Hi All, Is there a way to dynamically create multi...
# ask-community
d
Hi All, Is there a way to dynamically create multiple schedules from the same job, just with different configs
🤖 1
s
Hi David, Do you mean for (rather than from) the same job? If so: • Since schedules are defined in Python code, there’s no reason you can’t create them dynamically • You can define multiple schedules for the same job
d
Yes, I have one Job and want multiple schedules: At the moment I am creating multiple Run Request from the same Schedule:
Copy code
@schedule(
    job=job1,
    execution_timezone="Europe/Berlin",
    cron_schedule="*/5 * * * *",
    default_status=DefaultScheduleStatus.RUNNING

)
def job1_schedule():
    for config in [config1, config2, config3, ....]
        yield RunRequest(
            run_key="job1",
            run_config= config
        )
Is there a way to loop over my configs and create a schedule for each one?
s
If I understand you, something like this should work:
Copy code
schedules = []

for i, config in enumerate([config1, config2, config3]):
    @schedule(job=job1, name=f"job1_schedule_{i}", ...)
    def schedule_func():
        yield RunRequest(...)
    schedules.append(schedule_func)
Has that solved your issue?
d
Sorry only getting back to this now, yes thank you this helped me
👌 1