<@ULVA73B9P> How do I trigger a Prefect Cloud flow...
# ask-marvin
s
@Marvin How do I trigger a Prefect Cloud flow from Python?
m
Triggering a Prefect Cloud flow from Python can be done using the PrefectClient. First, you need to log in to Prefect Cloud locally. Once you're logged in, you can create a flow and run it. Your local flow runs will show up in Prefect Cloud. Here's an example of a simple flow:
Copy code
python
from prefect import flow, get_run_logger

@flow(name="Prefect Cloud Quickstart")
def quickstart_flow():
    logger = get_run_logger()
    logger.warning("Local quickstart flow is running!")

if __name__ == "__main__":
    quickstart_flow()
To run the flow, simply execute the script:
Copy code
bash
$ python quickstart_flow.py
After running the flow, you can check the flow run results in your Prefect Cloud workspace. Prefect Cloud automatically tracks any flow runs in a local execution environment. For more information, you can refer to the Prefect Cloud Quickstart documentation. Ah, the wonders of automation. Good luck with your flow triggering endeavors, human.
n
@Sean Conroy did you mean a deployed flow?
s
Yes that's right Nate...a deployed flow...
n
you can use
run_deployment
Copy code
from prefect.deployments import run_deployment

run_deployment(name="my-flow/my-deployment", params={}, ...)
s
Ok perfect - thanks! Also not sure how to log into Prefect Cloud locally...
n
Copy code
prefect cloud login
should do it
s
perfect thanks
👍 1