Skip to content

Storage GCS

Persists task output to Google Cloud Storage. Good for serverless and cloud-native workflows on GCP.

Note

Requires pip install dotflow[gcp]

Example

from dotflow import Config, DotFlow, action
from dotflow.providers import StorageGCS


@action
def step_one():
    return {"message": "hello from GCS"}


@action
def step_two(previous_context):
    print(previous_context.storage)
    return "ok"


config = Config(
    storage=StorageGCS(
        bucket="dotflow-io-bucket",
        prefix="workflows/",
        project="etl-test",
    )
)


def main():
    workflow = DotFlow(config=config)

    workflow.task.add(step=step_one)
    workflow.task.add(step=step_two)
    workflow.start()

    return workflow



# Code below omitted 👇
👀 Full file preview
from dotflow import Config, DotFlow, action
from dotflow.providers import StorageGCS


@action
def step_one():
    return {"message": "hello from GCS"}


@action
def step_two(previous_context):
    print(previous_context.storage)
    return "ok"


config = Config(
    storage=StorageGCS(
        bucket="dotflow-io-bucket",
        prefix="workflows/",
        project="etl-test",
    )
)


def main():
    workflow = DotFlow(config=config)

    workflow.task.add(step=step_one)
    workflow.task.add(step=step_two)
    workflow.start()

    return workflow


if __name__ == "__main__":
    main()

Authentication

StorageGCS uses Application Default Credentials (ADC):

  1. Environment variable: GOOGLE_APPLICATION_CREDENTIALS pointing to a service account JSON
  2. gcloud auth application-default login for local development
  3. Service account: automatic on Cloud Run, Cloud Functions, GKE

No credentials are needed in code — the GCP client handles it transparently.

References