Getting Started¶
This guide walks you through setting up the airnub-prefect-starter project on your local machine for development and running your first flow.
Prerequisites¶
Before you begin, ensure you have the following installed:
- Python: Version specified in
pyproject.toml(e.g., 3.12+). We recommend using a Python version manager likepyenv. - Docker: Required for running the local development environment (Prefect Server, Database, Worker). Install Docker Desktop or Docker Engine/CLI.
- Docker Compose: Usually included with Docker Desktop. Verify with
docker compose version. - Git: For cloning the repository.
make: (Optional, Recommended) For using the convenient Makefile commands. Available on Linux/macOS, may require installation on Windows (e.g., via Chocolatey or WSL).
Setup Steps¶
-
Clone the Repository: Open your terminal and clone the project repository:
-
Create and Activate Virtual Environment: It's crucial to work within a virtual environment to manage dependencies.
You should see# Create the environment (using uv, as per Makefile): make create_environment # Or using Python's built-in venv: # python -m venv .venv # Activate the environment # On macOS/Linux: source .venv/bin/activate # On Windows (Command Prompt): # .\.venv\Scripts\activate.bat # On Windows (PowerShell): # .\.venv\Scripts\Activate.ps1(.venv)at the beginning of your terminal prompt. -
Install Dependencies: This project uses
(This typically runsuv(a fast Python package installer/resolver). Themake installcommand handles installinguv(if not present globally and then project dependencies).uv pip install --no-cache --upgrade -e ".[dev]"which includes development dependencies). -
Configure Prefect API Target: Prefect needs to know which API endpoint to communicate with (your local server or Prefect Cloud). Set the
PREFECT_API_URLenvironment variable.Tip: For persistent local configuration, consider adding this# For the local Docker Compose setup (we'll start this soon): export PREFECT_API_URL="[http://127.0.0.1:4200/api](http://127.0.0.1:4200/api)" # If connecting to Prefect Cloud (replace with your actual URL/Key): # export PREFECT_API_URL="YOUR_PREFECT_CLOUD_API_URL" # export PREFECT_API_KEY="YOUR_PREFECT_CLOUD_API_KEY" # Required for Cloudexportline to your shell's profile (.zshrc,.bashrc,.bash_profile) or use a.envfile at the project root (seeREADME.mdfor notes on.envusage with Docker Compose and scripts). -
Start Local Development Services: This uses Docker Compose to start the Prefect Server, UI, PostgreSQL database, and the custom Prefect Worker based on the project's
Wait for the services to initialize. You'll see logs in your terminal.Dockerfile.worker. -
Access Prefect UI: Open your web browser and navigate to
http://127.0.0.1:4200. You should see the Prefect UI. -
Set up Prefect Blocks: The base template's
make setup-blockscommand primarily sets up essential local infrastructure blocks, such as aDockerContainerblock namedlocal-worker-infrawhich is used by local deployments defined inprefect.local.yaml.If you wish to extend this template to use specific cloud services (e.g., for remote file storage), you would typically:# Ensure PREFECT_API_URL is set to the local server (Step 4) # You can place PREFECT_API_URL and PREFECT_BLOCK_OVERWRITE=true in a setup.env file too. make setup-blocks- Add the required optional dependencies (e.g.,
uv pip install -e ".[aws]"for AWS S3). - Modify
scripts/setup_prefect_blocks.pyor create a new script to define and create blocks for those cloud services (e.g.,S3Bucket,GCSBucket). This would likely involve setting cloud provider-specific environment variables (likeSETUP_CLOUD_ACCESS_KEY,SETUP_BUCKET_NAME) before running your modified script.
Verify any created blocks (e.g.,
docker-container/local-worker-infra) appear in the Prefect UI under the "Blocks" section. See the Configuration Guide for more details. - Add the required optional dependencies (e.g.,
-
Set up Prefect Variables: This step loads configurations from the YAML files in
(You can setconfigs/variables/into Prefect Variables, which your flows will use for runtime parameters.PREFECT_VARIABLE_OVERWRITE=trueas an environment variable if you want to force updates to existing variables). -
Apply Flow Deployments: Register the example flows defined in the
Check the "Deployments" page in the UI. You should see deployments for the example "Project Alpha" department, such as "Ingestion Deployment (Project Alpha) - Local Dev".flows/directory (e.g., for the "Project Alpha" department) with the running local Prefect server. -
Run Your First Flow:
- Navigate to the "Deployments" page in the Prefect UI (
http://127.0.0.1:4200/deployments). - Find an example deployment (e.g., "Ingestion Deployment (Project Alpha) - Local Dev").
- Click the "Run" button (usually a play icon ▶️) in the top right.
- Accept the defaults or provide parameters if needed, and click "Run".
- You can monitor the flow run's progress on the "Flow Runs" page. Check the logs within the UI or using
docker compose logs -f workerin your terminal.
- Navigate to the "Deployments" page in the Prefect UI (
-
Stopping the Local Environment: When you're finished developing locally:
This stops and removes the Docker containers, network, and database volume.
Next Steps¶
- Learn more about the project's Configuration.
- Understand the Core Concepts & Architecture.
- Explore how to Use and Run Flows in more detail.
- See the guide on Development for adding your own flows and tasks.