Build bulletproof workflows
Ship resilient code faster, and turn your workflows into powerful applications
1from prefect import flow, task
2
3
4@task(log_prints=True)
5def say_hello(name: str):
6 print(f"Hello {name}!")
7
8
9@flow
10def hello_universe(names: list[str]):
11 for name in names:
12 say_hello(name)
13
14
15if __name__ == "__main__":
16 # create your first deployment to automate your flow
17 hello_universe.serve(name="your-first-deployment")
Ship trustworthy pipelines faster
With Prefect orchestration, build scalable workflows in pure python without changing how you work:
- Scheduling
- Retries
- Parameterization
- Dependency management
- Caching
1import httpx
2from prefect import flow, task
3
4
5@task
6def get_url(url: str, params: dict = None):
7 response = httpx.get(url, params=params)
8 response.raise_for_status()
9 return response.json()
10
11
12@flow(retries=3, retry_delay_seconds=5, log_prints=True)
13def get_repo_info(repo_name: str = "PrefectHQ/prefect"):
14 url = f"https://api.github.com/repos/{repo_name}"
15 repo_stats = get_url(url)
16 print(f"{repo_name} repository statistics 🤓:")
17 print(f"Stars 🌠: {repo_stats['stargazers_count']}")
18 print(f"Forks 🍴 : {repo_stats['forks_count']}")
19
20
21if __name__ == "__main__":
22 get_repo_info.serve(name="my-first-deployment")
Visualize, monitor, and triage
From the individual flow to your entire system health, always know where your failures are:
- Visualize the execution graph of thousands of workflow tasks
- Inspect individual workflows, or track holistic health
- Notify your stakeholders and get ahead of questions
Dev to production, simplified
Spin up a local orchestration server with a single command. No code changes means your workflow runs as expected, locally or in production.
$ prefect server start
___ ___ ___ ___ ___ ___ _____
| _ \ _ \ __| __| __/ __|_ _|
| _/ / _|| _|| _| (__ | |
|_| |_|_\___|_| |___\___| |_|
Configure Prefect to communicate with the server with:
prefect config set PREFECT_API_URL=http://127.0.0.1:4200/api
View the API reference documentation at http://127.0.0.1:4200/docs
Check out the dashboard at http://127.0.0.1:4200
Learn About Prefect
Just write python
Add a single decorator to your functions to gain scheduling, monitoring, and resiliency without unnecessary abstractions.
1import prefect
2from prefect import flow
3
4@flow
5def simple_looping_flow():
6 for i in range(5):
7 print(f"Current iteration: {i}")
8
9if __name__ == "__main__":
10 simple_looping_flow.serve(name="simple_looping_flow_deployment")
Infrastructure agnostic
Configure your execution environment, all the way down to the individual @flow. With work pools and work queues, you have granular control over your infrastructure.
Granular access controls
Stay compliant and manage provisions & permissions the way you want to
- SSO & SCIM
- Team management
- Custom roles and RBAC
- Object-level access control