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):
- Environment variable:
GOOGLE_APPLICATION_CREDENTIALSpointing to a service account JSON gcloud auth application-default loginfor local development- Service account: automatic on Cloud Run, Cloud Functions, GKE
No credentials are needed in code — the GCP client handles it transparently.