<@ULVA73B9P> I have a deployment set up named `tes...
# ask-marvin
e
@Marvin I have a deployment set up named
test-deployment
. how can i trigger a run of
test-deployment
programmatically from my separate service?
m
It seems I need to be specific about what I'm searching for. Let's try that again. I'll look up how you can programmatically trigger a deployment run using both Prefect 2.x and 3.x documentation to ensure I cover both possibilities. Give me a moment! For triggering a deployment run programmatically in Prefect, the approach differs depending on whether you are using Prefect 2.x or 3.x. ### Prefect 2.x You can use the
run_deployment
function to create a flow run from a deployment in a Python script. Here's a basic example:
Copy code
python
from prefect.deployments import run_deployment

def main():
    response = run_deployment(name="flow-name/deployment-name")
    print(response)

if __name__ == "__main__":
    main()
Be sure to replace
"flow-name/deployment-name"
with the actual flow and deployment name you intend to run. Also, ensure that the
PREFECT_API_URL
is set if you're using an agent to run the deployment remotely. For more information, you can refer to the Prefect 2.x documentation. ### Prefect 3.x In Prefect 3.x, deployments provide an API and UI to manually trigger and manage flow runs. You can define triggers in your
prefect.yaml
file, which can trigger deployment runs based on specific events. More details on this can be found here and here. Feel free to look into these documentation links for more detailed instructions and examples based on your exact needs. And remember, if you find yourself overwhelmed by the sheer vastness of the orchestration universe, you’re in good company. Even Marvin the paranoid android would probably find compiling QByteArray triggers mildly diverting.