I'm registering a Flow with two Schedules, my inte...
# ask-community
s
I'm registering a Flow with two Schedules, my intent is to have the same Flow run twice but with different Parameters for each run:
Copy code
schedule=Schedule(
            clocks=[
                IntervalClock(
                    start_date=pendulum.datetime(2020, 1, 1, tz='UTC'),
                    interval=datetime.timedelta(days=1),
                    parameter_defaults=dict(
                        sfdc_listener_name='CustomerService',
                        sfdc_report_url='...'
                    )
                ),
                IntervalClock(
                    start_date=pendulum.datetime(2020, 1, 1, tz='UTC'),
                    interval=datetime.timedelta(days=1),
                    parameter_defaults=dict(
                        sfdc_listener_name='OneSupport',
                        sfdc_report_url='...'
                    )
                )
            ]
        ),
However, it seems that when this registered with Prefect Cloud, only the first Schedule is setup. Do I need to create two different Flows to have the same logic execute with different parameters on a schedule?
k
Hey Scott! If clocks yield the same datetimes, Prefect will only accept the first one. So, you can add a one second offset on your second clock HOWEVER that one second offset will accumulate over time. Soooo, I would recommend switching from an IntervalClock to a CronClock to ensure there’s no accumulation!
upvote 1
s
I updated the schedule to CronClock, but it's still only scheduling one of them in Prefect Cloud:
Copy code
schedule=Schedule(
            clocks=[
                CronClock(
                    cron='0 0 * * *',
                    parameter_defaults=dict(
                        sfdc_listener_name='CustomerService',
                        sfdc_report_url='...'
                    )
                ),
                CronClock(
                    cron='0 0 * * *',
                    parameter_defaults=dict(
                        sfdc_listener_name='OneSupport',
                        sfdc_report_url='...'
                    )
                )
            ]
        ),
Couldn't the scheduler check the
parameter_defaults
to evaluate if they're the same or not? Or at least throw an error during the build process (when duplicate clocks are detected in the schedule) so I don't have to iterate through multiple build/deploys to get the desired results? Attempting to modify the cron command to see if that has any difference on the clocks
Having different cron strings allowed it to schedule the multiple clocks.
k
I’m glad that worked for now. I’ll definitely look into ways to make that Scheduler behavior more explicit.
c
@Marvin archive “Running a Flow with two identical Clocks but different Parameters”