https://prefect.io logo
#prefect-community
Title
# prefect-community
m

Martin T

06/07/2022, 1:48 PM
What is the proper way to modify one Parameter() based on another Parameter()? This does not work:
Copy code
from prefect import Flow, Parameter, case, task

@task
def mytask(p2):
    print(p2)

with Flow("case-demo") as flow:
    p1 = Parameter("p1", default=False)
    p2 = Parameter("p2", default="good")
    with case(p1, True):
        p2 = "bad"
    mytask(p2)

print(flow.tasks)
Copy code
$ prefect build -p flow.py
UserWarning: Tasks were created but not added to the flow: {<Parameter: p1>, <Parameter: p2>}.
$ prefect run -p flow.py
...bad...
1
a

Anna Geller

06/07/2022, 1:49 PM
What are you trying to do? Can you explain your use case?
m

Martin T

06/07/2022, 1:52 PM
Enforce that when user provides a specific parameter value (dry mode), another parameter is automatically set.
a

Anna Geller

06/07/2022, 1:57 PM
this is usually what default parameter values are for - you set a default and if the user sets something else, then a custom value is used
k

Kevin Kho

06/07/2022, 10:33 PM
I think you shouldn’t have two parameters then? You should just set one and generate the other right?
6 Views