parameters: ()
return_statement: return flask.send_file(buffer, mimetype="application/gzip",
                             as_attachment=True,
                             attachment_filename="Halite.tgz")
docstring: Retrieve the worker blob from object storage.
docstring_summary: Retrieve the worker blob from object storage.
docstring_tokens: Retrieve the worker blob from object storage .
function: def download_source_blob():
      """Retrieve the worker blob from object storage."""
  
      cached_blob = cache.get(config.WORKER_ARTIFACT_KEY)
      if cached_blob is None:
          print("Getting from GCloud", config.WORKER_ARTIFACT_KEY)
          # Retrieve from GCloud
          try:
              gcloud_blob = gcloud_storage.Blob(
                  config.WORKER_ARTIFACT_KEY,
                  model.get_deployed_artifacts_bucket(),
                  chunk_size=262144)
              cached_blob = gcloud_blob.download_as_string()
              cache.set(config.WORKER_ARTIFACT_KEY, cached_blob)
          except gcloud_exceptions.NotFound:
              raise util.APIError(404, message="Worker blob not found.")
  
      if cached_blob is None:
          raise util.APIError(404, message="Worker blob not found.")
  
      print("Building buffer")
      buffer = io.BytesIO()
      buffer.write(cached_blob)
      buffer.seek(0)
      return flask.send_file(buffer, mimetype="application/gzip",
                             as_attachment=True,
                             attachment_filename="Halite.tgz")
function_tokens: def download_source_blob ( ) : cached_blob = cache . get ( config . WORKER_ARTIFACT_KEY ) if cached_blob is None : print ( "Getting from GCloud" , config . WORKER_ARTIFACT_KEY ) # Retrieve from GCloud try : gcloud_blob = gcloud_storage . Blob ( config . WORKER_ARTIFACT_KEY , model . get_deployed_artifacts_bucket ( ) , chunk_size = 262144 ) cached_blob = gcloud_blob . download_as_string ( ) cache . set ( config . WORKER_ARTIFACT_KEY , cached_blob ) except gcloud_exceptions . NotFound : raise util . APIError ( 404 , message = "Worker blob not found." ) if cached_blob is None : raise util . APIError ( 404 , message = "Worker blob not found." ) print ( "Building buffer" ) buffer = io . BytesIO ( ) buffer . write ( cached_blob ) buffer . seek ( 0 ) return flask . send_file ( buffer , mimetype = "application/gzip" , as_attachment = True , attachment_filename = "Halite.tgz" )