Skip to content

Commit 73c8a6e

Browse files
committed
New client commit
1 parent 421abf8 commit 73c8a6e

7 files changed

Lines changed: 23 additions & 19 deletions

File tree

src/apify/_actor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ async def start(
908908
content_type=content_type,
909909
build=build,
910910
memory_mbytes=memory_mbytes,
911-
timeout_secs=int(actor_start_timeout.total_seconds()) if actor_start_timeout is not None else None,
911+
timeout=actor_start_timeout,
912912
wait_for_finish=wait_for_finish,
913913
webhooks=serialized_webhooks,
914914
)
@@ -1033,9 +1033,9 @@ async def call(
10331033
content_type=content_type,
10341034
build=build,
10351035
memory_mbytes=memory_mbytes,
1036-
timeout_secs=int(actor_call_timeout.total_seconds()) if actor_call_timeout is not None else None,
1036+
timeout=actor_call_timeout,
10371037
webhooks=serialized_webhooks,
1038-
wait_secs=int(wait.total_seconds()) if wait is not None else None,
1038+
wait_duration=wait,
10391039
logger=logger,
10401040
)
10411041

@@ -1109,9 +1109,9 @@ async def call_task(
11091109
task_input=task_input,
11101110
build=build,
11111111
memory_mbytes=memory_mbytes,
1112-
timeout_secs=int(task_call_timeout.total_seconds()) if task_call_timeout is not None else None,
1112+
timeout=task_call_timeout,
11131113
webhooks=serialized_webhooks,
1114-
wait_secs=int(wait.total_seconds()) if wait is not None else None,
1114+
wait_duration=wait,
11151115
)
11161116

11171117
if run is None:

src/apify/storage_clients/_apify/_alias_resolving.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import logging
44
from asyncio import Lock
5+
from datetime import timedelta
56
from logging import getLogger
67
from typing import TYPE_CHECKING, ClassVar, Literal, overload
78

@@ -254,8 +255,8 @@ async def _get_default_kvs_client(configuration: Configuration) -> KeyValueStore
254255
token=configuration.token,
255256
api_url=configuration.api_base_url,
256257
max_retries=8,
257-
min_delay_between_retries_millis=500,
258-
timeout_secs=360,
258+
min_delay_between_retries=timedelta(milliseconds=500),
259+
timeout=timedelta(seconds=360),
259260
)
260261

261262
if not configuration.default_key_value_store_id:

src/apify/storage_clients/_apify/_api_client_creation.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from datetime import timedelta
34
from typing import TYPE_CHECKING, Literal, overload
45

56
from apify_client import ApifyClientAsync
@@ -177,6 +178,6 @@ def _create_api_client(configuration: Configuration) -> ApifyClientAsync:
177178
api_url=configuration.api_base_url,
178179
api_public_url=configuration.api_public_base_url,
179180
max_retries=8,
180-
min_delay_between_retries_millis=500,
181-
timeout_secs=360,
181+
min_delay_between_retries=timedelta(milliseconds=500),
182+
timeout=timedelta(seconds=360),
182183
)

