From 9dc87c19ae34e55b1d27d0115e6b26a53ad56336 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Fri, 4 Aug 2023 15:45:45 +0200 Subject: [PATCH 1/3] Add actor reboot method to the RunClient Closes #137 --- docs/docs.md | 34 +++++++++++++++++++ .../clients/base/actor_job_base_client.py | 14 ++++++++ .../clients/resource_clients/run.py | 20 +++++++++++ 3 files changed, 68 insertions(+) diff --git a/docs/docs.md b/docs/docs.md index 1e04f712..186d215d 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -1964,6 +1964,7 @@ Sub-client for manipulating a single actor run. * [wait\_for\_finish()](#runclient-wait\_for\_finish) * [metamorph()](#runclient-metamorph) * [resurrect()](#runclient-resurrect) +* [reboot()](#runclient-reboot) * [dataset()](#runclient-dataset) * [key\_value\_store()](#runclient-key\_value\_store) * [request\_queue()](#runclient-request\_queue) @@ -2108,6 +2109,22 @@ Run status will be updated to RUNNING and its container will be restarted with t *** +#### [](#runclient-reboot) `RunClient.reboot()` + +Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING can be rebooted. + +[https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run](https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run) + +* **Returns** + + Details about the rebooted run. + +* **Return type** + + `dics` + +*** + #### [](#runclient-dataset) `RunClient.dataset()` Get the client for the default dataset of the actor run. @@ -4416,6 +4433,7 @@ Async sub-client for manipulating a single actor run. * [async wait\_for\_finish()](#runclientasync-wait\_for\_finish) * [async metamorph()](#runclientasync-metamorph) * [async resurrect()](#runclientasync-resurrect) +* [async reboot()](#runclientasync-reboot) * [dataset()](#runclientasync-dataset) * [key\_value\_store()](#runclientasync-key\_value\_store) * [request\_queue()](#runclientasync-request\_queue) @@ -4560,6 +4578,22 @@ Run status will be updated to RUNNING and its container will be restarted with t *** +#### [](#runclientasync-reboot) `async RunClientAsync.reboot()` + +Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING can be rebooted. + +[https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run](https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run) + +* **Returns** + + Details about the rebooted run. + +* **Return type** + + `dics` + +*** + #### [](#runclientasync-dataset) `RunClientAsync.dataset()` Get the client for the default dataset of the actor run. diff --git a/src/apify_client/clients/base/actor_job_base_client.py b/src/apify_client/clients/base/actor_job_base_client.py index 0e7e62e7..230c6441 100644 --- a/src/apify_client/clients/base/actor_job_base_client.py +++ b/src/apify_client/clients/base/actor_job_base_client.py @@ -73,6 +73,13 @@ def _abort(self, gracefully: Optional[bool] = None) -> Dict: ) return parse_date_fields(_pluck_data(response.json())) + def _reboot(self) -> Dict: + response = self.http_client.call( + url=self._url('reboot'), + method='POST', + ) + return parse_date_fields(_pluck_data(response.json())) + @ignore_docs class ActorJobBaseClientAsync(ResourceClientAsync): @@ -129,3 +136,10 @@ async def _abort(self, gracefully: Optional[bool] = None) -> Dict: ), ) return parse_date_fields(_pluck_data(response.json())) + + async def _reboot(self) -> Dict: + response = await self.http_client.call( + url=self._url('reboot'), + method='POST', + ) + return parse_date_fields(_pluck_data(response.json())) diff --git a/src/apify_client/clients/resource_clients/run.py b/src/apify_client/clients/resource_clients/run.py index 3cf29b58..5c4a6a05 100644 --- a/src/apify_client/clients/resource_clients/run.py +++ b/src/apify_client/clients/resource_clients/run.py @@ -155,6 +155,16 @@ def resurrect( return parse_date_fields(_pluck_data(response.json())) + def reboot(self) -> Dict: + """Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING can be rebooted. + + https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run + + Returns: + dics: Details about the rebooted run. + """ + return self._reboot() + def dataset(self) -> DatasetClient: """Get the client for the default dataset of the actor run. @@ -349,6 +359,16 @@ async def resurrect( return parse_date_fields(_pluck_data(response.json())) + async def reboot(self) -> Dict: + """Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING can be rebooted. + + https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run + + Returns: + dics: Details about the rebooted run. + """ + return await self._reboot() + def dataset(self) -> DatasetClientAsync: """Get the client for the default dataset of the actor run. From 5fc4de3134d36ba98cbb900ddb2bc3bfe430e2ab Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Tue, 22 Aug 2023 14:00:43 +0200 Subject: [PATCH 2/3] Update docstring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jiří Moravčík --- src/apify_client/clients/resource_clients/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apify_client/clients/resource_clients/run.py b/src/apify_client/clients/resource_clients/run.py index 5c4a6a05..38e6deed 100644 --- a/src/apify_client/clients/resource_clients/run.py +++ b/src/apify_client/clients/resource_clients/run.py @@ -161,7 +161,7 @@ def reboot(self) -> Dict: https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run Returns: - dics: Details about the rebooted run. + dict: The Actor run data. """ return self._reboot() From 79156772ebb03d411c56773aac385a4df033d54c Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Tue, 22 Aug 2023 14:16:39 +0200 Subject: [PATCH 3/3] Remove reboot method from actor_job_base_client --- docs/docs.md | 8 ++++---- .../clients/base/actor_job_base_client.py | 14 -------------- src/apify_client/clients/resource_clients/run.py | 14 +++++++++++--- 3 files changed, 15 insertions(+), 21 deletions(-) diff --git a/docs/docs.md b/docs/docs.md index 186d215d..ae9161cf 100644 --- a/docs/docs.md +++ b/docs/docs.md @@ -2117,11 +2117,11 @@ Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING c * **Returns** - Details about the rebooted run. + The Actor run data. * **Return type** - `dics` + `dict` *** @@ -4586,11 +4586,11 @@ Reboot an Actor run. Only runs that are running, i.e. runs with status RUNNING c * **Returns** - Details about the rebooted run. + The Actor run data. * **Return type** - `dics` + `dict` *** diff --git a/src/apify_client/clients/base/actor_job_base_client.py b/src/apify_client/clients/base/actor_job_base_client.py index 230c6441..0e7e62e7 100644 --- a/src/apify_client/clients/base/actor_job_base_client.py +++ b/src/apify_client/clients/base/actor_job_base_client.py @@ -73,13 +73,6 @@ def _abort(self, gracefully: Optional[bool] = None) -> Dict: ) return parse_date_fields(_pluck_data(response.json())) - def _reboot(self) -> Dict: - response = self.http_client.call( - url=self._url('reboot'), - method='POST', - ) - return parse_date_fields(_pluck_data(response.json())) - @ignore_docs class ActorJobBaseClientAsync(ResourceClientAsync): @@ -136,10 +129,3 @@ async def _abort(self, gracefully: Optional[bool] = None) -> Dict: ), ) return parse_date_fields(_pluck_data(response.json())) - - async def _reboot(self) -> Dict: - response = await self.http_client.call( - url=self._url('reboot'), - method='POST', - ) - return parse_date_fields(_pluck_data(response.json())) diff --git a/src/apify_client/clients/resource_clients/run.py b/src/apify_client/clients/resource_clients/run.py index 38e6deed..5811aaa7 100644 --- a/src/apify_client/clients/resource_clients/run.py +++ b/src/apify_client/clients/resource_clients/run.py @@ -163,7 +163,11 @@ def reboot(self) -> Dict: Returns: dict: The Actor run data. """ - return self._reboot() + response = self.http_client.call( + url=self._url('reboot'), + method='POST', + ) + return parse_date_fields(_pluck_data(response.json())) def dataset(self) -> DatasetClient: """Get the client for the default dataset of the actor run. @@ -365,9 +369,13 @@ async def reboot(self) -> Dict: https://docs.apify.com/api/v2#/reference/actor-runs/reboot-run/reboot-run Returns: - dics: Details about the rebooted run. + dict: The Actor run data. """ - return await self._reboot() + response = await self.http_client.call( + url=self._url('reboot'), + method='POST', + ) + return parse_date_fields(_pluck_data(response.json())) def dataset(self) -> DatasetClientAsync: """Get the client for the default dataset of the actor run.