@@ -40,9 +40,8 @@ client = Client()
4040automations = client.automations()
4141cron_automation = automations.create_cron_automation(
4242 " my-cron-automation" , # name of the cron automation
43- " dev-cluster" , # cluster slug to submit jobs to
4443 MyCronTask(message = " World" ), # the task (and its input parameters) to run repeatedly
45- cron_triggers = [
44+ cron_schedules = [
4645 " 12 * * * *" , # run every hour at minute 12
4746 " 45 18 * * *" , # run every day at 18:45
4847 " 30 13 * * 3" , # run every Wednesday at 13:30
@@ -64,8 +63,8 @@ Once an [eligible task runner](/workflows/concepts/task-runners#task-selection)
6463from tilebox.workflows import Client
6564
6665client = Client()
67- runner = client.runner(" dev-cluster " , tasks = [MyCronTask])
68- runner.run_forever ()
66+ runner = client.runner(tasks = [MyCronTask])
67+ runner.run_all ()
6968```
7069
7170If this task runner runs continuously, its output may resemble the following:
@@ -128,16 +127,15 @@ job_client = client.jobs()
128127task = MyCronTask(message = " Hello" )
129128
130129# submitting it directly won't work: raises ValueError:
131- # CronTask cannot be submitted without being triggered. Use task.once().
132- job_client.submit(" manual-cron-job" , task, cluster = " dev-cluster" )
133-
134- # specify a trigger time to submit the task as a regular task
135- triggered_task = task.once() # same as task.once(datetime.now())
136- job_client.submit(" manual-cron-job" , triggered_task, cluster = " dev-cluster" )
137-
138- # simulate a trigger at a specific time
139- triggered_task = task.once(datetime(2030 , 12 , 12 , 15 , 15 , tzinfo = timezone.utc))
140- # the task will be scheduled to run immediately, even with a future trigger time
141- # but the self.trigger.time will be 2023-12-12T15:15:00Z for the task instance
142- job_client.submit(" manual-cron-job" , triggered_task, cluster = " dev-cluster" )
130+ # job_client.submit("manual-cron-job", task)
131+
132+ # instead trigger a cron task with the current time as the trigger time
133+ job_client.submit(" manual-cron-job" , task.once())
134+
135+ # or specify a trigger time in the past or future
136+ # irrespective of the trigger time, the task will always be scheduled to run immediately
137+ job_client.submit(
138+ " manual-cron-job" ,
139+ task.once(datetime(2030 , 12 , 12 , 15 , 15 , tzinfo = timezone.utc))
140+ )
143141```
0 commit comments