src/apify/storage_clients/_apify/_request_queue_shared_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ async def _list_head(
432432

433433
# Otherwise fetch from API
434434
locked_queue_head = await self._api_client.list_and_lock_head(
435-
lock_secs=int(self._DEFAULT_LOCK_TIME.total_seconds()),
435+
lock_duration=self._DEFAULT_LOCK_TIME,
436436
limit=limit,
437437
)
438438

tests/e2e/conftest.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import subprocess
77
import sys
88
import textwrap
9+
from datetime import timedelta
910
from pathlib import Path
1011
from typing import TYPE_CHECKING, Any, Protocol
1112

@@ -306,7 +307,7 @@ async def _make_actor(
306307
name=actor_name,
307308
default_run_build='latest',
308309
default_run_memory_mbytes=memory_mbytes,
309-
default_run_timeout_secs=600,
310+
default_run_timeout=timedelta(seconds=600),
310311
versions=[
311312
{
312313
'versionNumber': '0.0',
@@ -322,7 +323,7 @@ async def _make_actor(
322323
print(f'Building Actor {actor_name}...')
323324
build_result = await actor_client.build(version_number='0.0')
324325
build_client = client.build(build_result.id)
325-
build_client_result = await build_client.wait_for_finish(wait_secs=600)
326+
build_client_result = await build_client.wait_for_finish(wait_duration=timedelta(seconds=600))
326327

327328
assert build_client_result is not None
328329
assert build_client_result.status.value == 'SUCCEEDED'
@@ -402,7 +403,7 @@ async def _run_actor(
402403
assert call_result is not None, 'Failed to start Actor run: missing run ID in the response.'
403404

404405
run_client = apify_client_async.run(call_result.id)
405-
client_actor_run = await run_client.wait_for_finish(wait_secs=600)
406+
client_actor_run = await run_client.wait_for_finish(wait_duration=timedelta(seconds=600))
406407

407408
assert client_actor_run is not None, 'Actor run did not finish successfully within the expected time.'
408409

tests/e2e/test_actor_api_helpers.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import asyncio
44
import json
5+
from datetime import timedelta
56
from typing import TYPE_CHECKING
67

78
from apify_client._models import ActorPermissionLevel
@@ -147,7 +148,7 @@ async def main_outer() -> None:
147148

148149
assert run_result_outer.status.value == 'SUCCEEDED'
149150

150-
await inner_actor.last_run().wait_for_finish(wait_secs=600)
151+
await inner_actor.last_run().wait_for_finish(wait_duration=timedelta(seconds=600))
151152

152153
inner_output_record = await inner_actor.last_run().key_value_store().get_record('OUTPUT')
153154
assert inner_output_record is not None
@@ -196,7 +197,7 @@ async def main_outer() -> None:
196197

197198
assert run_result_outer.status.value == 'SUCCEEDED'
198199

199-
await inner_actor.last_run().wait_for_finish(wait_secs=600)
200+
await inner_actor.last_run().wait_for_finish(wait_duration=timedelta(seconds=600))
200201

201202
inner_output_record = await inner_actor.last_run().key_value_store().get_record('OUTPUT')
202203
assert inner_output_record is not None
@@ -252,7 +253,7 @@ async def main_outer() -> None:
252253

253254
assert run_result_outer.status.value == 'SUCCEEDED'
254255

255-
await inner_actor.last_run().wait_for_finish(wait_secs=600)
256+
await inner_actor.last_run().wait_for_finish(wait_duration=timedelta(seconds=600))
256257

257258
inner_output_record = await inner_actor.last_run().key_value_store().get_record('OUTPUT')
258259
assert inner_output_record is not None
@@ -295,7 +296,7 @@ async def main_outer() -> None:
295296
assert run_result_outer.status.value == 'SUCCEEDED'
296297

297298
inner_actor_run_client = inner_actor.last_run()
298-
inner_actor_run = await inner_actor_run_client.wait_for_finish(wait_secs=600)
299+
inner_actor_run = await inner_actor_run_client.wait_for_finish(wait_duration=timedelta(seconds=600))
299300

300301
if inner_actor_run is None:
301302
raise AssertionError('Failed to get inner actor run after aborting it.')
@@ -477,7 +478,7 @@ async def main_client() -> None:
477478
assert ac_run_result.status.value == 'SUCCEEDED'
478479

479480
sa_run_client = server_actor.last_run()
480-
sa_run_client_run = await sa_run_client.wait_for_finish(wait_secs=600)
481+
sa_run_client_run = await sa_run_client.wait_for_finish(wait_duration=timedelta(seconds=600))
481482

482483
if sa_run_client_run is None:
483484
raise AssertionError('Failed to get server actor run after waiting for finish.')

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)