Skip to content

Commit e8ef135

Browse files
authored
feat: add server_* arguments and deprecate actor_standby_* ones (#1202)
Renames the `actor_standby_*` arguments of `ActorClient.update`, `ActorCollectionClient.create`, `TaskClient.update`, and `TaskCollectionClient.create` (sync and async) to the Server Actor naming used by `ActorClient.server()`: | Deprecated | New | | --- | --- | | `actor_standby_is_enabled` | `server_is_enabled` | | `actor_standby_desired_requests_per_actor_run` | `server_desired_requests_per_actor_run` | | `actor_standby_max_requests_per_actor_run` | `server_max_requests_per_actor_run` | | `actor_standby_idle_timeout` | `server_idle_timeout` | | `actor_standby_build` | `server_build` | | `actor_standby_memory_mbytes` | `server_memory_mbytes` | | `actor_standby_disable_standby_fields_override` | `server_disable_fields_override` | | `actor_standby_should_pass_actor_input` | `server_should_pass_actor_input` | The task methods take the five arguments they had before. The old names stay as deprecated aliases until v4, the same way as `build_tag` in `validate_input()`. Each one set emits a `DeprecationWarning` at the caller, and passing an alias together with its new name raises a `ValueError`. All eight methods share one helper, `build_actor_standby`, which maps the aliases and builds the `actorStandby` field. `actor_standby_tenancy` from #1169 isn't on master yet, so it isn't covered here. #1169 can add it as `server_tenancy` directly, without an alias. It should ship in the same release as #1153. Closes: #1195 *✍️ Drafted by Claude Code*
1 parent 9c56a55 commit e8ef135

10 files changed

Lines changed: 675 additions & 206 deletions

File tree

‎docs/02_concepts/14_server_actors.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ A [Server Actor](https://docs.apify.com/platform/actors/running/standby) (former
1919

2020
:::note Formerly Actor Standby
2121

22-
Actor Standby is the former name of Server Actors, and it'll be deprecated. The platform documentation and the API still use it, for example in the Actor's `standby_url` and `actor_standby` fields, and in the `actor_standby_*` arguments of `ActorClient.update`. In the client, `ActorClient.standby` is a deprecated alias of `ActorClient.server` that will be removed in v4.
22+
Actor Standby is the former name of Server Actors, and it'll be deprecated. The platform documentation and the API still use it, for example in the Actor's `standby_url` and `actor_standby` fields. In the client, `ActorClient.standby` is a deprecated alias of `ActorClient.server`, and the `actor_standby_*` arguments of the Actor and task `update` and `create` methods are deprecated aliases of their `server_*` counterparts, such as `server_build` for `actor_standby_build`. The aliases will be removed in v4.
2323

2424
:::
2525

‎src/apify_client/_resource_clients/actor.py‎

Lines changed: 117 additions & 53 deletions
Large diffs are not rendered by default.

‎src/apify_client/_resource_clients/actor_collection.py‎

Lines changed: 113 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from apify_client._models import (
77
ActorResource,
88
ActorResponse,
9-
ActorStandby,
109
CreateActorRequest,
1110
DefaultRunOptions,
1211
ExampleRunInput,
@@ -15,6 +14,7 @@
1514
)
1615
from apify_client._pagination import get_items_iterator, get_items_iterator_async
1716
from apify_client._resource_clients._resource_client import ResourceClient, ResourceClientAsync
17+
from apify_client._utils.server_args import build_actor_standby
1818
from apify_client._utils.time import to_seconds
1919

2020
if TYPE_CHECKING:
@@ -129,6 +129,16 @@ def create(
129129
default_run_force_permission_level: ActorPermissionLevel | None = None,
130130
example_run_input_body: str | None = None,
131131
example_run_input_content_type: str | None = None,
132+
server_is_enabled: bool | None = None,
133+
server_desired_requests_per_actor_run: int | None = None,
134+
server_max_requests_per_actor_run: int | None = None,
135+
server_idle_timeout: timedelta | None = None,
136+
server_build: str | None = None,
137+
server_memory_mbytes: int | None = None,
138+
server_disable_fields_override: bool | None = None,
139+
server_should_pass_actor_input: bool | None = None,
140+
actor_permission_level: ActorPermissionLevel | None = None,
141+
timeout: Timeout = 'medium',
132142
actor_standby_is_enabled: bool | None = None,
133143
actor_standby_desired_requests_per_actor_run: int | None = None,
134144
actor_standby_max_requests_per_actor_run: int | None = None,
@@ -137,8 +147,6 @@ def create(
137147
actor_standby_memory_mbytes: int | None = None,
138148
actor_standby_disable_standby_fields_override: bool | None = None,
139149
actor_standby_should_pass_actor_input: bool | None = None,
140-
actor_permission_level: ActorPermissionLevel | None = None,
141-
timeout: Timeout = 'medium',
142150
) -> ActorResource:
143151
"""Create a new Actor.
144152
@@ -166,21 +174,33 @@ def create(
166174
example_run_input_body: Input to be prefilled as default input to new users of this Actor, serialized
167175
as a string (e.g. `json.dumps(input)` for a JSON input).
168176
example_run_input_content_type: The content type of the example run input.
169-
actor_standby_is_enabled: Whether the Actor Standby is enabled.
170-
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
171-
a single Actor Standby run.
172-
actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for
173-
a single Actor Standby run.
174-
actor_standby_idle_timeout: If the Actor run does not receive any requests for this time,
175-
it will be shut down.
176-
actor_standby_build: The build tag or number to run when the Actor is in Standby mode.
177-
actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode.
178-
actor_standby_disable_standby_fields_override: If true, prevents the Standby configuration from being
179-
overridden elsewhere.
180-
actor_standby_should_pass_actor_input: Whether to pass the Actor input to the Standby runs. If false,
181-
the Standby runs start with no input.
177+
server_is_enabled: Whether the Actor is a Server Actor, which runs a web server called over HTTP.
178+
server_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for a single run of
179+
the Server Actor.
180+
server_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for a single run of the
181+
Server Actor.
182+
server_idle_timeout: If a run of the Server Actor does not receive any requests for this time, it is shut
183+
down.
184+
server_build: The build tag or number that the Server Actor runs.
185+
server_memory_mbytes: The memory in megabytes for the runs of the Server Actor.
186+
server_disable_fields_override: If true, prevents the Server Actor configuration from being overridden
187+
elsewhere.
188+
server_should_pass_actor_input: Whether to pass the Actor input to the runs of the Server Actor. If false,
189+
they start with no input.
182190
actor_permission_level: The permission level of the Actor on Apify platform.
183191
timeout: Timeout for the API HTTP request.
192+
actor_standby_is_enabled: Deprecated alias of `server_is_enabled`. Will be removed in v4.
193+
actor_standby_desired_requests_per_actor_run: Deprecated alias of `server_desired_requests_per_actor_run`.
194+
Will be removed in v4.
195+
actor_standby_max_requests_per_actor_run: Deprecated alias of `server_max_requests_per_actor_run`. Will be
196+
removed in v4.
197+
actor_standby_idle_timeout: Deprecated alias of `server_idle_timeout`. Will be removed in v4.
198+
actor_standby_build: Deprecated alias of `server_build`. Will be removed in v4.
199+
actor_standby_memory_mbytes: Deprecated alias of `server_memory_mbytes`. Will be removed in v4.
200+
actor_standby_disable_standby_fields_override: Deprecated alias of `server_disable_fields_override`. Will be
201+
removed in v4.
202+
actor_standby_should_pass_actor_input: Deprecated alias of `server_should_pass_actor_input`. Will be removed
203+
in v4.
184204
185205
Returns:
186206
The created Actor.
@@ -204,15 +224,27 @@ def create(
204224
force_permission_level=default_run_force_permission_level,
205225
restart_on_error=restart_on_error,
206226
),
207-
actor_standby=ActorStandby(
208-
is_enabled=actor_standby_is_enabled,
209-
desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
210-
max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
211-
idle_timeout_secs=to_seconds(actor_standby_idle_timeout, as_int=True),
212-
build=actor_standby_build,
213-
memory_mbytes=actor_standby_memory_mbytes,
214-
disable_standby_fields_override=actor_standby_disable_standby_fields_override,
215-
should_pass_actor_input=actor_standby_should_pass_actor_input,
227+
actor_standby=build_actor_standby(
228+
{
229+
'server_is_enabled': server_is_enabled,
230+
'server_desired_requests_per_actor_run': server_desired_requests_per_actor_run,
231+
'server_max_requests_per_actor_run': server_max_requests_per_actor_run,
232+
'server_idle_timeout': server_idle_timeout,
233+
'server_build': server_build,
234+
'server_memory_mbytes': server_memory_mbytes,
235+
'server_disable_fields_override': server_disable_fields_override,
236+
'server_should_pass_actor_input': server_should_pass_actor_input,
237+
},
238+
{
239+
'actor_standby_is_enabled': actor_standby_is_enabled,
240+
'actor_standby_desired_requests_per_actor_run': actor_standby_desired_requests_per_actor_run,
241+
'actor_standby_max_requests_per_actor_run': actor_standby_max_requests_per_actor_run,
242+
'actor_standby_idle_timeout': actor_standby_idle_timeout,
243+
'actor_standby_build': actor_standby_build,
244+
'actor_standby_memory_mbytes': actor_standby_memory_mbytes,
245+
'actor_standby_disable_standby_fields_override': actor_standby_disable_standby_fields_override,
246+
'actor_standby_should_pass_actor_input': actor_standby_should_pass_actor_input,
247+
},
216248
),
217249
example_run_input=ExampleRunInput(
218250
body=example_run_input_body,
@@ -326,6 +358,16 @@ async def create(
326358
default_run_force_permission_level: ActorPermissionLevel | None = None,
327359
example_run_input_body: str | None = None,
328360
example_run_input_content_type: str | None = None,
361+
server_is_enabled: bool | None = None,
362+
server_desired_requests_per_actor_run: int | None = None,
363+
server_max_requests_per_actor_run: int | None = None,
364+
server_idle_timeout: timedelta | None = None,
365+
server_build: str | None = None,
366+
server_memory_mbytes: int | None = None,
367+
server_disable_fields_override: bool | None = None,
368+
server_should_pass_actor_input: bool | None = None,
369+
actor_permission_level: ActorPermissionLevel | None = None,
370+
timeout: Timeout = 'medium',
329371
actor_standby_is_enabled: bool | None = None,
330372
actor_standby_desired_requests_per_actor_run: int | None = None,
331373
actor_standby_max_requests_per_actor_run: int | None = None,
@@ -334,8 +376,6 @@ async def create(
334376
actor_standby_memory_mbytes: int | None = None,
335377
actor_standby_disable_standby_fields_override: bool | None = None,
336378
actor_standby_should_pass_actor_input: bool | None = None,
337-
actor_permission_level: ActorPermissionLevel | None = None,
338-
timeout: Timeout = 'medium',
339379
) -> ActorResource:
340380
"""Create a new Actor.
341381
@@ -363,21 +403,33 @@ async def create(
363403
example_run_input_body: Input to be prefilled as default input to new users of this Actor, serialized
364404
as a string (e.g. `json.dumps(input)` for a JSON input).
365405
example_run_input_content_type: The content type of the example run input.
366-
actor_standby_is_enabled: Whether the Actor Standby is enabled.
367-
actor_standby_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for
368-
a single Actor Standby run.
369-
actor_standby_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for
370-
a single Actor Standby run.
371-
actor_standby_idle_timeout: If the Actor run does not receive any requests for this time,
372-
it will be shut down.
373-
actor_standby_build: The build tag or number to run when the Actor is in Standby mode.
374-
actor_standby_memory_mbytes: The memory in megabytes to use when the Actor is in Standby mode.
375-
actor_standby_disable_standby_fields_override: If true, prevents the Standby configuration from being
376-
overridden elsewhere.
377-
actor_standby_should_pass_actor_input: Whether to pass the Actor input to the Standby runs. If false,
378-
the Standby runs start with no input.
406+
server_is_enabled: Whether the Actor is a Server Actor, which runs a web server called over HTTP.
407+
server_desired_requests_per_actor_run: The desired number of concurrent HTTP requests for a single run of
408+
the Server Actor.
409+
server_max_requests_per_actor_run: The maximum number of concurrent HTTP requests for a single run of the
410+
Server Actor.
411+
server_idle_timeout: If a run of the Server Actor does not receive any requests for this time, it is shut
412+
down.
413+
server_build: The build tag or number that the Server Actor runs.
414+
server_memory_mbytes: The memory in megabytes for the runs of the Server Actor.
415+
server_disable_fields_override: If true, prevents the Server Actor configuration from being overridden
416+
elsewhere.
417+
server_should_pass_actor_input: Whether to pass the Actor input to the runs of the Server Actor. If false,
418+
they start with no input.
379419
actor_permission_level: The permission level of the Actor on Apify platform.
380420
timeout: Timeout for the API HTTP request.
421+
actor_standby_is_enabled: Deprecated alias of `server_is_enabled`. Will be removed in v4.
422+
actor_standby_desired_requests_per_actor_run: Deprecated alias of `server_desired_requests_per_actor_run`.
423+
Will be removed in v4.
424+
actor_standby_max_requests_per_actor_run: Deprecated alias of `server_max_requests_per_actor_run`. Will be
425+
removed in v4.
426+
actor_standby_idle_timeout: Deprecated alias of `server_idle_timeout`. Will be removed in v4.
427+
actor_standby_build: Deprecated alias of `server_build`. Will be removed in v4.
428+
actor_standby_memory_mbytes: Deprecated alias of `server_memory_mbytes`. Will be removed in v4.
429+
actor_standby_disable_standby_fields_override: Deprecated alias of `server_disable_fields_override`. Will be
430+
removed in v4.
431+
actor_standby_should_pass_actor_input: Deprecated alias of `server_should_pass_actor_input`. Will be removed
432+
in v4.
381433
382434
Returns:
383435
The created Actor.
@@ -401,15 +453,27 @@ async def create(
401453
force_permission_level=default_run_force_permission_level,
402454
restart_on_error=restart_on_error,
403455
),
404-
actor_standby=ActorStandby(
405-
is_enabled=actor_standby_is_enabled,
406-
desired_requests_per_actor_run=actor_standby_desired_requests_per_actor_run,
407-
max_requests_per_actor_run=actor_standby_max_requests_per_actor_run,
408-
idle_timeout_secs=to_seconds(actor_standby_idle_timeout, as_int=True),
409-
build=actor_standby_build,
410-
memory_mbytes=actor_standby_memory_mbytes,
411-
disable_standby_fields_override=actor_standby_disable_standby_fields_override,
412-
should_pass_actor_input=actor_standby_should_pass_actor_input,
456+
actor_standby=build_actor_standby(
457+
{
458+
'server_is_enabled': server_is_enabled,
459+
'server_desired_requests_per_actor_run': server_desired_requests_per_actor_run,
460+
'server_max_requests_per_actor_run': server_max_requests_per_actor_run,
461+
'server_idle_timeout': server_idle_timeout,
462+
'server_build': server_build,
463+
'server_memory_mbytes': server_memory_mbytes,
464+
'server_disable_fields_override': server_disable_fields_override,
465+
'server_should_pass_actor_input': server_should_pass_actor_input,
466+
},
467+
{
468+
'actor_standby_is_enabled': actor_standby_is_enabled,
469+
'actor_standby_desired_requests_per_actor_run': actor_standby_desired_requests_per_actor_run,
470+
'actor_standby_max_requests_per_actor_run': actor_standby_max_requests_per_actor_run,
471+
'actor_standby_idle_timeout': actor_standby_idle_timeout,
472+
'actor_standby_build': actor_standby_build,
473+
'actor_standby_memory_mbytes': actor_standby_memory_mbytes,
474+
'actor_standby_disable_standby_fields_override': actor_standby_disable_standby_fields_override,
475+
'actor_standby_should_pass_actor_input': actor_standby_should_pass_actor_input,
476+
},
413477
),
414478
example_run_input=ExampleRunInput(
415479
body=example_run_input_body,

0 commit comments

Comments
 (0)