Hi everyone, Does anyone know of a way to schedule...
# prefect-cloud
s
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
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
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
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
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 :("
🙌 1
s
Thanks @Nate this is what I was looking for .