Hi. Does RRuleSchedule support something like? I w...
# prefect-community
Hi. Does RRuleSchedule support something like? I was able to deploy the flow, but don't see any scheduled flow runs.
Copy code
UI says: 'Every year' schedule:
hi Vadym, check out the docs here. The example provided is this
Copy code
  rrule: 'FREQ=WEEKLY;BYDAY=MO,WE,FR;UNTIL=20240730T040000Z'
Could you clarify what you are trying to do with the rrule schedule?
Sure. I used DatesClock to run flows using custom calendar and now I am looking for the solution in Prefect 2.
Ahh okay, I don't believe rrule would be appropriate for that use case. Rrule uses recurring calendar logic- for example- the first Tuesday of every month. Let me follow up on this. I'll try to find if there is a similar datesclock or custom solution that exists
Thanks a lot! I was trying to implement custom schedule, but pydantic validation does not allow custom model fields.
Copy code
class CalendarSchedule(PrefectBaseModel):

    run_times: list[pendulum.Time]
    calendar_id: str

    async def get_dates(
        n: int = None,
        start: datetime.datetime = None,
        end: datetime.datetime = None,
    ) -> list[pendulum.DateTime]:
        calendar = Calendar(self.calendar_id)

        dates = calendar.business_days(
            start=pendulum.Date(2020, 1, 1),
            end=pendulum.Date(2025, 1, 1),
        return [
            pendulum.instance(pendulum.DateTime.combine(date, time))
            for date in dates
            for time in self.run_times
👍 1
validation fails for schedule field in Deployment and then DeploymentCreate models
@James Sopkin Should I wait for the idea from your side or should I try to find another solution? Thanks
Hi Vadym, I did reach out to my team to ask about a dates or calendar schedule but have not hear back yet. I imagine there's an alternative solution like using lambda to trigger Prefect flows with ad-hoc scheduling, but I'd like to find out if there's a simpler solution that already exists or is in the works
Go ahead and try other ideas if you think of them
@Vadym Dytyniak a bit late but here is how you could schedule runs for a given date https://gist.github.com/32a0561dd3b115efebe3360574645cad
@Anna Geller looks interesting, but what about duplicates if I run the same code 2 times?
if you run it twice, it would schedule 2 runs for the same date and tbh this is a fully expected behavior
But each new deployment is new deployment_id or it depends on the version?
and what happens with old scheduled runs if you deploy new version?
#1 creating runs is independent of each other and is based on deployment ID, correct #2 scheduled runs for the old deployment are deleted and new runs are created for the new deployment
I'd encourage you to just give it a try and see how this works in practice, and if something doesn't work as you would expect, you can open a GitHub issue
🙌 1