Adding schedules to flow.to_deployment() raises an error because code is checking for schedule object length, although they have none. Example is for CronSchedule but issue also occurs with IntervalSchedule (and I assume RRuleSchedule, though not tested)
from prefect import flow, serve
from prefect.client.schemas.schedules import CronSchedule
@flow
def sample_flow(input: str) -> str:
print(f"Input is: {input}")
if __name__ == "__main__":
default_deploy = sample_flow.to_deployment(
name="sample_deployment",
schedules=CronSchedule(
cron="0 19 * * 1-5",
timezone="US/Eastern",
day_or=True),
parameters={"input": "hello world!"},
)
serve(default_deploy)
Error message:
File "C:\Users\USER\Desktop\local-folder\venv\Lib\site-packages\prefect\deployments\runner.py", line 230, in reconcile_schedules
return reconcile_schedules_runner(values)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\USER\Desktop\local-folder\venv\Lib\site-packages\prefect\_internal\schemas\validators.py", line 226, in reconcile_schedules_runner
if schedules is not None and len(schedules) > 0:
^^^^^^^^^^^^^^
TypeError: object of type 'CronSchedule' has no len()
Version info (prefect version output)
Version: 3.0.2
API version: 0.8.4
Python version: 3.11.0
Git commit: c846de02
Built: Fri, Sep 13, 2024 10:48 AM
OS/Arch: win32/AMD64
Profile: default
Server type: cloud
Pydantic version: 2.9.1
Bug summary
Adding schedules to
flow.to_deployment()
raises an error because code is checking for schedule object length, although they have none. Example is forCronSchedule
but issue also occurs withIntervalSchedule
(and I assumeRRuleSchedule
, though not tested)Error message:
Version info (
prefect version
output)Additional context
No response