Skip to content

Commit 70776d9

Browse files
Fix automation docs (#68)
1 parent 702a66b commit 70776d9

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

workflows/near-real-time/cron.mdx

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,8 @@ client = Client()
4040
automations = client.automations()
4141
cron_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)
6463
from tilebox.workflows import Client
6564

6665
client = 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

7170
If this task runner runs continuously, its output may resemble the following:
@@ -128,16 +127,15 @@ job_client = client.jobs()
128127
task = 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
```

workflows/near-real-time/storage-events.mdx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ client = Client()
120120
automations = client.automations()
121121
storage_event_automation = automations.create_storage_event_automation(
122122
"log-object-creations", # name of the storage event automation
123-
"dev-cluster", # cluster slug to submit jobs to
124123
LogObjectCreation(head_bytes=20), # the task (and its input parameters) to run repeatedly
125124
triggers=[
126125
# you can specify a glob pattern:
@@ -155,7 +154,7 @@ Once an [eligible task runner](/workflows/concepts/task-runners#task-selection)
155154
from tilebox.workflows import Client
156155

157156
client = Client()
158-
runner = client.runner("dev-cluster", tasks=[LogObjectCreation])
157+
runner = client.runner(tasks=[LogObjectCreation])
159158
runner.run_forever()
160159
```
161160

@@ -212,19 +211,12 @@ job_client = client.jobs()
212211
task = LogObjectCreation(head_bytes=20)
213212

214213
# submitting it directly won't work; raises ValueError:
215-
# StorageEventTask cannot be submitted without being triggered. Use task.once().
216-
job_client.submit(
217-
"manual-storage-event-job",
218-
task,
219-
cluster="dev-cluster"
220-
)
214+
# job_client.submit("manual-storage-event-job", task)
221215

222-
# instead, specify a trigger,
223-
# so that we can submit the task as a regular task
224-
triggered_task = task.once(gcs_bucket, "my-object.txt")
216+
# instead, we specify a trigger condition, and submit a job manually
225217
job_client.submit(
226218
"manual-storage-event-job",
227-
triggered_task,
228-
cluster="dev-cluster"
219+
# simulate an event that occurred in the gcs bucket for the object "my-object.txt"
220+
task.once(gcs_bucket, "my-object.txt"),
229221
)
230222
```

0 commit comments

Comments
 (0)