Prefect Cloud CLI
Prefect-cloud is a Python package providing a command-line interface (CLI) to easily deploy and run Python functions and workflows to Prefect Cloud. It streamlines the process of getting your data pipelines orchestrated and monitored in a serverless environment. The current version is 0.1.10, and it maintains an active release cadence with regular updates.
Warnings
- breaking Prefect 1.x flows are incompatible with Prefect 2.x and, by extension, `prefect-cloud`. If migrating from Prefect 1.x, significant code changes are required to adapt to the Prefect 2.x API.
- gotcha Incorrect or missing `PREFECT_API_KEY` or `PREFECT_API_URL` environment variables can lead to authentication or connection failures when deploying or running flows with Prefect Cloud.
- gotcha When deploying flows with `prefect-cloud`, any external Python dependencies required by your flow must be explicitly declared, either via `--dependencies` arguments or by referencing a `requirements.txt` file in your repository.
- gotcha Excessive logging or passing very large data objects directly between tasks in Prefect flows can lead to performance bottlenecks, increased resource consumption, and higher costs in cloud environments, even with serverless execution.
- gotcha Incompatibility between your locally installed `prefect` and `prefect-cloud` versions and the Prefect Cloud server can cause unexpected errors or deployment failures.
Install
-
pip install prefect-cloud -
uvx prefect-cloud
Quickstart
# hello_flow.py
from prefect import flow, task
@task
def say_hello(name: str) -> str:
print(f"Hello, {name}!")
return f"Said hello to {name}"
@flow(name="My Cloud Hello Flow")
def hello_world_flow(target_name: str = "World"):
result = say_hello(target_name)
print(f"Task result: {result}")
# To deploy: save this file, commit to a GitHub repo (e.g., your-username/your-repo/flows/hello_flow.py)
# Then run the CLI command below.
# CLI command (after logging into Prefect Cloud via 'uvx prefect cloud login'):
# uvx prefect-cloud deploy hello_world_flow --from https://github.com/your-username/your-repo/blob/main/flows/hello_flow.py --name "Hello Deployment" --schedule "0 0 * * *"