Prefect is an open-source workflow orchestration and management system that allows users to build, run, and monitor data pipelines. It provides a robust framework for defining workflows as Python code, complete with task dependencies, retries, caching, and state management. The current stable version is 3.6.25, with frequent nightly development builds and stable releases typically every few weeks.
pip install prefectVerified import paths — ran on the pinned version, not inferred.
This quickstart defines a simple task and a flow that uses it. It then demonstrates how to `serve` the flow, which will start a local Prefect API server and agent, and register the flow as a deployment. This allows you to observe flow runs and their states in the Pref Prefect UI (http://localhost:4200). For connecting to Prefect Cloud, set `PREFECT_API_URL` and `PREFECT_API_KEY` environment variables.
Review the Prefect 2 migration guide and rewrite existing Prefect 1 flows to conform to the new API and concepts. There is no automated upgrade path.
Always use `flow.to_deployment()` and then either `serve()` for local development/testing or `prefect deploy` for production environments to register your flow with the Prefect API and enable orchestration.
For local development, use `prefect serve()` to start a temporary server and agent, or run `prefect server start` in a separate terminal. For Prefect Cloud, set the necessary environment variables (`PREFECT_API_URL`, `PREFECT_API_KEY`).
After code changes, re-run your `serve()` script or use the `prefect deploy` CLI command to update the deployment definition.
Ensure Prefect and all custom flow dependencies are installed in the Python environment where the flow is executed. If running locally, activate your virtual environment. For deployments, verify the Docker image or execution environment includes all necessary packages and that the Python path is correctly configured for custom modules. Example for installation: `pip install prefect`.
Check worker/container logs for OOM or other termination signals. Increase resources (memory, CPU) for the execution environment. For long-running tasks, consider breaking them down, utilizing Prefect's concurrency features, or adjusting the `PREFECT_RUNNER_HEARTBEAT_FREQUENCY` environment variable. Ensure stable network connectivity to the Prefect API.
Verify `PREFECT_API_URL` and `PREFECT_API_KEY` environment variables or profile settings using `prefect config view`. Ensure the API key is valid and has the necessary permissions. Check network connectivity, firewall rules, and proxy settings (e.g., `HTTPS_PROXY`, `SSL_CERT_FILE`) to allow communication with the Prefect API. If self-hosting, ensure the Prefect server is running and accessible.
Ensure the deployment's `entrypoint` in your `prefect.yaml` correctly points to an existing Python file and a valid Prefect flow function within it. Verify that the file exists and is accessible from the environment where `prefect deploy` is run. Check that any dependencies required for loading the flow are present in that environment. For example, if your flow is `my_module.py:my_flow`, ensure `my_module.py` exists and `my_flow` is a `@flow` decorated function.
No dependency data recorded yet.