Skip to content

Commit 8f73420

Browse files
authored
fix: move restart on error Actor option to Run options (#508)
1 parent 993c905 commit 8f73420

File tree

5 files changed

+64
-5
lines changed

5 files changed

+64
-5
lines changed

src/apify_client/clients/resource_clients/actor.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def get_actor_representation(
6969
'seoTitle': seo_title,
7070
'seoDescription': seo_description,
7171
'versions': versions,
72-
'restartOnError': restart_on_error,
7372
'isPublic': is_public,
7473
'isDeprecated': is_deprecated,
7574
'isAnonymouslyRunnable': is_anonymously_runnable,
@@ -79,6 +78,7 @@ def get_actor_representation(
7978
'maxItems': default_run_max_items,
8079
'memoryMbytes': default_run_memory_mbytes,
8180
'timeoutSecs': default_run_timeout_secs,
81+
'restartOnError': restart_on_error,
8282
'forcePermissionLevel': default_run_force_permission_level,
8383
},
8484
'exampleRunInput': {
@@ -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/run.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ def resurrect(
162162
timeout_secs: int | None = None,
163163
max_items: int | None = None,
164164
max_total_charge_usd: Decimal | None = None,
165+
restart_on_error: bool | None = None,
165166
) -> dict:
166167
"""Resurrect a finished Actor run.
167168
@@ -181,6 +182,8 @@ def resurrect(
181182
resurrected run uses the same limit as before. Limit can be only increased.
182183
max_total_charge_usd: Maximum cost for the resurrected pay-per-event run in USD. By default, the
183184
resurrected run uses the same limit as before. Limit can be only increased.
185+
restart_on_error: Determines whether the resurrected run will be restarted if it fails.
186+
By default, the resurrected run uses the same setting as before.
184187
185188
Returns:
186189
The Actor run data.
@@ -191,6 +194,7 @@ def resurrect(
191194
timeout=timeout_secs,
192195
maxItems=max_items,
193196
maxTotalChargeUsd=max_total_charge_usd,
197+
restartOnError=restart_on_error,
194198
)
195199

196200
response = self.http_client.call(
@@ -483,6 +487,7 @@ async def resurrect(
483487
timeout_secs: int | None = None,
484488
max_items: int | None = None,
485489
max_total_charge_usd: Decimal | None = None,
490+
restart_on_error: bool | None = None,
486491
) -> dict:
487492
"""Resurrect a finished Actor run.
488493
@@ -502,6 +507,8 @@ async def resurrect(
502507
resurrected run uses the same limit as before. Limit can be only increased.
503508
max_total_charge_usd: Maximum cost for the resurrected pay-per-event run in USD. By default, the
504509
resurrected run uses the same limit as before. Limit can be only increased.
510+
restart_on_error: Determines whether the resurrected run will be restarted if it fails.
511+
By default, the resurrected run uses the same setting as before.
505512
506513
Returns:
507514
The Actor run data.
@@ -512,6 +519,7 @@ async def resurrect(
512519
timeout=timeout_secs,
513520
maxItems=max_items,
514521
maxTotalChargeUsd=max_total_charge_usd,
522+
restartOnError=restart_on_error,
515523
)
516524

517525
response = await self.http_client.call(

src/apify_client/clients/resource_clients/task.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ def get_task_representation(
3838
actor_standby_idle_timeout_secs: int | None = None,
3939
actor_standby_build: str | None = None,
4040
actor_standby_memory_mbytes: int | None = None,
41+
*,
42+
restart_on_error: bool | None = None,
4143
) -> dict:
4244
"""Get the dictionary representation of a task."""
4345
return {
@@ -48,6 +50,7 @@ def get_task_representation(
4850
'maxItems': max_items,
4951
'memoryMbytes': memory_mbytes,
5052
'timeoutSecs': timeout_secs,
53+
'restartOnError': restart_on_error,
5154
},
5255
'input': task_input,
5356
'title': title,
@@ -87,6 +90,7 @@ def update(
8790
max_items: int | None = None,
8891
memory_mbytes: int | None = None,
8992
timeout_secs: int | None = None,
93+
restart_on_error: bool | None = None,
9094
title: str | None = None,
9195
actor_standby_desired_requests_per_actor_run: int | None = None,
9296
actor_standby_max_requests_per_actor_run: int | None = None,
@@ -108,6 +112,8 @@ def update(
108112
in the task settings.
109113
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
110114
in the task settings.
115+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
116+
a non-zero status code.
111117
task_input: Task input dictionary.
112118
title: A human-friendly equivalent of the name.
113119
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
@@ -129,6 +135,7 @@ def update(
129135
max_items=max_items,
130136
memory_mbytes=memory_mbytes,
131137
timeout_secs=timeout_secs,
138+
restart_on_error=restart_on_error,
132139
title=title,
133140
actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
134141
actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
@@ -154,6 +161,7 @@ def start(
154161
max_items: int | None = None,
155162
memory_mbytes: int | None = None,
156163
timeout_secs: int | None = None,
164+
restart_on_error: bool | None = None,
157165
wait_for_finish: int | None = None,
158166
webhooks: list[dict] | None = None,
159167
) -> dict:
@@ -171,6 +179,8 @@ def start(
171179
in the task settings.
172180
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
173181
in the task settings.
182+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
183+
a non-zero status code.
174184
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
175185
it is 0, the maximum value is 60.
176186
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
@@ -189,6 +199,7 @@ def start(
189199
maxItems=max_items,
190200
memory=memory_mbytes,
191201
timeout=timeout_secs,
202+
restartOnError=restart_on_error,
192203
waitForFinish=wait_for_finish,
193204
webhooks=encode_webhook_list_to_base64(webhooks) if webhooks is not None else None,
194205
)
@@ -211,6 +222,7 @@ def call(
211222
max_items: int | None = None,
212223
memory_mbytes: int | None = None,
213224
timeout_secs: int | None = None,
225+
restart_on_error: bool | None = None,
214226
webhooks: list[dict] | None = None,
215227
wait_secs: int | None = None,
216228
) -> dict | None:
@@ -230,6 +242,8 @@ def call(
230242
in the task settings.
231243
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
232244
in the task settings.
245+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
246+
a non-zero status code.
233247
webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive
234248
a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for
235249
the Actor or task, you do not have to add it again here.
@@ -245,6 +259,7 @@ def call(
245259
max_items=max_items,
246260
memory_mbytes=memory_mbytes,
247261
timeout_secs=timeout_secs,
262+
restart_on_error=restart_on_error,
248263
webhooks=webhooks,
249264
)
250265

@@ -343,6 +358,7 @@ async def update(
343358
max_items: int | None = None,
344359
memory_mbytes: int | None = None,
345360
timeout_secs: int | None = None,
361+
restart_on_error: bool | None = None,
346362
title: str | None = None,
347363
actor_standby_desired_requests_per_actor_run: int | None = None,
348364
actor_standby_max_requests_per_actor_run: int | None = None,
@@ -364,6 +380,8 @@ async def update(
364380
in the task settings.
365381
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
366382
in the task settings.
383+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
384+
a non-zero status code.
367385
task_input: Task input dictionary.
368386
title: A human-friendly equivalent of the name.
369387
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
@@ -385,6 +403,7 @@ async def update(
385403
max_items=max_items,
386404
memory_mbytes=memory_mbytes,
387405
timeout_secs=timeout_secs,
406+
restart_on_error=restart_on_error,
388407
title=title,
389408
actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
390409
actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
@@ -410,6 +429,7 @@ async def start(
410429
max_items: int | None = None,
411430
memory_mbytes: int | None = None,
412431
timeout_secs: int | None = None,
432+
restart_on_error: bool | None = None,
413433
wait_for_finish: int | None = None,
414434
webhooks: list[dict] | None = None,
415435
) -> dict:
@@ -427,6 +447,8 @@ async def start(
427447
in the task settings.
428448
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
429449
in the task settings.
450+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
451+
a non-zero status code.
430452
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
431453
it is 0, the maximum value is 60.
432454
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
@@ -445,6 +467,7 @@ async def start(
445467
maxItems=max_items,
446468
memory=memory_mbytes,
447469
timeout=timeout_secs,
470+
restartOnError=restart_on_error,
448471
waitForFinish=wait_for_finish,
449472
webhooks=encode_webhook_list_to_base64(webhooks) if webhooks is not None else None,
450473
)
@@ -467,6 +490,7 @@ async def call(
467490
max_items: int | None = None,
468491
memory_mbytes: int | None = None,
469492
timeout_secs: int | None = None,
493+
restart_on_error: bool | None = None,
470494
webhooks: list[dict] | None = None,
471495
wait_secs: int | None = None,
472496
) -> dict | None:
@@ -486,6 +510,8 @@ async def call(
486510
in the task settings.
487511
timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified
488512
in the task settings.
513+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
514+
a non-zero status code.
489515
webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive
490516
a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for
491517
the Actor or task, you do not have to add it again here.
@@ -501,6 +527,7 @@ async def call(
501527
max_items=max_items,
502528
memory_mbytes=memory_mbytes,
503529
timeout_secs=timeout_secs,
530+
restart_on_error=restart_on_error,
504531
webhooks=webhooks,
505532
)
506533

0 commit comments

Comments
 (0)