Hi, how do I pass arguments to a flow in command l...
# prefect-community
p
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
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
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
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! panda dancing
👍 1
p
Do you suggest manually edit deployment.yaml at this time? Ultimately I like to set the default parameters from some app config file.
t
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
Hi Patrick, you can set default arguments for
deployment.yaml
by adding a default arguments to your flow:
Copy code
@flow
def my_flow(a=1, b=2):
  ...
👍 1
☝️ 1
t
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:
Copy code
NAME=foobar
STYLE=frumpy
and also as JSON:
Copy code
{
  'NAME' : 'foobar',
  'STYLE' : 'frumpy'
}
neither of these appear to work. What am I missing?
In both cases, I get the following exception:
Copy code
pydantic.error_wrappers.ValidationError: 1 validation error for Process
env
  value is not a valid dict (type=type_error.dict)
k
Hmm. The JSON looks right to me. Do you happen to wrap the JSON inside a quotation?