Workflows
A workflow is a list of stages. Each stage names an app that already has a handler. depends lists the stages that must finish first. Deploy stores the stage names and the app each one calls. The Python function body stays in that app’s image.
import surfra
@surfra.stage(app="hello", output_schema={"type": "object"})def hello(data): return {"text": "hello"}
@surfra.stage(app="world", depends=("hello",), input_schema={"type": "object"})def world(data): return {"text": data["text"] + " world"}
surfra.Workflow("hello-world").deploy()Workflow.deploy() sends the stages registered in this process. Pass a list when the stages are built by hand:
surfra.Workflow("hello-world").deploy([ {"name": "hello", "app": "hello", "depends": []}, {"name": "world", "app": "world", "depends": ["hello"]},])Stage names are unique inside the workflow. depends uses those names. Input and output schemas are optional and show up on the workflow canvas.
Submit a run with the same stage list:
app = surfra.App("hello")job = app.submit( [ {"name": "hello", "app": "hello", "depends": []}, {"name": "world", "app": "world", "depends": ["hello"]}, ], metadata={"application": "hello-world"},)print(job["id"])