-1

My program always runs on startup instead of the scheduled time, maybe i'm just misunderstanding something but I can't say why it's doing this.

from prefect import flow, task, get_run_logger
from prefect.deployments import Deployment
from prefect.orion.schemas.schedules import (
   CronSchedule,
   IntervalSchedule,
   RRuleSchedule,
)

@task(retries=2, retry_delay_seconds=5)
def say_hello():
    print("hello")
    return True

@flow(name="leonardo_dicapriflow")
def leonardo_dicapriflow(name: str):
    say_hello()
    return 

deployment = Deployment.build_from_flow(
   flow=leonardo_dicapriflow,
   name="email-deployment",
   version=1,
   tags=["demo"],
   schedule=CronSchedule(cron=("55 11 3 10 *") )
)
deployment.apply()

leonardo_dicapriflow("Leo") 

Photo of my error screen

enter image description here

1 Answers1

1

So remove the last line of the code and it will be fine

leonardo_dicapriflow("Leo")

apparrently it was running twice, one of them happened to be on start up.

  • Great that you figured it out that this last line calls a function and must be removed for a scheduled deployment – Anna Geller Sep 04 '22 at 07:50