https://prefect.io logo
m

mithalee mohapatra

12/16/2020, 3:27 AM
if name == '__main__':     schedule = Schedule(clocks=[IntervalClock(start_date=pendulum.datetime(2020, 12, 16,hour=2,minute=14,second=0),interval=timedelta(minutes=2))]) #schedule.next(5) with Flow("Hello", schedule) as flow:     say_hello() executor=LocalDaskExecutor(scheduler="processes", num_workers=6) flow.run(executor=executor) I am trying to run LocalDaskExecutor with prefect schedule but getting the below error. Just Flow.run() works fine with schedule though. with Flow("Hello", schedule) as flow: NameError: name 'schedule' is not defined
c

Chris White

12/16/2020, 6:01 AM
Hi @mithalee mohapatra - please use triple backticks to format your code so we can better interpret the indentation levels; this appears to be a python issue, not a Prefect one — you need to ensure that you assign the
schedule
variable within the same scope as when you define your flow
m

mithalee mohapatra

12/16/2020, 7:00 AM
Thanks Chris. I fixed the scope. But now when I run my flow with LocalDaskexecutor and schedule ,my tasks are not running.Here is my code:@task def say_hello():     print("Hello, world!")     logger = prefect.context.get("logger")     logger.info("Hello, world!")  schedule = Schedule(clocks=[IntervalClock(start_date=pendulum.datetime(2020, 12, 16,hour=2,minute=14,second=0),interval=timedelta(minutes=2))]) with Flow("Hello",schedule) as flow:     say_hello() executor=LocalDaskExecutor(scheduler="processes", num_workers=6) flow.run(executor=executor)
The LocalDaskExecutor() works fine without the schedule.
I am wondering if the LocalDaskExecutor will work with the prefect Schedule? The DastExecutor is working fine the Schedule.
Thanks.working for me now.
2 Views