Skip to content

Commit 7a13809

Browse files
authored
fix: forward missing run kwargs in Actor.start/call/call_task (#906)
## Summary `ActorClient.call` (apify-client) exposes several run-configuration kwargs that the SDK wrapper `Actor.call` was silently dropping, forcing users to bypass the SDK and reach into `Actor.apify_client.actor(id).call(...)` (e.g. to set `max_total_charge_usd` for pay-per-event Actors — see the [user report](#)). This patch wires through the missing parameters so the SDK API matches the underlying client: - `Actor.start` / `Actor.call` — adds `max_items`, `max_total_charge_usd`, `restart_on_error`, `force_permission_level` - `Actor.call_task` — adds `max_items`, `restart_on_error` (the task endpoint has no `max_total_charge_usd` / `force_permission_level`) Docstrings updated to match. No change to existing kwargs or call semantics; pyproject `apify-client` constraint unchanged.
1 parent 6b393eb commit 7a13809

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

src/apify/_actor.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@
4242
if TYPE_CHECKING:
4343
import logging
4444
from collections.abc import Callable
45+
from decimal import Decimal
4546
from types import TracebackType
4647

4748
from typing_extensions import Self
4849

50+
from apify_shared.consts import ActorPermissionLevel
4951
from crawlee._types import JsonSerializable
5052
from crawlee.proxy_configuration import _NewUrlFunction
5153

@@ -863,8 +865,11 @@ async def start(
863865
token: str | None = None,
864866
content_type: str | None = None,
865867
build: str | None = None,
868+
max_total_charge_usd: Decimal | None = None,
869+
restart_on_error: bool | None = None,
866870
memory_mbytes: int | None = None,
867871
timeout: timedelta | None | Literal['inherit', 'RemainingTime'] = None,
872+
force_permission_level: ActorPermissionLevel | None = None,
868873
wait_for_finish: int | None = None,
869874
webhooks: list[Webhook] | None = None,
870875
) -> ActorRun:
@@ -879,11 +884,16 @@ async def start(
879884
content_type: The content type of the input.
880885
build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
881886
the run uses the build specified in the default run configuration for the Actor (typically latest).
887+
max_total_charge_usd: A limit on the total charged amount for pay-per-event Actors.
888+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
889+
a non-zero status code.
882890
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
883891
in the default run configuration for the Actor.
884892
timeout: Optional timeout for the run, in seconds. By default, the run uses timeout specified in
885893
the default run configuration for the Actor. Using `inherit` or `RemainingTime` will set timeout of the
886894
other Actor to the time remaining from this Actor timeout.
895+
force_permission_level: Override the Actor's permissions for this run. If not set, the Actor will run
896+
with permissions configured in the Actor settings.
887897
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
888898
it is 0, the maximum value is 300.
889899
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
@@ -923,8 +933,11 @@ async def start(
923933
run_input=run_input,
924934
content_type=content_type,
925935
build=build,
936+
max_total_charge_usd=max_total_charge_usd,
937+
restart_on_error=restart_on_error,
926938
memory_mbytes=memory_mbytes,
927939
timeout_secs=int(actor_start_timeout.total_seconds()) if actor_start_timeout is not None else None,
940+
force_permission_level=force_permission_level,
928941
wait_for_finish=wait_for_finish,
929942
webhooks=serialized_webhooks,
930943
)
@@ -973,8 +986,11 @@ async def call(
973986
token: str | None = None,
974987
content_type: str | None = None,
975988
build: str | None = None,
989+
max_total_charge_usd: Decimal | None = None,
990+
restart_on_error: bool | None = None,
976991
memory_mbytes: int | None = None,
977992
timeout: timedelta | None | Literal['inherit', 'RemainingTime'] = None,
993+
force_permission_level: ActorPermissionLevel | None = None,
978994
webhooks: list[Webhook] | None = None,
979995
wait: timedelta | None = None,
980996
logger: logging.Logger | None | Literal['default'] = 'default',
@@ -990,11 +1006,16 @@ async def call(
9901006
content_type: The content type of the input.
9911007
build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
9921008
the run uses the build specified in the default run configuration for the Actor (typically latest).
1009+
max_total_charge_usd: A limit on the total charged amount for pay-per-event Actors.
1010+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
1011+
a non-zero status code.
9931012
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
9941013
in the default run configuration for the Actor.
9951014
timeout: Optional timeout for the run, in seconds. By default, the run uses timeout specified in
9961015
the default run configuration for the Actor. Using `inherit` or `RemainingTime` will set timeout of the
9971016
other Actor to the time remaining from this Actor timeout.
1017+
force_permission_level: Override the Actor's permissions for this run. If not set, the Actor will run
1018+
with permissions configured in the Actor settings.
9981019
webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can
9991020
be used to receive a notification, e.g. when the Actor finished or failed. If you already have
10001021
a webhook set up for the Actor, you do not have to add it again here.
@@ -1038,8 +1059,11 @@ async def call(
10381059
run_input=run_input,
10391060
content_type=content_type,
10401061
build=build,
1062+
max_total_charge_usd=max_total_charge_usd,
1063+
restart_on_error=restart_on_error,
10411064
memory_mbytes=memory_mbytes,
10421065
timeout_secs=int(actor_call_timeout.total_seconds()) if actor_call_timeout is not None else None,
1066+
force_permission_level=force_permission_level,
10431067
webhooks=serialized_webhooks,
10441068
wait_secs=int(wait.total_seconds()) if wait is not None else None,
10451069
logger=logger,
@@ -1054,6 +1078,7 @@ async def call_task(
10541078
task_input: dict | None = None,
10551079
*,
10561080
build: str | None = None,
1081+
restart_on_error: bool | None = None,
10571082
memory_mbytes: int | None = None,
10581083
timeout: timedelta | None | Literal['inherit'] = None,
10591084
webhooks: list[Webhook] | None = None,
@@ -1074,6 +1099,8 @@ async def call_task(
10741099
content_type: The content type of the input.
10751100
build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
10761101
the run uses the build specified in the default run configuration for the Actor (typically latest).
1102+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
1103+
a non-zero status code.
10771104
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
10781105
in the default run configuration for the Actor.
10791106
timeout: Optional timeout for the run, in seconds. By default, the run uses timeout specified in
@@ -1109,6 +1136,7 @@ async def call_task(
11091136
api_result = await client.task(task_id).call(
11101137
task_input=task_input,
11111138
build=build,
1139+
restart_on_error=restart_on_error,
11121140
memory_mbytes=memory_mbytes,
11131141
timeout_secs=int(task_call_timeout.total_seconds()) if task_call_timeout is not None else None,
11141142
webhooks=serialized_webhooks,

0 commit comments

Comments
 (0)