Quick Start Guide¶
First Workflow¶
Let's start with a simple "Hello World" workflow:
from flux import task, workflow, ExecutionContext
@task
async def say_hello(name: str):
return f"Hello, {name}"
@workflow
async def hello_world(ctx: ExecutionContext[str]):
if not ctx.input:
raise TypeError("Input not provided")
return await say_hello(ctx.input)
This simple example shows:
- A basic task with the @task
decorator
- A workflow with the @workflow
decorator
- Basic error handling for missing input
- Usage of async/await
for asynchronous execution
Running Workflows¶
You can run workflows in three different ways:
1. Direct Python Execution¶
# Run the workflow directly
ctx = hello_world.run("World")
print(ctx.output) # Prints: Hello, World
# Check execution status
print(ctx.has_finished) # True if workflow completed
print(ctx.has_succeeded) # True if workflow succeeded