Skip to content

Commit 6211639

Browse files
committed
fix: forward missing run kwargs in Actor.start/call/call_task
Align the SDK wrappers with `apify-client`: pass through `max_items`, `max_total_charge_usd`, `restart_on_error`, and `force_permission_level` so users no longer have to drop down to the raw client to set them.
1 parent 6d86e27 commit 6211639

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

src/apify/_actor.py

Lines changed: 40 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,12 @@ async def start(
863865
token: str | None = None,
864866
content_type: str | None = None,
865867
build: str | None = None,
868+
max_items: int | None = None,
869+
max_total_charge_usd: Decimal | None = None,
870+
restart_on_error: bool | None = None,
866871
memory_mbytes: int | None = None,
867872
timeout: timedelta | None | Literal['inherit', 'RemainingTime'] = None,
873+
force_permission_level: ActorPermissionLevel | None = None,
868874
wait_for_finish: int | None = None,
869875
webhooks: list[Webhook] | None = None,
870876
) -> ActorRun:
@@ -879,11 +885,18 @@ async def start(
879885
content_type: The content type of the input.
880886
build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
881887
the run uses the build specified in the default run configuration for the Actor (typically latest).
888+
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
889+
per result, you will not be charged for more results than the given limit.
890+
max_total_charge_usd: A limit on the total charged amount for pay-per-event Actors.
891+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
892+
a non-zero status code.
882893
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
883894
in the default run configuration for the Actor.
884895
timeout: Optional timeout for the run, in seconds. By default, the run uses timeout specified in
885896
the default run configuration for the Actor. Using `inherit` or `RemainingTime` will set timeout of the
886897
other Actor to the time remaining from this Actor timeout.
898+
force_permission_level: Override the Actor's permissions for this run. If not set, the Actor will run
899+
with permissions configured in the Actor settings.
887900
wait_for_finish: The maximum number of seconds the server waits for the run to finish. By default,
888901
it is 0, the maximum value is 300.
889902
webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
@@ -923,8 +936,12 @@ async def start(
923936
run_input=run_input,
924937
content_type=content_type,
925938
build=build,
939+
max_items=max_items,
940+
max_total_charge_usd=max_total_charge_usd,
941+
restart_on_error=restart_on_error,
926942
memory_mbytes=memory_mbytes,
927943
timeout_secs=int(actor_start_timeout.total_seconds()) if actor_start_timeout is not None else None,
944+
force_permission_level=force_permission_level,
928945
wait_for_finish=wait_for_finish,
929946
webhooks=serialized_webhooks,
930947
)
@@ -973,8 +990,12 @@ async def call(
973990
token: str | None = None,
974991
content_type: str | None = None,
975992
build: str | None = None,
993+
max_items: int | None = None,
994+
max_total_charge_usd: Decimal | None = None,
995+
restart_on_error: bool | None = None,
976996
memory_mbytes: int | None = None,
977997
timeout: timedelta | None | Literal['inherit', 'RemainingTime'] = None,
998+
force_permission_level: ActorPermissionLevel | None = None,
978999
webhooks: list[Webhook] | None = None,
9791000
wait: timedelta | None = None,
9801001
logger: logging.Logger | None | Literal['default'] = 'default',
@@ -990,11 +1011,18 @@ async def call(
9901011
content_type: The content type of the input.
9911012
build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
9921013
the run uses the build specified in the default run configuration for the Actor (typically latest).
1014+
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
1015+
per result, you will not be charged for more results than the given limit.
1016+
max_total_charge_usd: A limit on the total charged amount for pay-per-event Actors.
1017+
restart_on_error: If true, the Actor run process will be restarted whenever it exits with
1018+
a non-zero status code.
9931019
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
9941020
in the default run configuration for the Actor.
9951021
timeout: Optional timeout for the run, in seconds. By default, the run uses timeout specified in
9961022
the default run configuration for the Actor. Using `inherit` or `RemainingTime` will set timeout of the
9971023
other Actor to the time remaining from this Actor timeout.
1024+
force_permission_level: Override the Actor's permissions for this run. If not set, the Actor will run
1025+
with permissions configured in the Actor settings.
9981026
webhooks: Optional webhooks (https://docs.apify.com/webhooks) associated with the Actor run, which can
9991027
be used to receive a notification, e.g. when the Actor finished or failed. If you already have
10001028
a webhook set up for the Actor, you do not have to add it again here.
@@ -1038,8 +1066,12 @@ async def call(
10381066
run_input=run_input,
10391067
content_type=content_type,
10401068
build=build,
1069+
max_items=max_items,
1070+
max_total_charge_usd=max_total_charge_usd,
1071+
restart_on_error=restart_on_error,
10411072
memory_mbytes=memory_mbytes,
10421073
timeout_secs=int(actor_call_timeout.total_seconds()) if actor_call_timeout is not None else None,
1074+
force_permission_level=force_permission_level,
10431075
webhooks=serialized_webhooks,
10441076
wait_secs=int(wait.total_seconds()) if wait is not None else None,
10451077
logger=logger,
@@ -1054,6 +1086,8 @@ async def call_task(
10541086
task_input: dict | None = None,
10551087
*,
10561088
build: str | None = None,
1089+
max_items: int | None = None,
1090+
restart_on_error: bool | None = None,
10571091
memory_mbytes: int | None = None,
10581092
timeout: timedelta | None | Literal['inherit'] = None,
10591093
webhooks: list[Webhook] | None = None,
@@ -1074,6 +1108,10 @@ async def call_task(
10741108
content_type: The content type of the input.
10751109
build: Specifies the Actor build to run. It can be either a build tag or build number. By default,
10761110
the run uses the build specified in the default run configuration for the Actor (typically latest).
1111+
max_items: Maximum number of results that will be returned by this run. If the Actor is charged
1112+
per result, you will not be charged for more results than the given limit.
1113+
restart_on_error: If true, the Task run process will be restarted whenever it exits with
1114+
a non-zero status code.
10771115
memory_mbytes: Memory limit for the run, in megabytes. By default, the run uses a memory limit specified
10781116
in the default run configuration for the Actor.
10791117
timeout: Optional timeout for the run, in seconds. By default, the run uses timeout specified in
@@ -1109,6 +1147,8 @@ async def call_task(
11091147
api_result = await client.task(task_id).call(
11101148
task_input=task_input,
11111149
build=build,
1150+
max_items=max_items,
1151+
restart_on_error=restart_on_error,
11121152
memory_mbytes=memory_mbytes,
11131153
timeout_secs=int(task_call_timeout.total_seconds()) if task_call_timeout is not None else None,
11141154
webhooks=serialized_webhooks,

0 commit comments

Comments
 (0)