Pascal Jahan Elahi (Pawsey)
01/24/2025, 6:24 AMMarvin
01/24/2025, 6:25 AMbash
docker run -p 4200:4200 --rm <http://ghcr.io/astral-sh/uv:python3.12-bookworm-slim|ghcr.io/astral-sh/uv:python3.12-bookworm-slim> uvx prefect server start --host 0.0.0.0
This will start the Prefect server UI on <http://127.0.0.1:4200>
.
2. Run Your Workflow: Once your server is running, you can execute your workflows. If you have a flow defined, you can run it using the Prefect Python SDK. Here's a basic example of running a flow:
python
from prefect import flow
@flow
def my_flow():
print("Running my flow!")
if __name__ == "__main__":
my_flow()
3. Connect to the Local Server: Ensure that your Prefect client is pointing to your local server. You can set the PREFECT_API_URL
environment variable to connect to your local server:
bash
export PREFECT_API_URL="<http://127.0.0.1:4200>"
For more detailed instructions, you can refer to Prefect's self-hosting documentation and the Prefect server setup guide.
This should get you started with running workflows on a locally hosted Prefect server. If you have any specific configurations or issues, feel free to ask!Pascal Jahan Elahi (Pawsey)
01/24/2025, 6:26 AMpython my_flow.py
and it will contact the prefect server if I have the PREFECT_API_URL defined?Marvin
01/24/2025, 6:26 AMPREFECT_API_URL
environment variable to point to your local Prefect server, running your flow with python my_flow.py
should indeed contact the server. Here's a quick rundown:
1. Ensure the Prefect Server is Running: Make sure your Prefect server is running locally using the Docker command I provided earlier.
2. Set the API URL: Make sure the PREFECT_API_URL
is set in your environment:
bash
export PREFECT_API_URL="<http://127.0.0.1:4200>"
3. Run Your Flow: Simply execute your Python script:
bash
python my_flow.py
This will run the flow and log the run to your local Prefect server, where you can view details in the UI.
If you encounter any issues, ensure that your flow definition and any necessary imports are correctly set up.