Hi everyone, Does anyone know of a way to schedule a deployment run manually . To give you more context I have created a flow and a deployment . I want to trigger the flow to run inside the deployment manually instead of a schedule which has a timeframe to specify for the execution . How do I achieve an on-demand deployment run with prefect .
P.S: I'm using the open-source version
t
Tyson Chavarie
10/03/2023, 4:52 PM
If you don't provide a schedule in your deploy command you will be able to run it manually as you are describing. I use Prefect Cloud but it should be the same..
s
Sam Joel
10/03/2023, 5:51 PM
Thanks @Tyson Chavarie . But how do you trigger the deployment run manually with custom parameters is it an API call or do we have any SDK functions which can do those because I searched the docs but didnt find any. Just saw a manual trigger on the UI.
t
Tyson Chavarie
10/03/2023, 5:55 PM
yeah for manually triggering I would use the UI. You can pick customer run when you click the play button and it lets you configure some additional parameters..not sure if this works in OpenSource version
n
Nate
10/04/2023, 12:15 AM
hi @Sam Joel - you can use
run_deployment
like
Copy code
from prefect.deployments import run_deployment
my_deployment = "my-flow/first-deployment"
flow_run = run_deployment(
name=my_deployment,
parameters={"answer": 42}, # assumes `my_flow` function accepts an `answer: int`
scheduled_time=datetime.now() + timedelta(hours=1) # start in an hour
# timeout = 0 # if you don't want this to wait for the triggered flow run to finish
)
assert flow_run.state.is_completed(), f"{flow_run.name} did not complete :("
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.