Charles Liu
07/15/2021, 5:43 PMKevin Kho
environment = "prod"
user = "${environments.${environment}.user}"
[environments]
[environments.dev]
user = "test"
[environments.prod]
user = "admin"
If you have this in the config.toml, you can then check the value inside your Flow. So think of these as settings you want on the agent also, whereas parameters are really about the Flow itself agnostic to where it is running. There is some overlap in what can be achieved with parameters an the context though.Charles Liu
07/15/2021, 5:52 PMCharles Liu
07/15/2021, 5:54 PMKevin Kho
x = Parameter("x", default=1)
Then you should see that window populated. And then you can specify the default there and override this. But if you just want one run with a different Parameter value, you should click the Run
instead of Quick Run
and it will let you set the Parameters there for that individual run.Charles Liu
07/15/2021, 6:07 PMimportant_number = Parameter("important_number", default=3)
@task()
def this_task():
task_params:{
"important_number": 3
}
with Flow()...etc.
Kevin Kho
@task
def abc(x):
logger = prefect.context.get("logger")
<http://logger.info|logger.info>(x)
return x
with Flow("context-test") as flow:
x = Parameter("x", default=3)
a = abc(x)
Charles Liu
07/15/2021, 6:08 PMKevin Kho
Charles Liu
07/15/2021, 6:10 PMCharles Liu
07/15/2021, 6:30 PMKevin Kho
Charles Liu
07/15/2021, 6:57 PMCharles Liu
07/15/2021, 6:58 PMKevin Kho
task(lambda x: x+1)(value)
Charles Liu
07/15/2021, 7:12 PMKevin Kho
with Flow("context-test") as flow:
x = Parameter("x", default=1)
y = Parameter("y", task(lambda x: x + 1))
a = abc(y)
The default needs to be static because it’s registered and saved during build time. y
here shouldn’t be a Parameter. You can just do the y = task(lambda x: x +1)(x)
Charles Liu
07/15/2021, 8:41 PMCharles Liu
07/16/2021, 7:16 PMCharles Liu
07/16/2021, 7:16 PMKevin Kho
Charles Liu
07/19/2021, 6:26 PMCharles Liu
07/19/2021, 6:27 PMKevin Kho
Kevin Kho
Kevin Kho
Charles Liu
07/19/2021, 7:42 PM