Dileep Damodaran

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

    bot_ids = Parameter("Bot Ids", required=False, default="")
    bots = 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
flow. I was always getting
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?

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: I highly recommend switching to Prefect 2 where this subtly is not an issue