https://prefect.io logo
a

Anze Kravanja

01/22/2021, 6:06 AM
Hello! I’m pretty new to the tool but love it so far! I have a question, if I have a flow, the flow is registered and has parameters, can I schedule 2 flow runs at two different schedules with different parameters? I know I can easily do a one time run in the UI with diff parameters.
z

Zanie

01/22/2021, 3:13 PM
Hi @Anze Kravanja -- off the top of my head you could just register the same flow with two names then set the schedule on each. I’m not sure there’s a straightforward way to get two overlapping schedules on a single flow, although the CRON syntax is pretty powerful so you could probably achieve your target schedule in a single one.
a

Anze Kravanja

01/22/2021, 3:47 PM
Yes, I think that’s a solid option, but in some cases I might not know how many flows I want to run with different params. For example, pulling some data based on an account id will always have the same flow, but I might get more and more account ids to run for. So I could just register a new flow each time, which would require adding code, but if I could just schedule another run with a new set of params and a schedule that would be cleaner.
n

nicholas

01/22/2021, 3:57 PM
Hi @Anze Kravanja - this is doable without re-registering! To do that you would use varying parameter clocks. Which look something like this in your code:
Copy code
clock1 = clocks.CronClock("1 * * * *", parameter_defaults={"foo": "bar"})
clock2 = clocks.CronClock("2 * * * *", parameter_defaults={"foo": "batz"})

schedule = Schedule(clocks=[clock1, clock2])

flow.schedule = schedule
🦜 1
z

Zanie

01/22/2021, 4:01 PM
🤯 thanks Nicholas 🙂
a

Anze Kravanja

01/22/2021, 4:03 PM
Awesome stuff! Thank you very much! I suppose this same thing can’t be done via UI yet, but I have a feeling the API might have support for this.
n

nicholas

01/22/2021, 4:06 PM
That's correct @Anze Kravanja - the UI supports multiple clocks on the flow group but doesn't yet support varying parameters by clock
1
c

Chris White

01/22/2021, 5:00 PM
@Marvin archive “How can I schedule two different runs with two different parameter values?”
4 Views