https://prefect.io logo
Title
s

Scott Zelenka

03/26/2020, 8:19 PM
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:
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

Kyle Moon-Wright

03/26/2020, 8:28 PM
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

Scott Zelenka

03/26/2020, 9:12 PM
I updated the schedule to CronClock, but it's still only scheduling one of them in Prefect Cloud:
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

Kyle Moon-Wright

03/26/2020, 9:33 PM
I’m glad that worked for now. I’ll definitely look into ways to make that Scheduler behavior more explicit.
c

Chris White

03/26/2020, 11:04 PM
@Marvin archive “Running a Flow with two identical Clocks but different Parameters”