How to override default parameter values when creating a flow run from deployment?

View in #prefect-community on Slack

Jose_Daniel_Posada_Montoya @Jose_Daniel_Posada_Montoya: Hi, Orion question, is there any upcoming plan in the roadmap that allows modifying the parameters of a deployment from the UI before launching a Flow Run of it. Thanks!

Anna_Geller @Anna_Geller: That’s definitely on the roadmap. To make sure you can track it, let me open an issue for it.
@Marvin open “Orion: allow changing parameter values when triggering a flow run from a deployment in the UI”

Marvin @Marvin: Orion: allow changing parameter values when triggering a flow run from a deployment in the UI · Issue #5617 · PrefectHQ/prefect · GitHub

Jose_Daniel_Posada_Montoya @Jose_Daniel_Posada_Montoya: Good to know, thanks a lot!

Michael_Smith @Michael_Smith: Similar question for the CLI (api client). At the moment the cli doesnt accept parameters when running deployments. In addition is it possible to install the prefect client independently of the entire prefect package? Are there any API docs for PF2?

Jose_Daniel_Posada_Montoya @Jose_Daniel_Posada_Montoya: You can’t do it thru the CLI, but you can override default params using the Python client or REST API using create_flow_run_from_deployment

Hi! To find out what I can do, say @marvin display help.

@marvin display help

I currently know how to do the following things:

@marvin start {name-of-tutorial}

Starts an interactive tutorial just for you, in a personal message. {name-of-tutorial} can be one of: tutorial, advanced tutorial.

@marvin roll 2d6

:game_die: 3, 6

@marvin quote

:left_speech_bubble: The thoughts we choose to think are the tools we use to paint the canvas of our lives. — Louise Hay

@marvin fortune

:crystal_ball: You may rely on it

I recently had this issue and found a way to launch a flow run with a deployment and override parameters within the Prefect API. Posting the code below in case this will help someone else.

Basically, create an OrionClient object and run the create_flow_run_from_deployment function in an async loop. Solution works on Prefect 2.0.2.

from prefect.client import OrionClient
import asyncio
prefect_client = OrionClient(api="http://<ip>:4200/api")
loop = asyncio.get_event_loop()
task = loop.create_task(
    prefect_client.create_flow_run_from_deployment(
        deployment_id="188e210d-4246-45d4-9ac2-014852b96115",
        parameters={'content_id':'new_content_id'}))
loop.run_until_complete(task)
1 Like

Nice work and thanks for sharing!