https://prefect.io logo
Title
p

Patrick Tan

08/09/2022, 1:13 PM
Hi, how do I pass arguments to a flow in command line when doing a deployment run in Prefect 2.0. Eg, prefect deployment run my_flow/dev ????(arguments)
βœ… 1
t

Taylor Curran

08/09/2022, 1:22 PM
Hi Patrick :) You can specify the arguments in the
deployment.yaml
file. Or you can use prefect.client create_flow_run_from_deployment() if you are comfortable using our API. Or you can override default argument values before a flow runs easily from right in the UI by clicking on the three dots to edit a deployment.
We are currently working to improve the configurability of deployments so you may have more options going forward to specify this in the CLI. These updates should be coming this month, keep an eye on release announcements for new functionality!
p

Patrick Tan

08/09/2022, 1:27 PM
OK. Good to know. I am migrating from 1.0 to 2.0 and first thing I try to achieve is not losing 1.0 capability
πŸ‘ 1
t

Taylor Curran

08/09/2022, 1:29 PM
Absolutely, as I said our deployment definition experience will have a lot more functionality in the next few weeks if that helps you plan. Also not sure if you have checked out our Migration Guide, but this will list out the many resources available for making the change. Happy engineering Patrick! πŸ˜›anda-dancing:
πŸ‘ 1
p

Patrick Tan

08/09/2022, 1:31 PM
Do you suggest manually edit deployment.yaml at this time? Ultimately I like to set the default parameters from some app config file.
t

Taylor Curran

08/09/2022, 1:33 PM
Depends on how frequently the argument values are changing. If they change every-time the flow runs, I would point you towards using our client (API) or using the UI where overrides to defaults can be made, however if its a matter of specifying default values, you can define these both inside your flow code and/or inside the .yaml file.
πŸ‘ 2
k

Khuyen Tran

08/09/2022, 2:35 PM
Hi Patrick, you can set default arguments for
deployment.yaml
by adding a default arguments to your flow:
@flow
def my_flow(a=1, b=2):
  ...
πŸ‘ 1
☝️ 1
t

Tony Piazza

10/03/2022, 10:47 PM
trying to specify environment variables with my deployment run via the configured block. i edited the associated block and tried adding them as key/value pairs:
NAME=foobar
STYLE=frumpy
and also as JSON:
{
  'NAME' : 'foobar',
  'STYLE' : 'frumpy'
}
neither of these appear to work. What am I missing?
In both cases, I get the following exception:
pydantic.error_wrappers.ValidationError: 1 validation error for Process
env
  value is not a valid dict (type=type_error.dict)
k

Khuyen Tran

10/04/2022, 2:31 PM
Hmm. The JSON looks right to me. Do you happen to wrap the JSON inside a quotation?