Back to examples
Basics
Hello World
The minimal DAGY example; define a task, wrap it in a flow, and deploy.
When to use
Use this as your starting point when learning DAGY. It shows the absolute minimum needed to define and deploy a pipeline.
basics/hello-world.py
"""
01_hello_world.py: Minimal DAGY example.
Demonstrates:
- Defining a task with @task
- Defining a flow with @flow
- Running locally with flow.run_local()
"""
from dagy import flow, task
@task
def greet(name: str) -> str:
return f"Hello, {name}! Welcome to DAGY."
@flow(name="hello_world")
def hello_world_flow(name: str = "World") -> None:
greet(name)
if __name__ == "__main__":
result = hello_world_flow.deploy(name="hello_world")
print(f"Deployed : {result.flow_name}:{result.flow_version}")
print(f"Deployment: {result.deployment_name}")How it works
- Import `flow` and `task` from `dagy`.
- Decorate a function with `@task` to make it a pipeline step.
- Decorate another function with `@flow(name=...)` to define the pipeline.
- Inside the flow, call the task; DAGY records the dependency automatically.
- Call `flow.deploy()` to register the pipeline with DAGY Cloud.
Inputs
- `name` (str, default `"World"`): the name to greet.
Outputs
- A greeting string returned by the `greet` task.
- Deployment metadata (flow name, version, deployment name).
Dependencies
`dagy` (core SDK)