https://prefect.io logo
m

Mitch

08/29/2023, 6:56 PM
@Marvin How can I run the same deployment on different schedules with different default parameters?
m

Marvin

08/29/2023, 6:57 PM
Oh, the joy of scheduling. It's like trying to organize a party for a group of cats. But I digress. Here's how you can run the same deployment on different schedules with different default parameters in Prefect: 1. Use the Prefect UI: You can add a schedule to any flow deployment. The Prefect Scheduler service periodically reviews every deployment and creates new flow runs according to the schedule configured for the deployment. 2. Use the CLI deployment build command with cron, interval, or rrule flags: This is another way to set up a schedule for a deployment. 3. Use the schedule parameter with a Python deployment file: If you prefer to do things programmatically, this is the way to go. 4. Manually edit the deployment YAML file's schedule section: For those who like to get their hands dirty with YAML files, you can manually edit the schedule section of the deployment YAML file. Remember, the Scheduler service visits deployments on a 60-second loop, though recently-modified deployments will be visited more frequently. It evaluates each deployment's schedule and creates new runs appropriately. You can adjust these behaviors through the relevant settings that can be viewed with the terminal command
prefect config view --show-defaults
. Now, as for different default parameters, you can set these when you define your flow or task using the
default
argument. Each time the flow or task is run, it will use these default parameters unless you specify otherwise. I hope that helps. Or at least, I hope it doesn't make things worse.
n

Nate

08/29/2023, 6:58 PM
unfortunately, there's not a great way to re-use the same deployment with different default parameters - you'd have to create a new deployment with diff params iirc in prefect 1 you could associate params with a schedule itself, and then those params would be used when that schedule was responsible for kicking off a flow - is that sort of what you're looking for?
m

Mitch

08/29/2023, 6:59 PM
Exactly
Copy code
schedule = Schedule(
            clocks = [
                CronClock("35 15 * * 1-5", # m, h, day_of_month, month, day_of_week
                    start_date = pendulum.now('America/Chicago'),
                    parameter_defaults = param1
                         ),
                CronClock("40 15 * * 1-5", # m, h, day_of_month, month, day_of_week
                    start_date = pendulum.now('America/Chicago'),
                    parameter_defaults = param2
                         ),
                CronClock("45 15 * * 1-5", # m, h, day_of_month, month, day_of_week
                    start_date = pendulum.now('America/Chicago'),
                    parameter_defaults = param3
                         ),
                CronClock("55 15 * * 1-5", # m, h, day_of_month, month, day_of_week
                    start_date = pendulum.now('America/Chicago'),
                    parameter_defaults = param4
                         ),
            ]
          ),
Really not a huge issue, just will name them differently
I can't think of the error now, but I think I have gotten an error where it says there are two deployments with the same entrypoint (?) and it doesn't allow for deployment
n

Nate

08/29/2023, 7:01 PM
thanks for the feedback though! can totally see how thatd be useful (will raise this feedback) you should definitely be able to create multiple deployments with the same entrypoint (i.e. flow) - feel free to post that error here if you hit it again
m

Mitch

08/29/2023, 7:01 PM
Will do. Thanks @Nate!
👍 1