Skip to content

Commit 00260e9

Browse files
committed
feat: add restart_on_error option to actor start and call and to task in general
1 parent 64a0a1e commit 00260e9

File tree

4 files changed

+54
-4
lines changed

4 files changed

+54
-4
lines changed

src/apify_client/clients/resource_clients/actor.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def update(
153153
seo_title: The title of the Actor optimized for search engines.
154154
seo_description: The description of the Actor optimized for search engines.
155155
versions: The list of Actor versions.
156-
restart_on_error: If true, the main Actor run process will be restarted whenever it exits with
156+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
157157
a non-zero status code.
158158
is_public: Whether the Actor is public.
159159
is_deprecated: Whether the Actor is deprecated.
@@ -224,6 +224,7 @@ def start(
224224
build: str | None = None,
225225
max_items: int | None = None,
226226
max_total_charge_usd: Decimal | None = None,
227+
restart_on_error: bool | None = None,
227228
memory_mbytes: int | None = None,
228229
timeout_secs: int | None = None,
229230
force_permission_level: ActorPermissionLevel | None = None,
@@ -242,6 +243,8 @@ def start(
242243
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
243244
per result, you will not be charged for more results than the given limit.
244245
max_total_charge_usd: A limit on the total charged amount for pay-per-event actors.
246+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
247+
a non-zero status code.
245248
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit
246249
specified in the default run configuration for the Actor.
247250
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
@@ -267,6 +270,7 @@ def start(
267270
build=build,
268271
maxItems=max_items,
269272
maxTotalChargeUsd=max_total_charge_usd,
273+
restartOnError=restart_on_error,
270274
memory=memory_mbytes,
271275
timeout=timeout_secs,
272276
waitForFinish=wait_for_finish,
@@ -292,6 +296,7 @@ def call(
292296
build: str | None = None,
293297
max_items: int | None = None,
294298
max_total_charge_usd: Decimal | None = None,
299+
restart_on_error: bool | None = None,
295300
memory_mbytes: int | None = None,
296301
timeout_secs: int | None = None,
297302
webhooks: list[dict] | None = None,
@@ -313,6 +318,8 @@ def call(
313318
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
314319
per result, you will not be charged for more results than the given limit.
315320
max_total_charge_usd: A limit on the total charged amount for pay-per-event actors.
321+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
322+
a non-zero status code.
316323
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit
317324
specified in the default run configuration for the Actor.
318325
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
@@ -338,6 +345,7 @@ def call(
338345
build=build,
339346
max_items=max_items,
340347
max_total_charge_usd=max_total_charge_usd,
348+
restart_on_error=restart_on_error,
341349
memory_mbytes=memory_mbytes,
342350
timeout_secs=timeout_secs,
343351
webhooks=webhooks,
@@ -565,7 +573,7 @@ async def update(
565573
seo_title: The title of the Actor optimized for search engines.
566574
seo_description: The description of the Actor optimized for search engines.
567575
versions: The list of Actor versions.
568-
restart_on_error: If true, the main Actor run process will be restarted whenever it exits with
576+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
569577
a non-zero status code.
570578
is_public: Whether the Actor is public.
571579
is_deprecated: Whether the Actor is deprecated.
@@ -636,6 +644,7 @@ async def start(
636644
build: str | None = None,
637645
max_items: int | None = None,
638646
max_total_charge_usd: Decimal | None = None,
647+
restart_on_error: bool | None = None,
639648
memory_mbytes: int | None = None,
640649
timeout_secs: int | None = None,
641650
force_permission_level: ActorPermissionLevel | None = None,
@@ -654,6 +663,8 @@ async def start(
654663
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
655664
per result, you will not be charged for more results than the given limit.
656665
max_total_charge_usd: A limit on the total charged amount for pay-per-event actors.
666+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
667+
a non-zero status code.
657668
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit
658669
specified in the default run configuration for the Actor.
659670
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
@@ -679,6 +690,7 @@ async def start(
679690
build=build,
680691
maxItems=max_items,
681692
maxTotalChargeUsd=max_total_charge_usd,
693+
restartOnError=restart_on_error,
682694
memory=memory_mbytes,
683695
timeout=timeout_secs,
684696
waitForFinish=wait_for_finish,
@@ -704,6 +716,7 @@ async def call(
704716
build: str | None = None,
705717
max_items: int | None = None,
706718
max_total_charge_usd: Decimal | None = None,
719+
restart_on_error: bool | None = None,
707720
memory_mbytes: int | None = None,
708721
timeout_secs: int | None = None,
709722
webhooks: list[dict] | None = None,
@@ -725,6 +738,8 @@ async def call(
725738
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
726739
per result, you will not be charged for more results than the given limit.
727740
max_total_charge_usd: A limit on the total charged amount for pay-per-event actors.
741+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
742+
a non-zero status code.
728743
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit
729744
specified in the default run configuration for the Actor.
730745
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
@@ -750,6 +765,7 @@ async def call(
750765
build=build,
751766
max_items=max_items,
752767
max_total_charge_usd=max_total_charge_usd,
768+
restart_on_error=restart_on_error,
753769
memory_mbytes=memory_mbytes,
754770
timeout_secs=timeout_secs,
755771
webhooks=webhooks,

src/apify_client/clients/resource_clients/actor_collection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def create(
8080
seo_title: The title of the Actor optimized for search engines.
8181
seo_description: The description of the Actor optimized for search engines.
8282
versions: The list of Actor versions.
83-
restart_on_error: If true, the main Actor run process will be restarted whenever it exits with
83+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
8484
a non-zero status code.
8585
is_public: Whether the Actor is public.
8686
is_deprecated: Whether the Actor is deprecated.
@@ -205,7 +205,7 @@ async def create(
205205
seo_title: The title of the Actor optimized for search engines.
206206
seo_description: The description of the Actor optimized for search engines.
207207
versions: The list of Actor versions.
208-
restart_on_error: If true, the main Actor run process will be restarted whenever it exits with
208+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
209209
a non-zero status code.
210210
is_public: Whether the Actor is public.
211211
is_deprecated: Whether the Actor is deprecated.

src/apify_client/clients/resource_clients/task.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def get_task_representation(
3232
max_items: int | None = None,
3333
memory_mbytes: int | None = None,
3434
timeout_secs: int | None = None,
35+
restart_on_error: bool | None = None,
3536
title: str | None = None,
3637
actor_standby_desired_requests_per_actor_run: int | None = None,
3738
actor_standby_max_requests_per_actor_run: int | None = None,
@@ -48,6 +49,7 @@ def get_task_representation(
4849
'maxItems': max_items,
4950
'memoryMbytes': memory_mbytes,
5051
'timeoutSecs': timeout_secs,
52+
'restartOnError': restart_on_error,
5153
},
5254
'input': task_input,
5355
'title': title,
@@ -87,6 +89,7 @@ def update(
8789
max_items: int | None = None,
8890
memory_mbytes: int | None = None,
8991
timeout_secs: int | None = None,
92+
restart_on_error: bool | None = None,
9093
title: str | None = None,
9194
actor_standby_desired_requests_per_actor_run: int | None = None,
9295
actor_standby_max_requests_per_actor_run: int | None = None,
@@ -109,6 +112,8 @@ def update(
109112
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
110113
in the task settings.
111114
task_input: Task input dictionary.
115+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
116+
a non-zero status code.
112117
title: A human-friendly equivalent of the name.
113118
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
114119
a single Actor Standby run.
@@ -129,6 +134,7 @@ def update(
129134
max_items=max_items,
130135
memory_mbytes=memory_mbytes,
131136
timeout_secs=timeout_secs,
137+
restart_on_error=restart_on_error,
132138
title=title,
133139
actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
134140
actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
@@ -154,6 +160,7 @@ def start(
154160
max_items: int | None = None,
155161
memory_mbytes: int | None = None,
156162
timeout_secs: int | None = None,
163+
restart_on_error: bool | None = None,
157164
wait_for_finish: int | None = None,
158165
webhooks: list[dict] | None = None,
159166
) -> dict:
@@ -171,6 +178,8 @@ def start(
171178
in the task settings.
172179
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
173180
in the task settings.
181+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
182+
a non-zero status code.
174183
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
175184
it is 0, the maximum value is 60.
176185
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
@@ -189,6 +198,7 @@ def start(
189198
maxItems=max_items,
190199
memory=memory_mbytes,
191200
timeout=timeout_secs,
201+
restartOnError=restart_on_error,
192202
waitForFinish=wait_for_finish,
193203
webhooks=encode_webhook_list_to_base64(webhooks) if webhooks is not None else None,
194204
)
@@ -211,6 +221,7 @@ def call(
211221
max_items: int | None = None,
212222
memory_mbytes: int | None = None,
213223
timeout_secs: int | None = None,
224+
restart_on_error: bool | None = None,
214225
webhooks: list[dict] | None = None,
215226
wait_secs: int | None = None,
216227
) -> dict | None:
@@ -230,6 +241,8 @@ def call(
230241
in the task settings.
231242
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
232243
in the task settings.
244+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
245+
a non-zero status code.
233246
webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive
234247
a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for
235248
the Actor or task, you do not have to add it again here.
@@ -245,6 +258,7 @@ def call(
245258
max_items=max_items,
246259
memory_mbytes=memory_mbytes,
247260
timeout_secs=timeout_secs,
261+
restart_on_error=restart_on_error,
248262
webhooks=webhooks,
249263
)
250264

@@ -343,6 +357,7 @@ async def update(
343357
max_items: int | None = None,
344358
memory_mbytes: int | None = None,
345359
timeout_secs: int | None = None,
360+
restart_on_error: bool | None = None,
346361
title: str | None = None,
347362
actor_standby_desired_requests_per_actor_run: int | None = None,
348363
actor_standby_max_requests_per_actor_run: int | None = None,
@@ -364,6 +379,8 @@ async def update(
364379
in the task settings.
365380
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
366381
in the task settings.
382+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
383+
a non-zero status code.
367384
task_input: Task input dictionary.
368385
title: A human-friendly equivalent of the name.
369386
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
@@ -385,6 +402,7 @@ async def update(
385402
max_items=max_items,
386403
memory_mbytes=memory_mbytes,
387404
timeout_secs=timeout_secs,
405+
restart_on_error=restart_on_error,
388406
title=title,
389407
actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
390408
actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
@@ -410,6 +428,7 @@ async def start(
410428
max_items: int | None = None,
411429
memory_mbytes: int | None = None,
412430
timeout_secs: int | None = None,
431+
restart_on_error: bool | None = None,
413432
wait_for_finish: int | None = None,
414433
webhooks: list[dict] | None = None,
415434
) -> dict:
@@ -427,6 +446,8 @@ async def start(
427446
in the task settings.
428447
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
429448
in the task settings.
449+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
450+
a non-zero status code.
430451
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
431452
it is 0, the maximum value is 60.
432453
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
@@ -445,6 +466,7 @@ async def start(
445466
maxItems=max_items,
446467
memory=memory_mbytes,
447468
timeout=timeout_secs,
469+
restartOnError=restart_on_error,
448470
waitForFinish=wait_for_finish,
449471
webhooks=encode_webhook_list_to_base64(webhooks) if webhooks is not None else None,
450472
)
@@ -467,6 +489,7 @@ async def call(
467489
max_items: int | None = None,
468490
memory_mbytes: int | None = None,
469491
timeout_secs: int | None = None,
492+
restart_on_error: bool | None = None,
470493
webhooks: list[dict] | None = None,
471494
wait_secs: int | None = None,
472495
) -> dict | None:
@@ -486,6 +509,8 @@ async def call(
486509
in the task settings.
487510
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
488511
in the task settings.
512+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
513+
a non-zero status code.
489514
webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive
490515
a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for
491516
the Actor or task, you do not have to add it again here.
@@ -501,6 +526,7 @@ async def call(
501526
max_items=max_items,
502527
memory_mbytes=memory_mbytes,
503528
timeout_secs=timeout_secs,
529+
restart_on_error=restart_on_error,
504530
webhooks=webhooks,
505531
)
506532

src/apify_client/clients/resource_clients/task_collection.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def create(
4747
timeout_secs: int | None = None,
4848
memory_mbytes: int | None = None,
4949
max_items: int | None = None,
50+
restart_on_error: bool | None = None,
5051
task_input: dict | None = None,
5152
title: str | None = None,
5253
actor_standby_desired_requests_per_actor_run: int | None = None,
@@ -70,6 +71,8 @@ def create(
7071
is charged per result, you will not be charged for more results than the given limit.
7172
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
7273
in the task settings.
74+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
75+
a non-zero status code.
7376
task_input: Task input object.
7477
title: A human-friendly equivalent of the name.
7578
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
@@ -92,6 +95,7 @@ def create(
9295
max_items=max_items,
9396
memory_mbytes=memory_mbytes,
9497
timeout_secs=timeout_secs,
98+
restart_on_error=restart_on_error,
9599
title=title,
96100
actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
97101
actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
@@ -140,6 +144,7 @@ async def create(
140144
timeout_secs: int | None = None,
141145
memory_mbytes: int | None = None,
142146
max_items: int | None = None,
147+
restart_on_error: bool | None = None,
143148
task_input: dict | None = None,
144149
title: str | None = None,
145150
actor_standby_desired_requests_per_actor_run: int | None = None,
@@ -163,6 +168,8 @@ async def create(
163168
is charged per result, you will not be charged for more results than the given limit.
164169
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
165170
in the task settings.
171+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
172+
a non-zero status code.
166173
task_input: Task input object.
167174
title: A human-friendly equivalent of the name.
168175
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
@@ -185,6 +192,7 @@ async def create(
185192
max_items=max_items,
186193
memory_mbytes=memory_mbytes,
187194
timeout_secs=timeout_secs,
195+
restart_on_error=restart_on_error,
188196
title=title,
189197
actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
190198
actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,

0 commit comments

Comments
 (0)