Skip to content

Commit ffa2984

Browse files
authored
Add option to change run options when resurrecting it (#125)
On the API, we support changing the run options (build, memory, timeout) when resurrecting it, but we didn't support it in the client. This adds it.
1 parent 85fdc56 commit ffa2984

File tree

4 files changed

+75
-7
lines changed

4 files changed

+75
-7
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Changelog
22
=========
33

4+
[1.2.0](../../releases/tag/v1.2.0) - Unreleased
5+
6+
### Added
7+
8+
- added option to change the build, memory limit and timeout when resurrecting a run
9+
410
[1.1.1](../../releases/tag/v1.1.1) - 2023-05-05
511

612
### Internal changes

docs/docs.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2078,7 +2078,7 @@ Transform an actor run into a run of another actor with a new input.
20782078

20792079
***
20802080

2081-
#### [](#runclient-resurrect) `RunClient.resurrect()`
2081+
#### [](#runclient-resurrect) `RunClient.resurrect(*, build=None, memory_mbytes=None, timeout_secs=None)`
20822082

20832083
Resurrect a finished actor run.
20842084

@@ -2087,6 +2087,17 @@ Run status will be updated to RUNNING and its container will be restarted with t
20872087

20882088
[https://docs.apify.com/api/v2#/reference/actor-runs/resurrect-run/resurrect-run](https://docs.apify.com/api/v2#/reference/actor-runs/resurrect-run/resurrect-run)
20892089

2090+
* **Parameters**
2091+
2092+
* **build** (`str`, *optional*) – Which actor build the resurrected run should use. It can be either a build tag or build number.
2093+
By default, the resurrected run uses the same build as before.
2094+
2095+
* **memory_mbytes** (`int`, *optional*) – New memory limit for the resurrected run, in megabytes.
2096+
By default, the resurrected run uses the same memory limit as before.
2097+
2098+
* **timeout_secs** (`int`, *optional*) – New timeout for the resurrected run, in seconds.
2099+
By default, the resurrected run uses the same timeout as before.
2100+
20902101
* **Returns**
20912102

20922103
The actor run data.
@@ -4283,7 +4294,7 @@ Transform an actor run into a run of another actor with a new input.
42834294

42844295
***
42854296

4286-
#### [](#runclientasync-resurrect) `async RunClientAsync.resurrect()`
4297+
#### [](#runclientasync-resurrect) `async RunClientAsync.resurrect(*, build=None, memory_mbytes=None, timeout_secs=None)`
42874298

42884299
Resurrect a finished actor run.
42894300

@@ -4292,6 +4303,17 @@ Run status will be updated to RUNNING and its container will be restarted with t
42924303

42934304
[https://docs.apify.com/api/v2#/reference/actor-runs/resurrect-run/resurrect-run](https://docs.apify.com/api/v2#/reference/actor-runs/resurrect-run/resurrect-run)
42944305

4306+
* **Parameters**
4307+
4308+
* **build** (`str`, *optional*) – Which actor build the resurrected run should use. It can be either a build tag or build number.
4309+
By default, the resurrected run uses the same build as before.
4310+
4311+
* **memory_mbytes** (`int`, *optional*) – New memory limit for the resurrected run, in megabytes.
4312+
By default, the resurrected run uses the same memory limit as before.
4313+
4314+
* **timeout_secs** (`int`, *optional*) – New timeout for the resurrected run, in seconds.
4315+
By default, the resurrected run uses the same timeout as before.
4316+
42954317
* **Returns**
42964318

42974319
The actor run data.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "apify_client"
3-
version = "1.1.1"
3+
version = "1.2.0"
44
description = "Apify API client for Python"
55
readme = "README.md"
66
license = {text = "Apache Software License"}

src/apify_client/clients/resource_clients/run.py

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,41 @@ def metamorph(
121121

122122
return _parse_date_fields(_pluck_data(response.json()))
123123

124-
def resurrect(self) -> Dict:
124+
def resurrect(
125+
self,
126+
*,
127+
build: Optional[str] = None,
128+
memory_mbytes: Optional[int] = None,
129+
timeout_secs: Optional[int] = None,
130+
) -> Dict:
125131
"""Resurrect a finished actor run.
126132
127133
Only finished runs, i.e. runs with status FINISHED, FAILED, ABORTED and TIMED-OUT can be resurrected.
128134
Run status will be updated to RUNNING and its container will be restarted with the same default storages.
129135
130136
https://docs.apify.com/api/v2#/reference/actor-runs/resurrect-run/resurrect-run
131137
138+
Args:
139+
build (str, optional): Which actor build the resurrected run should use. It can be either a build tag or build number.
140+
By default, the resurrected run uses the same build as before.
141+
memory_mbytes (int, optional): New memory limit for the resurrected run, in megabytes.
142+
By default, the resurrected run uses the same memory limit as before.
143+
timeout_secs (int, optional): New timeout for the resurrected run, in seconds.
144+
By default, the resurrected run uses the same timeout as before.
145+
132146
Returns:
133147
dict: The actor run data.
134148
"""
149+
request_params = self._params(
150+
build=build,
151+
memory=memory_mbytes,
152+
timeout=timeout_secs,
153+
)
154+
135155
response = self.http_client.call(
136156
url=self._url('resurrect'),
137157
method='POST',
138-
params=self._params(),
158+
params=request_params,
139159
)
140160

141161
return _parse_date_fields(_pluck_data(response.json()))
@@ -295,21 +315,41 @@ async def metamorph(
295315

296316
return _parse_date_fields(_pluck_data(response.json()))
297317

298-
async def resurrect(self) -> Dict:
318+
async def resurrect(
319+
self,
320+
*,
321+
build: Optional[str] = None,
322+
memory_mbytes: Optional[int] = None,
323+
timeout_secs: Optional[int] = None,
324+
) -> Dict:
299325
"""Resurrect a finished actor run.
300326
301327
Only finished runs, i.e. runs with status FINISHED, FAILED, ABORTED and TIMED-OUT can be resurrected.
302328
Run status will be updated to RUNNING and its container will be restarted with the same default storages.
303329
304330
https://docs.apify.com/api/v2#/reference/actor-runs/resurrect-run/resurrect-run
305331
332+
Args:
333+
build (str, optional): Which actor build the resurrected run should use. It can be either a build tag or build number.
334+
By default, the resurrected run uses the same build as before.
335+
memory_mbytes (int, optional): New memory limit for the resurrected run, in megabytes.
336+
By default, the resurrected run uses the same memory limit as before.
337+
timeout_secs (int, optional): New timeout for the resurrected run, in seconds.
338+
By default, the resurrected run uses the same timeout as before.
339+
306340
Returns:
307341
dict: The actor run data.
308342
"""
343+
request_params = self._params(
344+
build=build,
345+
memory=memory_mbytes,
346+
timeout=timeout_secs,
347+
)
348+
309349
response = await self.http_client.call(
310350
url=self._url('resurrect'),
311351
method='POST',
312-
params=self._params(),
352+
params=request_params,
313353
)
314354

315355
return _parse_date_fields(_pluck_data(response.json()))

0 commit comments

Comments
 (0)