@@ -946,7 +946,7 @@ async def start(
946946 timeout : timedelta | Literal ['inherit' ] | None = None ,
947947 force_permission_level : ActorPermissionLevel | None = None ,
948948 webhooks : list [Webhook ] | None = None ,
949- name : str | None = None ,
949+ run_name : str | None = None ,
950950 ) -> Run :
951951 """Run an Actor on the Apify platform.
952952
@@ -973,12 +973,12 @@ async def start(
973973 webhooks: Optional ad-hoc webhooks (https://docs.apify.com/webhooks/ad-hoc-webhooks) associated with
974974 the Actor run which can be used to receive a notification, e.g. when the Actor finished or failed.
975975 If you already have a webhook set up for the Actor or task, you do not have to add it again here.
976- name : Optional name of the child run, unique within this Actor run. A named run is recorded in the
976+ run_name : Optional name of the child run, unique within this Actor run. A named run is recorded in the
977977 default key-value store, so after a migration or resurrection of this Actor the same call reattaches
978978 to the recorded run. A `SUCCEEDED` run is returned as is, an `ABORTED` or `TIMED-OUT` one is
979979 resurrected, and a new run is started only when nothing is recorded under the name, or the recorded
980980 run `FAILED` or no longer exists. The name is bound to `actor_id` exactly as passed, so reusing it with
981- any other value raises a `ValueError`.
981+ any other value, or for a task, raises a `ValueError`.
982982
983983 Returns:
984984 Info about the started Actor run
@@ -1008,11 +1008,11 @@ async def start(
10081008 webhooks = to_client_representations (webhooks ),
10091009 )
10101010
1011- if name is None :
1011+ if run_name is None :
10121012 return await start_run ()
10131013
10141014 run , _ = await self ._find_or_start_child_run (
1015- name ,
1015+ run_name ,
10161016 actor_id = actor_id ,
10171017 client = client ,
10181018 start_run = start_run ,
@@ -1078,7 +1078,7 @@ async def call(
10781078 webhooks : list [Webhook ] | None = None ,
10791079 wait : timedelta | None = None ,
10801080 logger : logging .Logger | Literal ['default' ] | None = 'default' ,
1081- name : str | None = None ,
1081+ run_name : str | None = None ,
10821082 ) -> Run :
10831083 """Start an Actor on the Apify Platform and wait for it to finish before returning.
10841084
@@ -1108,12 +1108,12 @@ async def call(
11081108 logger: Logger used to redirect logs from the Actor run. Using "default" literal means that a predefined
11091109 default logger will be used. Setting `None` will disable any log propagation. Passing custom logger
11101110 will redirect logs to the provided logger.
1111- name : Optional name of the child run, unique within this Actor run. A named run is recorded in the
1111+ run_name : Optional name of the child run, unique within this Actor run. A named run is recorded in the
11121112 default key-value store, so after a migration or resurrection of this Actor the same call reattaches
11131113 to the recorded run. A `SUCCEEDED` run is returned as is, an `ABORTED` or `TIMED-OUT` one is
11141114 resurrected, and a new run is started only when nothing is recorded under the name, or the recorded
11151115 run `FAILED` or no longer exists. The name is bound to `actor_id` exactly as passed, so reusing it with
1116- any other value raises a `ValueError`.
1116+ any other value, or for a task, raises a `ValueError`.
11171117
11181118 Returns:
11191119 Info about the started Actor run.
@@ -1131,7 +1131,7 @@ async def call(
11311131
11321132 actor_client = client .actor (actor_id )
11331133
1134- if name is None :
1134+ if run_name is None :
11351135 run = await actor_client .call (
11361136 run_input = run_input ,
11371137 content_type = content_type ,
@@ -1147,7 +1147,7 @@ async def call(
11471147 )
11481148 else :
11491149 started_run , is_new = await self ._find_or_start_child_run (
1150- name ,
1150+ run_name ,
11511151 actor_id = actor_id ,
11521152 client = client ,
11531153 start_run = partial (
@@ -1182,7 +1182,8 @@ async def _find_or_start_child_run(
11821182 self ,
11831183 name : str ,
11841184 * ,
1185- actor_id : str ,
1185+ actor_id : str | None = None ,
1186+ task_id : str | None = None ,
11861187 client : ApifyClientAsync ,
11871188 start_run : Callable [[], Awaitable [Run ]],
11881189 build : str | None ,
@@ -1194,6 +1195,7 @@ async def _find_or_start_child_run(
11941195 return await self ._child_run_registry .find_or_start (
11951196 name ,
11961197 actor_id = actor_id ,
1198+ task_id = task_id ,
11971199 client = client ,
11981200 start_run = start_run ,
11991201 resurrect_run = lambda run_client : run_client .resurrect (
@@ -1253,6 +1255,7 @@ async def call_task(
12531255 webhooks : list [Webhook ] | None = None ,
12541256 wait : timedelta | None = None ,
12551257 token : str | None = None ,
1258+ run_name : str | None = None ,
12561259 ) -> Run :
12571260 """Start an Actor task on the Apify Platform and wait for it to finish before returning.
12581261
@@ -1278,6 +1281,12 @@ async def call_task(
12781281 be used to receive a notification, e.g. when the Actor finished or failed. If you already have
12791282 a webhook set up for the Actor, you do not have to add it again here.
12801283 wait: The maximum time the server waits for the run to finish. If not provided, waits indefinitely.
1284+ run_name: Optional name of the child run, unique within this Actor run. A named run is recorded in the
1285+ default key-value store, so after a migration or resurrection of this Actor the same call reattaches
1286+ to the recorded run. A `SUCCEEDED` run is returned as is, an `ABORTED` or `TIMED-OUT` one is
1287+ resurrected, and a new run is started only when nothing is recorded under the name, or the recorded
1288+ run `FAILED` or no longer exists. The name is bound to `task_id` exactly as passed, so reusing it with
1289+ any other value, or for an Actor, raises a `ValueError`.
12811290
12821291 Returns:
12831292 Info about the started Actor run.
@@ -1294,15 +1303,40 @@ async def call_task(
12941303 raise ValueError (f'Invalid timeout { timeout !r} : expected `None`, `"inherit"`, or a `timedelta`.' )
12951304
12961305 task_client = client .task (task_id )
1297- run = await task_client .call (
1298- task_input = task_input ,
1299- build = build ,
1300- restart_on_error = restart_on_error ,
1301- memory_mbytes = memory_mbytes ,
1302- run_timeout = task_call_timeout ,
1303- webhooks = to_client_representations (webhooks ),
1304- wait_duration = wait ,
1305- )
1306+
1307+ if run_name is None :
1308+ run = await task_client .call (
1309+ task_input = task_input ,
1310+ build = build ,
1311+ restart_on_error = restart_on_error ,
1312+ memory_mbytes = memory_mbytes ,
1313+ run_timeout = task_call_timeout ,
1314+ webhooks = to_client_representations (webhooks ),
1315+ wait_duration = wait ,
1316+ )
1317+ else :
1318+ started_run , _ = await self ._find_or_start_child_run (
1319+ run_name ,
1320+ task_id = task_id ,
1321+ client = client ,
1322+ start_run = partial (
1323+ task_client .start ,
1324+ task_input = task_input ,
1325+ build = build ,
1326+ restart_on_error = restart_on_error ,
1327+ memory_mbytes = memory_mbytes ,
1328+ run_timeout = task_call_timeout ,
1329+ webhooks = to_client_representations (webhooks ),
1330+ ),
1331+ build = build ,
1332+ max_total_charge_usd = None ,
1333+ restart_on_error = restart_on_error ,
1334+ memory_mbytes = memory_mbytes ,
1335+ run_timeout = task_call_timeout ,
1336+ )
1337+ run = await self ._wait_for_child_run (
1338+ client .run (started_run .id ), started_run , wait = wait , logger = None , from_start = False
1339+ )
13061340
13071341 if run is None :
13081342 raise RuntimeError (f'Failed to call Task with ID "{ task_id } ".' )
0 commit comments