Thread
#prefect-community
    Martin T

    Martin T

    3 months ago
    What is the proper way to modify one Parameter() based on another Parameter()? This does not work:
    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)
    $ 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...
    Anna Geller

    Anna Geller

    3 months ago
    What are you trying to do? Can you explain your use case?
    Martin T

    Martin T

    3 months ago
    Enforce that when user provides a specific parameter value (dry mode), another parameter is automatically set.
    Anna Geller

    Anna Geller

    3 months ago
    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
    Kevin Kho

    Kevin Kho

    3 months ago
    I think you shouldn’t have two parameters then? You should just set one and generate the other right?