From 3e77ea6451bb019ceb1c8d063809b1d3408d6881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Morav=C4=8D=C3=ADk?= Date: Tue, 23 Jul 2024 18:31:58 +0200 Subject: [PATCH 1/2] feat: add actor standby --- .../clients/resource_clients/actor.py | 33 +++++++++++++++++++ .../resource_clients/actor_collection.py | 19 +++++++++++ .../clients/resource_clients/task.py | 28 ++++++++++++++++ .../resource_clients/task_collection.py | 16 +++++++++ 4 files changed, 96 insertions(+) diff --git a/src/apify_client/clients/resource_clients/actor.py b/src/apify_client/clients/resource_clients/actor.py index d2061b9c..d1fb24ce 100644 --- a/src/apify_client/clients/resource_clients/actor.py +++ b/src/apify_client/clients/resource_clients/actor.py @@ -41,6 +41,12 @@ def get_actor_representation( default_run_timeout_secs: int | None = None, example_run_input_body: Any = None, example_run_input_content_type: str | None = None, + actor_standby_is_enabled: bool | 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, ) -> dict: """Get dictionary representation of the Actor.""" return { @@ -65,6 +71,14 @@ def get_actor_representation( 'body': example_run_input_body, 'contentType': example_run_input_content_type, }, + 'actorStandby': { + 'isEnabled': actor_standby_is_enabled, + 'desiredRequestsPerActorRun': actor_standby_desired_requests_per_actor_run, + 'maxRequestsPerActorRun': actor_standby_max_requests_per_actor_run, + 'idleTimeoutSecs': actor_standby_idle_timeout_secs, + 'build': actor_standby_build, + 'memoryMbytes': actor_standby_memory_mbytes, + }, } @@ -107,6 +121,12 @@ def update( default_run_timeout_secs: int | None = None, example_run_input_body: Any = None, example_run_input_content_type: str | None = None, + actor_standby_is_enabled: bool | 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, ) -> dict: """Update the actor with the specified fields. @@ -131,6 +151,13 @@ def update( default_run_timeout_secs (int, optional): Default timeout for the runs of this actor in seconds. example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this actor. example_run_input_content_type (str, optional): The content type of the example run input. + actor_standby_is_enabled (bool, optional): Whether the Actor Standby is enabled. + actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. + actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. + actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. Returns: dict: The updated actor @@ -153,6 +180,12 @@ def update( default_run_timeout_secs=default_run_timeout_secs, example_run_input_body=example_run_input_body, example_run_input_content_type=example_run_input_content_type, + actor_standby_is_enabled=actor_standby_is_enabled, + 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, + actor_standby_idle_timeout_secs=actor_standby_idle_timeout_secs, + actor_standby_build=actor_standby_build, + actor_standby_memory_mbytes=actor_standby_memory_mbytes, ) return self._update(filter_out_none_values_recursively(actor_representation)) diff --git a/src/apify_client/clients/resource_clients/actor_collection.py b/src/apify_client/clients/resource_clients/actor_collection.py index ef85c89f..8a71a6da 100644 --- a/src/apify_client/clients/resource_clients/actor_collection.py +++ b/src/apify_client/clients/resource_clients/actor_collection.py @@ -63,6 +63,12 @@ def create( default_run_timeout_secs: int | None = None, example_run_input_body: Any = None, example_run_input_content_type: str | None = None, + actor_standby_is_enabled: bool | 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, ) -> dict: """Create a new actor. @@ -87,6 +93,13 @@ def create( default_run_timeout_secs (int, optional): Default timeout for the runs of this actor in seconds. example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this actor. example_run_input_content_type (str, optional): The content type of the example run input. + actor_standby_is_enabled (bool, optional): Whether the Actor Standby is enabled. + actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. + actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. + actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. Returns: dict: The created actor. @@ -109,6 +122,12 @@ def create( default_run_timeout_secs=default_run_timeout_secs, example_run_input_body=example_run_input_body, example_run_input_content_type=example_run_input_content_type, + actor_standby_is_enabled=actor_standby_is_enabled, + 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, + actor_standby_idle_timeout_secs=actor_standby_idle_timeout_secs, + actor_standby_build=actor_standby_build, + actor_standby_memory_mbytes=actor_standby_memory_mbytes, ) return self._create(filter_out_none_values_recursively(actor_representation)) diff --git a/src/apify_client/clients/resource_clients/task.py b/src/apify_client/clients/resource_clients/task.py index 9be6aa5e..b1a3bee5 100644 --- a/src/apify_client/clients/resource_clients/task.py +++ b/src/apify_client/clients/resource_clients/task.py @@ -29,6 +29,11 @@ def get_task_representation( memory_mbytes: int | None = None, timeout_secs: int | 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, ) -> dict: """Get the dictionary representation of a task.""" return { @@ -42,6 +47,13 @@ def get_task_representation( }, 'input': task_input, 'title': title, + 'actorStandby': { + 'desiredRequestsPerActorRun': actor_standby_desired_requests_per_actor_run, + 'maxRequestsPerActorRun': actor_standby_max_requests_per_actor_run, + 'idleTimeoutSecs': actor_standby_idle_timeout_secs, + 'build': actor_standby_build, + 'memoryMbytes': actor_standby_memory_mbytes, + }, } @@ -74,6 +86,11 @@ def update( memory_mbytes: int | None = None, timeout_secs: int | 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, ) -> dict: """Update the task with specified fields. @@ -90,6 +107,12 @@ def update( timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. task_input (dict, optional): Task input dictionary title (str, optional): A human-friendly equivalent of the name + actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. + actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. + actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. Returns: dict: The updated task @@ -102,6 +125,11 @@ def update( memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, 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, + actor_standby_idle_timeout_secs=actor_standby_idle_timeout_secs, + actor_standby_build=actor_standby_build, + actor_standby_memory_mbytes=actor_standby_memory_mbytes, ) return self._update(filter_out_none_values_recursively(task_representation)) diff --git a/src/apify_client/clients/resource_clients/task_collection.py b/src/apify_client/clients/resource_clients/task_collection.py index 8f201d99..d311a746 100644 --- a/src/apify_client/clients/resource_clients/task_collection.py +++ b/src/apify_client/clients/resource_clients/task_collection.py @@ -52,6 +52,11 @@ def create( max_items: int | None = None, task_input: dict | 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, ) -> dict: """Create a new task. @@ -69,6 +74,12 @@ def create( timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. task_input (dict, optional): Task input object. title (str, optional): A human-friendly equivalent of the name + actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. + actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. + actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. Returns: dict: The created task. @@ -82,6 +93,11 @@ def create( memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, 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, + actor_standby_idle_timeout_secs=actor_standby_idle_timeout_secs, + actor_standby_build=actor_standby_build, + actor_standby_memory_mbytes=actor_standby_memory_mbytes, ) return self._create(filter_out_none_values_recursively(task_representation)) From 4ef6c6369ad21229cd12f941565ad08f78a8591f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Morav=C4=8D=C3=ADk?= Date: Tue, 23 Jul 2024 19:32:11 +0200 Subject: [PATCH 2/2] async --- .../clients/resource_clients/actor.py | 19 +++++++++++++++++++ .../resource_clients/actor_collection.py | 19 +++++++++++++++++++ .../clients/resource_clients/task.py | 16 ++++++++++++++++ .../resource_clients/task_collection.py | 16 ++++++++++++++++ 4 files changed, 70 insertions(+) diff --git a/src/apify_client/clients/resource_clients/actor.py b/src/apify_client/clients/resource_clients/actor.py index d1fb24ce..3cc3fb6c 100644 --- a/src/apify_client/clients/resource_clients/actor.py +++ b/src/apify_client/clients/resource_clients/actor.py @@ -447,6 +447,12 @@ async def update( default_run_timeout_secs: int | None = None, example_run_input_body: Any = None, example_run_input_content_type: str | None = None, + actor_standby_is_enabled: bool | 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, ) -> dict: """Update the actor with the specified fields. @@ -471,6 +477,13 @@ async def update( default_run_timeout_secs (int, optional): Default timeout for the runs of this actor in seconds. example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this actor. example_run_input_content_type (str, optional): The content type of the example run input. + actor_standby_is_enabled (bool, optional): Whether the Actor Standby is enabled. + actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. + actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. + actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. Returns: dict: The updated actor @@ -493,6 +506,12 @@ async def update( default_run_timeout_secs=default_run_timeout_secs, example_run_input_body=example_run_input_body, example_run_input_content_type=example_run_input_content_type, + actor_standby_is_enabled=actor_standby_is_enabled, + 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, + actor_standby_idle_timeout_secs=actor_standby_idle_timeout_secs, + actor_standby_build=actor_standby_build, + actor_standby_memory_mbytes=actor_standby_memory_mbytes, ) return await self._update(filter_out_none_values_recursively(actor_representation)) diff --git a/src/apify_client/clients/resource_clients/actor_collection.py b/src/apify_client/clients/resource_clients/actor_collection.py index 8a71a6da..5a028bbb 100644 --- a/src/apify_client/clients/resource_clients/actor_collection.py +++ b/src/apify_client/clients/resource_clients/actor_collection.py @@ -185,6 +185,12 @@ async def create( default_run_timeout_secs: int | None = None, example_run_input_body: Any = None, example_run_input_content_type: str | None = None, + actor_standby_is_enabled: bool | 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, ) -> dict: """Create a new actor. @@ -209,6 +215,13 @@ async def create( default_run_timeout_secs (int, optional): Default timeout for the runs of this actor in seconds. example_run_input_body (Any, optional): Input to be prefilled as default input to new users of this actor. example_run_input_content_type (str, optional): The content type of the example run input. + actor_standby_is_enabled (bool, optional): Whether the Actor Standby is enabled. + actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. + actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. + actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. Returns: dict: The created actor. @@ -231,6 +244,12 @@ async def create( default_run_timeout_secs=default_run_timeout_secs, example_run_input_body=example_run_input_body, example_run_input_content_type=example_run_input_content_type, + actor_standby_is_enabled=actor_standby_is_enabled, + 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, + actor_standby_idle_timeout_secs=actor_standby_idle_timeout_secs, + actor_standby_build=actor_standby_build, + actor_standby_memory_mbytes=actor_standby_memory_mbytes, ) return await self._create(filter_out_none_values_recursively(actor_representation)) diff --git a/src/apify_client/clients/resource_clients/task.py b/src/apify_client/clients/resource_clients/task.py index b1a3bee5..dd3e39fb 100644 --- a/src/apify_client/clients/resource_clients/task.py +++ b/src/apify_client/clients/resource_clients/task.py @@ -339,6 +339,11 @@ async def update( memory_mbytes: int | None = None, timeout_secs: int | 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, ) -> dict: """Update the task with specified fields. @@ -355,6 +360,12 @@ async def update( timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. task_input (dict, optional): Task input dictionary title (str, optional): A human-friendly equivalent of the name + actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. + actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. + actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. Returns: dict: The updated task @@ -367,6 +378,11 @@ async def update( memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, 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, + actor_standby_idle_timeout_secs=actor_standby_idle_timeout_secs, + actor_standby_build=actor_standby_build, + actor_standby_memory_mbytes=actor_standby_memory_mbytes, ) return await self._update(filter_out_none_values_recursively(task_representation)) diff --git a/src/apify_client/clients/resource_clients/task_collection.py b/src/apify_client/clients/resource_clients/task_collection.py index d311a746..5e063d6f 100644 --- a/src/apify_client/clients/resource_clients/task_collection.py +++ b/src/apify_client/clients/resource_clients/task_collection.py @@ -144,6 +144,11 @@ async def create( max_items: int | None = None, task_input: dict | 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, ) -> dict: """Create a new task. @@ -161,6 +166,12 @@ async def create( timeout_secs (int, optional): Optional timeout for the run, in seconds. By default, the run uses timeout specified in the task settings. task_input (dict, optional): Task input object. title (str, optional): A human-friendly equivalent of the name + actor_standby_desired_requests_per_actor_run (int, optional): The desired number of concurrent HTTP requests for + a single Actor Standby run. + actor_standby_max_requests_per_actor_run (int, optional): The maximum number of concurrent HTTP requests for a single Actor Standby run. + actor_standby_idle_timeout_secs (int, optional): If the Actor run does not receive any requests for this time, it will be shut down. + actor_standby_build (str, optional): The build tag or number to run when the Actor is in Standby mode. + actor_standby_memory_mbytes (int, optional): The memory in megabytes to use when the Actor is in Standby mode. Returns: dict: The created task. @@ -174,6 +185,11 @@ async def create( memory_mbytes=memory_mbytes, timeout_secs=timeout_secs, 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, + actor_standby_idle_timeout_secs=actor_standby_idle_timeout_secs, + actor_standby_build=actor_standby_build, + actor_standby_memory_mbytes=actor_standby_memory_mbytes, ) return await self._create(filter_out_none_values_recursively(task_representation))