Bruno Murino
07/06/2021, 8:45 AMflow.schedule = get_schedule()
import datetime
from datetime import datetime, timedelta
from prefect.schedules import clocks, Schedule
def get_schedule():
now = datetime.utcnow()
clock1 = clocks.IntervalClock(
interval=timedelta(minutes=10),
parameter_defaults={
"scope": "full",
},
)
my_schedule = Schedule(
clocks=[
clock1,
]
)
return my_schedule
Stéphan Taljaard
07/06/2021, 9:28 AMBruno Murino
07/06/2021, 9:28 AMSimon Gasse
07/06/2021, 9:45 AMKevin Kho
07/06/2021, 10:50 AMSimon Gasse
07/06/2021, 11:04 AMscheduled_hello.py
and ran python scheduled_hello.py
on the machine where the server is running.
from datetime import timedelta
from prefect import task, Flow
from prefect.schedules import IntervalSchedule
@task
def say_hello():
print("Hello, world!")
schedule = IntervalSchedule(interval=timedelta(minutes=2))
with Flow("Scheduled Hello", schedule) as flow:
say_hello()
flow.register(project_name='example',
labels=['local'],
idempotency_key=flow.serialized_hash())
prefect register
instead?
Edit: I tried with prefect register
but it does not make a difference 🤔Kevin Kho
07/06/2021, 11:16 AMflow.schedule = schedule
after the flow definition and before the flow.register()
?Bruno Murino
07/06/2021, 11:21 AMif os.environ["EXECUTOR"] == "aws" and os.environ["ENV"] == "prod":
flow.schedule = get_schedule()
Kevin Kho
07/06/2021, 11:24 AMif
block first? What do you see when you to go to the Flow Settings and click Schedule?Bruno Murino
07/06/2021, 11:29 AMSimon Gasse
07/06/2021, 11:30 AMschedule = IntervalSchedule(interval=timedelta(minutes=2))
with Flow("Scheduled Hello") as flow:
say_hello()
flow.schedule = schedule
flow.register(project_name='example',
labels=['local'],
idempotency_key=flow.serialized_hash())
unfortunately does not make a difference on my setupprefect server
not go through the attached schedules to figure out what to run next?Kevin Kho
07/06/2021, 11:32 AMBruno Murino
07/06/2021, 11:35 AMKevin Kho
07/06/2021, 11:39 AMSimon Gasse
07/06/2021, 12:10 PM$ pip show prefect
Name: prefect
Version: 0.15.0
Kevin Kho
07/06/2021, 6:26 PMBruno Murino
07/06/2021, 11:14 PMKevin Kho
07/07/2021, 12:49 AMSimon Gasse
07/07/2021, 6:56 AMsha256
in the `docker-compose.yml`:
image: prefecthq/apollo@sha256:65ca4f0a4a667fd48360a5c00b4670a796dbc43f2e3a1a0e40ad8b40e1e5cd7f
...
image: prefecthq/server@sha256:0490b527756a53bd3c80513cf09d8c51fdf002c7991524898f62fdd43a31a343
Bruno Murino
07/07/2021, 8:35 AMAdam
07/08/2021, 11:18 AMschedule = IntervalSchedule(interval=timedelta(minutes=2))
with Flow("Scheduled Hello", schedule) as flow:
say_hello()
We normally do:
schedule = IntervalSchedule(interval=timedelta(minutes=2))
with Flow("Scheduled Hello", schedule=schedule) as flow:
say_hello()
Bruno Murino
07/08/2021, 11:44 AM