What is the proper way to modify one Parameter() b...
# prefect-community
m
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
What are you trying to do? Can you explain your use case?
m
Enforce that when user provides a specific parameter value (dry mode), another parameter is automatically set.
a
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
I think you shouldn’t have two parameters then? You should just set one and generate the other right?