https://prefect.io logo
Title
d

Dileep Damodaran

01/25/2023, 3:38 AM
Hi , I wanted to accept a parameter to a master
prefect
flow and set the reference tasks parameters based on that.
with Flow(
    "Master",
    schedule=schedule,
    run_config=master_run_config,
    terminal_state_handler=_utils.final_state_handler,
) as flow:
    logger = prefect.utilities.logging.get_logger("master")

    bot_ids = Parameter("Bot Ids", required=False, default="")
    bots = bot_ids.run() if bot_ids else ""
    bots = [x for x in bots.split(",") if x]
    bots = [x.strip() for x in bots]

    
    all_b = ['A','B','C','D']
    unknown_bots = [b for b in bots if b and b not in all_b]

    if len(unknown_bots) > 0:
       #TODO  raise exception

    #TODO set reference tasks
From the above code snippet, I’m expecting a parameter
Bot Ids
and checking if the supplied
Bot Ids
are valid or not. Here I’m facing two issues: •
Bot Ids
parameter is not available in the prefect UI. I tried passing
Bot ids
to one of the reference tasks (Though I’m not using the parameter inside the task), and the parameter started appearing in the prefect Run Flow UI. is there any way to make the parameter input available in prefect Ui without having to pass the parameter to any of the reference tasks • I tried passing values for
Bot Ids
from the prefect UI and noticed that it was not getting captured in the
master
flow. I was always getting
bot_ids
as empty • I tried changing the default value of the parameter , and noticed that the flow was working as expected.
bot_ids = Parameter("Bot Ids", required=False, default="steps")
Why is that the default value works in this case, but not the supplied values?
c

Chris White

01/25/2023, 4:03 PM
Hi Dileep - Prefect 1 flows represent compiled / deferred execution graphs; your code is running immediately without Prefect involvement or orchestration. This SO answer explains it a little more: https://stackoverflow.com/a/64158793/1617887 I highly recommend switching to Prefect 2 where this subtly is not an issue