Set up a Prefect Scheduled Deployment

You’ll need three terminal windows for the following steps (or I like to use screen so I don’t have too many windows open). I’ve bolded the required steps.

Optionally, in terminal 1, set up a virtual env if you’d like.

# venv
python -m venv prefect-env
source prefect-env/bin/activate. # activate env
# conda
conda create -n prefect-env python=3.9
conda activate prefect-env. # activate env

In terminal 1, start an Orion server (be sure to activate your env if you created one):

pip install -U "prefect>=2.0b"
prefect orion start

In terminal 2, create a work-queue and an agent to watch that work-queue (be sure to activate your env if you created one)

prefect work-queue create process-work-queue
prefect agent start <UUID>  # replace with actual UUID 

Optionally, if using a Raspberry Pi and you get a numpy error:
sudo apt-get install libatlas-base-dev

Optionally in terminal 3, download a flow (or write your own; be sure to activate your env if you created one):

mkdir flows
cd flows
pip install pandas numpy
wget https://raw.githubusercontent.com/ahuang11/forecast_verification_flow/main/store_nws.py

Lastly in terminal 3, deploy the flow (be sure to activate your env if you created one):

prefect deployment create store_nws.py
prefect deployment run process-forecasts/hourly-deployment # <name of flow>/<name of deployment>

Visit 127.0.0.1:4200 in your browser to see your flow deployed and running!

1 Like