From de47a3824f53fc8e6a40fd898d54d0544687f420 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hanu=C5=A1?= Date: Thu, 2 Oct 2025 15:20:12 +0200 Subject: [PATCH 1/6] feat: move restart on error Actor option to Run options --- src/apify_client/clients/resource_clients/actor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apify_client/clients/resource_clients/actor.py b/src/apify_client/clients/resource_clients/actor.py index b889e431..e44f9800 100644 --- a/src/apify_client/clients/resource_clients/actor.py +++ b/src/apify_client/clients/resource_clients/actor.py @@ -69,7 +69,6 @@ def get_actor_representation( 'seoTitle': seo_title, 'seoDescription': seo_description, 'versions': versions, - 'restartOnError': restart_on_error, 'isPublic': is_public, 'isDeprecated': is_deprecated, 'isAnonymouslyRunnable': is_anonymously_runnable, @@ -79,6 +78,7 @@ def get_actor_representation( 'maxItems': default_run_max_items, 'memoryMbytes': default_run_memory_mbytes, 'timeoutSecs': default_run_timeout_secs, + 'restartOnError': restart_on_error, 'forcePermissionLevel': default_run_force_permission_level, }, 'exampleRunInput': { From 64a0a1ed52e559e00db816878a8054220945c4b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hanu=C5=A1?= Date: Tue, 7 Oct 2025 13:14:41 +0200 Subject: [PATCH 2/6] feat: add restart_on_error option to resurrect run --- src/apify_client/clients/resource_clients/run.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/apify_client/clients/resource_clients/run.py b/src/apify_client/clients/resource_clients/run.py index 0392e815..22f4ac02 100644 --- a/src/apify_client/clients/resource_clients/run.py +++ b/src/apify_client/clients/resource_clients/run.py @@ -162,6 +162,7 @@ def resurrect( timeout_secs: int | None = None, max_items: int | None = None, max_total_charge_usd: Decimal | None = None, + restart_on_error: bool | None = None, ) -> dict: """Resurrect a finished Actor run. @@ -181,6 +182,8 @@ def resurrect( resurrected run uses the same limit as before. Limit can be only increased. max_total_charge_usd: Maximum cost for the resurrected pay-per-event run in USD. By default, the resurrected run uses the same limit as before. Limit can be only increased. + restart_on_error: Determines whether the resurrected run will be restarted if it fails. + By default, the resurrected run uses the same setting as before. Returns: The Actor run data. @@ -191,6 +194,7 @@ def resurrect( timeout=timeout_secs, maxItems=max_items, maxTotalChargeUsd=max_total_charge_usd, + restartOnError=restart_on_error, ) response = self.http_client.call( @@ -483,6 +487,7 @@ async def resurrect( timeout_secs: int | None = None, max_items: int | None = None, max_total_charge_usd: Decimal | None = None, + restart_on_error: bool | None = None, ) -> dict: """Resurrect a finished Actor run. @@ -502,6 +507,8 @@ async def resurrect( resurrected run uses the same limit as before. Limit can be only increased. max_total_charge_usd: Maximum cost for the resurrected pay-per-event run in USD. By default, the resurrected run uses the same limit as before. Limit can be only increased. + restart_on_error: Determines whether the resurrected run will be restarted if it fails. + By default, the resurrected run uses the same setting as before. Returns: The Actor run data. @@ -512,6 +519,7 @@ async def resurrect( timeout=timeout_secs, maxItems=max_items, maxTotalChargeUsd=max_total_charge_usd, + restartOnError=restart_on_error, ) response = await self.http_client.call( From 00260e9c211e7cbb630101b1c5f211dc297ff114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hanu=C5=A1?= Date: Thu, 9 Oct 2025 09:33:04 +0200 Subject: [PATCH 3/6] feat: add restart_on_error option to actor start and call and to task in general --- .../clients/resource_clients/actor.py | 20 ++++++++++++-- .../resource_clients/actor_collection.py | 4 +-- .../clients/resource_clients/task.py | 26 +++++++++++++++++++ .../resource_clients/task_collection.py | 8 ++++++ 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/src/apify_client/clients/resource_clients/actor.py b/src/apify_client/clients/resource_clients/actor.py index e44f9800..a55307b9 100644 --- a/src/apify_client/clients/resource_clients/actor.py +++ b/src/apify_client/clients/resource_clients/actor.py @@ -153,7 +153,7 @@ def update( seo_title: The title of the Actor optimized for search engines. seo_description: The description of the Actor optimized for search engines. versions: The list of Actor versions. - restart_on_error: If true, the main Actor run process will be restarted whenever it exits with + restart_on_error: If true, the Actor run process will be restarted whenever it exits with a non-zero status code. is_public: Whether the Actor is public. is_deprecated: Whether the Actor is deprecated. @@ -224,6 +224,7 @@ def start( build: str | None = None, max_items: int | None = None, max_total_charge_usd: Decimal | None = None, + restart_on_error: bool | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, force_permission_level: ActorPermissionLevel | None = None, @@ -242,6 +243,8 @@ def start( max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result, you will not be charged for more results than the given limit. max_total_charge_usd: A limit on the total charged amount for pay-per-event actors. + restart_on_error: If true, the Actor run process will be restarted whenever it exits with + a non-zero status code. memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified in the default run configuration for the Actor. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified @@ -267,6 +270,7 @@ def start( build=build, maxItems=max_items, maxTotalChargeUsd=max_total_charge_usd, + restartOnError=restart_on_error, memory=memory_mbytes, timeout=timeout_secs, waitForFinish=wait_for_finish, @@ -292,6 +296,7 @@ def call( build: str | None = None, max_items: int | None = None, max_total_charge_usd: Decimal | None = None, + restart_on_error: bool | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, webhooks: list[dict] | None = None, @@ -313,6 +318,8 @@ def call( max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result, you will not be charged for more results than the given limit. max_total_charge_usd: A limit on the total charged amount for pay-per-event actors. + restart_on_error: If true, the Actor run process will be restarted whenever it exits with + a non-zero status code. memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified in the default run configuration for the Actor. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified @@ -338,6 +345,7 @@ def call( build=build, max_items=max_items, max_total_charge_usd=max_total_charge_usd, + restart_on_error=restart_on_error, memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, webhooks=webhooks, @@ -565,7 +573,7 @@ async def update( seo_title: The title of the Actor optimized for search engines. seo_description: The description of the Actor optimized for search engines. versions: The list of Actor versions. - restart_on_error: If true, the main Actor run process will be restarted whenever it exits with + restart_on_error: If true, the Actor run process will be restarted whenever it exits with a non-zero status code. is_public: Whether the Actor is public. is_deprecated: Whether the Actor is deprecated. @@ -636,6 +644,7 @@ async def start( build: str | None = None, max_items: int | None = None, max_total_charge_usd: Decimal | None = None, + restart_on_error: bool | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, force_permission_level: ActorPermissionLevel | None = None, @@ -654,6 +663,8 @@ async def start( max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result, you will not be charged for more results than the given limit. max_total_charge_usd: A limit on the total charged amount for pay-per-event actors. + restart_on_error: If true, the Actor run process will be restarted whenever it exits with + a non-zero status code. memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified in the default run configuration for the Actor. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified @@ -679,6 +690,7 @@ async def start( build=build, maxItems=max_items, maxTotalChargeUsd=max_total_charge_usd, + restartOnError=restart_on_error, memory=memory_mbytes, timeout=timeout_secs, waitForFinish=wait_for_finish, @@ -704,6 +716,7 @@ async def call( build: str | None = None, max_items: int | None = None, max_total_charge_usd: Decimal | None = None, + restart_on_error: bool | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, webhooks: list[dict] | None = None, @@ -725,6 +738,8 @@ async def call( max_items: Maximum number of results that will be returned by this run. If the Actor is charged per result, you will not be charged for more results than the given limit. max_total_charge_usd: A limit on the total charged amount for pay-per-event actors. + restart_on_error: If true, the Actor run process will be restarted whenever it exits with + a non-zero status code. memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified in the default run configuration for the Actor. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified @@ -750,6 +765,7 @@ async def call( build=build, max_items=max_items, max_total_charge_usd=max_total_charge_usd, + restart_on_error=restart_on_error, memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, webhooks=webhooks, diff --git a/src/apify_client/clients/resource_clients/actor_collection.py b/src/apify_client/clients/resource_clients/actor_collection.py index 3746dfbb..95c7b105 100644 --- a/src/apify_client/clients/resource_clients/actor_collection.py +++ b/src/apify_client/clients/resource_clients/actor_collection.py @@ -80,7 +80,7 @@ def create( seo_title: The title of the Actor optimized for search engines. seo_description: The description of the Actor optimized for search engines. versions: The list of Actor versions. - restart_on_error: If true, the main Actor run process will be restarted whenever it exits with + restart_on_error: If true, the Actor run process will be restarted whenever it exits with a non-zero status code. is_public: Whether the Actor is public. is_deprecated: Whether the Actor is deprecated. @@ -205,7 +205,7 @@ async def create( seo_title: The title of the Actor optimized for search engines. seo_description: The description of the Actor optimized for search engines. versions: The list of Actor versions. - restart_on_error: If true, the main Actor run process will be restarted whenever it exits with + restart_on_error: If true, the Actor run process will be restarted whenever it exits with a non-zero status code. is_public: Whether the Actor is public. is_deprecated: Whether the Actor is deprecated. diff --git a/src/apify_client/clients/resource_clients/task.py b/src/apify_client/clients/resource_clients/task.py index 5db942b4..b5d02937 100644 --- a/src/apify_client/clients/resource_clients/task.py +++ b/src/apify_client/clients/resource_clients/task.py @@ -32,6 +32,7 @@ def get_task_representation( max_items: int | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, + restart_on_error: bool | None = None, title: str | None = None, actor_standby_desired_requests_per_actor_run: int | None = None, actor_standby_max_requests_per_actor_run: int | None = None, @@ -48,6 +49,7 @@ def get_task_representation( 'maxItems': max_items, 'memoryMbytes': memory_mbytes, 'timeoutSecs': timeout_secs, + 'restartOnError': restart_on_error, }, 'input': task_input, 'title': title, @@ -87,6 +89,7 @@ def update( max_items: int | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, + restart_on_error: bool | None = None, title: str | None = None, actor_standby_desired_requests_per_actor_run: int | None = None, actor_standby_max_requests_per_actor_run: int | None = None, @@ -109,6 +112,8 @@ def update( timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. task_input: Task input dictionary. + restart_on_error: If true, the Task run process will be restarted whenever it exits with + a non-zero status code. title: A human-friendly equivalent of the name. actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for a single Actor Standby run. @@ -129,6 +134,7 @@ def update( max_items=max_items, memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, + restart_on_error=restart_on_error, title=title, actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run, actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run, @@ -154,6 +160,7 @@ def start( max_items: int | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, + restart_on_error: bool | None = None, wait_for_finish: int | None = None, webhooks: list[dict] | None = None, ) -> dict: @@ -171,6 +178,8 @@ def start( in the task settings. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. + restart_on_error: If true, the Task run process will be restarted whenever it exits with + a non-zero status code. wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default, it is 0, the maximum value is 60. webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with @@ -189,6 +198,7 @@ def start( maxItems=max_items, memory=memory_mbytes, timeout=timeout_secs, + restartOnError=restart_on_error, waitForFinish=wait_for_finish, webhooks=encode_webhook_list_to_base64(webhooks) if webhooks is not None else None, ) @@ -211,6 +221,7 @@ def call( max_items: int | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, + restart_on_error: bool | None = None, webhooks: list[dict] | None = None, wait_secs: int | None = None, ) -> dict | None: @@ -230,6 +241,8 @@ def call( in the task settings. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. + restart_on_error: If true, the Task run process will be restarted whenever it exits with + a non-zero status code. webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for the Actor or task, you do not have to add it again here. @@ -245,6 +258,7 @@ def call( max_items=max_items, memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, + restart_on_error=restart_on_error, webhooks=webhooks, ) @@ -343,6 +357,7 @@ async def update( max_items: int | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, + restart_on_error: bool | None = None, title: str | None = None, actor_standby_desired_requests_per_actor_run: int | None = None, actor_standby_max_requests_per_actor_run: int | None = None, @@ -364,6 +379,8 @@ async def update( in the task settings. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. + restart_on_error: If true, the Task run process will be restarted whenever it exits with + a non-zero status code. task_input: Task input dictionary. title: A human-friendly equivalent of the name. actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for @@ -385,6 +402,7 @@ async def update( max_items=max_items, memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, + restart_on_error=restart_on_error, title=title, actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run, actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run, @@ -410,6 +428,7 @@ async def start( max_items: int | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, + restart_on_error: bool | None = None, wait_for_finish: int | None = None, webhooks: list[dict] | None = None, ) -> dict: @@ -427,6 +446,8 @@ async def start( in the task settings. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. + restart_on_error: If true, the Task run process will be restarted whenever it exits with + a non-zero status code. wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default, it is 0, the maximum value is 60. webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with @@ -445,6 +466,7 @@ async def start( maxItems=max_items, memory=memory_mbytes, timeout=timeout_secs, + restartOnError=restart_on_error, waitForFinish=wait_for_finish, webhooks=encode_webhook_list_to_base64(webhooks) if webhooks is not None else None, ) @@ -467,6 +489,7 @@ async def call( max_items: int | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, + restart_on_error: bool | None = None, webhooks: list[dict] | None = None, wait_secs: int | None = None, ) -> dict | None: @@ -486,6 +509,8 @@ async def call( in the task settings. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. + restart_on_error: If true, the Task run process will be restarted whenever it exits with + a non-zero status code. webhooks: Specifies optional webhooks associated with the Actor run, which can be used to receive a notification e.g. when the Actor finished or failed. Note: if you already have a webhook set up for the Actor or task, you do not have to add it again here. @@ -501,6 +526,7 @@ async def call( max_items=max_items, memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, + restart_on_error=restart_on_error, webhooks=webhooks, ) diff --git a/src/apify_client/clients/resource_clients/task_collection.py b/src/apify_client/clients/resource_clients/task_collection.py index 7956eda1..0f8fe188 100644 --- a/src/apify_client/clients/resource_clients/task_collection.py +++ b/src/apify_client/clients/resource_clients/task_collection.py @@ -47,6 +47,7 @@ def create( timeout_secs: int | None = None, memory_mbytes: int | None = None, max_items: int | None = None, + restart_on_error: bool | None = None, task_input: dict | None = None, title: str | None = None, actor_standby_desired_requests_per_actor_run: int | None = None, @@ -70,6 +71,8 @@ def create( is charged per result, you will not be charged for more results than the given limit. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. + restart_on_error: If true, the Task run process will be restarted whenever it exits with + a non-zero status code. task_input: Task input object. title: A human-friendly equivalent of the name. actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for @@ -92,6 +95,7 @@ def create( max_items=max_items, memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, + restart_on_error=restart_on_error, title=title, actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run, actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run, @@ -140,6 +144,7 @@ async def create( timeout_secs: int | None = None, memory_mbytes: int | None = None, max_items: int | None = None, + restart_on_error: bool | None = None, task_input: dict | None = None, title: str | None = None, actor_standby_desired_requests_per_actor_run: int | None = None, @@ -163,6 +168,8 @@ async def create( is charged per result, you will not be charged for more results than the given limit. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. + restart_on_error: If true, the Task run process will be restarted whenever it exits with + a non-zero status code. task_input: Task input object. title: A human-friendly equivalent of the name. actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for @@ -185,6 +192,7 @@ async def create( max_items=max_items, memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, + restart_on_error=restart_on_error, title=title, actor_standby_desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run, actor_standby_max_requests_per_actor_run=actor_standby_max_requests_per_actor_run, From ef982b5a097a69d47aefbfe59c6d3dc241908545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hanu=C5=A1?= Date: Thu, 9 Oct 2025 12:27:20 +0200 Subject: [PATCH 4/6] fix: move restart_on_error to the end in task representation function --- src/apify_client/clients/resource_clients/task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apify_client/clients/resource_clients/task.py b/src/apify_client/clients/resource_clients/task.py index b5d02937..2bfdd8b3 100644 --- a/src/apify_client/clients/resource_clients/task.py +++ b/src/apify_client/clients/resource_clients/task.py @@ -32,13 +32,13 @@ def get_task_representation( max_items: int | None = None, memory_mbytes: int | None = None, timeout_secs: int | None = None, - restart_on_error: bool | None = None, title: str | None = None, actor_standby_desired_requests_per_actor_run: int | None = None, actor_standby_max_requests_per_actor_run: int | None = None, actor_standby_idle_timeout_secs: int | None = None, actor_standby_build: str | None = None, actor_standby_memory_mbytes: int | None = None, + restart_on_error: bool | None = None, ) -> dict: """Get the dictionary representation of a task.""" return { From e31e18b4a79b75eae3f7e09b324963bb6b2f73c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hanu=C5=A1?= Date: Thu, 9 Oct 2025 12:36:20 +0200 Subject: [PATCH 5/6] fix: synchronize sync and async task docs --- src/apify_client/clients/resource_clients/task.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apify_client/clients/resource_clients/task.py b/src/apify_client/clients/resource_clients/task.py index 2bfdd8b3..ac78955e 100644 --- a/src/apify_client/clients/resource_clients/task.py +++ b/src/apify_client/clients/resource_clients/task.py @@ -111,9 +111,9 @@ def update( in the task settings. timeout_secs: Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. - task_input: Task input dictionary. restart_on_error: If true, the Task run process will be restarted whenever it exits with a non-zero status code. + task_input: Task input dictionary. title: A human-friendly equivalent of the name. actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for a single Actor Standby run. From 8e7ec1fd7f5937128c1c31914f0a09ee75ce0ec3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Hanu=C5=A1?= Date: Thu, 9 Oct 2025 13:06:35 +0200 Subject: [PATCH 6/6] fix: make restart_on_error in task representation function non-positional --- src/apify_client/clients/resource_clients/task.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/apify_client/clients/resource_clients/task.py b/src/apify_client/clients/resource_clients/task.py index ac78955e..4f53fb6b 100644 --- a/src/apify_client/clients/resource_clients/task.py +++ b/src/apify_client/clients/resource_clients/task.py @@ -38,6 +38,7 @@ def get_task_representation( actor_standby_idle_timeout_secs: int | None = None, actor_standby_build: str | None = None, actor_standby_memory_mbytes: int | None = None, + *, restart_on_error: bool | None = None, ) -> dict: """Get the dictionary representation of a task."""