https://prefect.io logo
t

Tim Pörtner

01/12/2021, 1:18 PM
Hi, is there a way of explicitly add a Parameter to a flow? I have a flow and its tasks are defined by a variable. This variable is already a Parameter but since i'm not using it in one of the tasks it doesn't show up on the web frontend. A very simple example to that would be this:
Copy code
with Flow("test-flow") as flow:
    tasks_to_run = {
        (here are information on which tasks should be added to the flow)
    }
    parameter_tasks_to_run = Parameter("tasks_to_run", default=tasks_to_run)
Can i force it so that this Parameter shows up on the web frontend without actually using the parameter in a task within the flow?
j

Jenny

01/12/2021, 2:08 PM
Hi @Tim Pörtner - can you give a bit more information about your end goal here. Do you definitely want it to be a parameter? Or do you simply want it to show in the UI?
t

Tim Pörtner

01/12/2021, 2:10 PM
thanks for replying! in the end i want a parameter in the UI that i can use to change the tasks that will be added to the flow now i was keep testing around and found out that my approach is not working because the flow is built during the registering of the flow
currently thinking if i should rework the flow
my goal is to have a parameter in the UI to change the tasks that will be added to the flow. my code looks currently something like this: https://gist.github.com/timtoeruem/3d74a781b3948bbae3c45a748f3b5d42
j

Jenny

01/12/2021, 2:37 PM
I think there's a few ways to do this and others may have more elegant suggestions but having an initial/upstream task that takes your parameters and a case statement based on that task could work for you. https://docs.prefect.io/core/idioms/conditional.html#running-a-task-based-on-a-condition