Skip to content

Commit 9c44f3b

Browse files
committed
New client commit
1 parent 80f5b03 commit 9c44f3b

File tree

12 files changed

+164
-94
lines changed

12 files changed

+164
-94
lines changed

src/apify/_models.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from pydantic import BaseModel, BeforeValidator, ConfigDict, Field
77

88
from apify_client._models import ActorJobStatus, Run
9-
from crawlee._utils.models import timedelta_ms
109
from crawlee._utils.urls import validate_http_url
1110

1211
from apify._utils import docs_group
@@ -48,8 +47,6 @@ class WebhookStats(BaseModel):
4847

4948
total_dispatches: Annotated[int, Field(alias='totalDispatches')]
5049

51-
from apify_client._models import Run
52-
5350

5451
@docs_group('Actor')
5552
class Webhook(BaseModel):

tests/e2e/conftest.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from filelock import FileLock
1515

1616
from apify_client import ApifyClient, ApifyClientAsync
17-
from apify_client._models import ActorJobStatus, ActorPermissionLevel, VersionSourceType
17+
from apify_client._models import ActorPermissionLevel, VersionSourceType
1818
from apify_shared.consts import ApifyEnvVars
1919
from crawlee import service_locator
2020

@@ -49,7 +49,9 @@ def apify_client_async(apify_token: str) -> ApifyClientAsync:
4949
"""Create an instance of the ApifyClientAsync."""
5050
api_url = os.getenv(_API_URL_ENV_VAR)
5151

52-
return ApifyClientAsync(apify_token, api_url=api_url)
52+
if api_url is not None:
53+
return ApifyClientAsync(apify_token, api_url=api_url)
54+
return ApifyClientAsync(apify_token)
5355

5456

5557
@pytest.fixture

tests/e2e/test_actor_request_queue.py

Lines changed: 6 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
45

56
from apify import Actor
@@ -32,14 +33,17 @@ async def main() -> None:
3233
actor = await make_actor(label='rq-clients-resurrection', main_func=main)
3334
run_result = await run_actor(actor)
3435
assert run_result.status == 'SUCCEEDED'
35-
3636
# Resurrect the run, the RequestQueue should still use same client key and thus not have multiple clients.
3737
run_client = apify_client_async.run(run_id=run_result.id)
3838
# Redirect logs even from the resurrected run
3939
streamed_log = await run_client.get_streamed_log(from_start=False)
4040
await run_client.resurrect()
41+
4142
async with streamed_log:
42-
run_result = ActorRun.model_validate(await run_client.wait_for_finish(wait_secs=600))
43+
raw_run_result = await run_client.wait_for_finish(wait_duration=timedelta(seconds=600))
44+
assert raw_run_result is not None
45+
46+
run_result = ActorRun.from_client_actor_run(raw_run_result)
4347
assert run_result.status == 'SUCCEEDED'
4448

4549

tests/e2e/test_crawlee/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from typing import TYPE_CHECKING
66

77
if TYPE_CHECKING:
8-
from apify_client.clients.resource_clients import ActorClientAsync
8+
from apify_client._resource_clients import ActorClientAsync
99

1010
from apify._models import ActorRun
1111

tests/e2e/test_scrapy/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from typing import TYPE_CHECKING
55

66
if TYPE_CHECKING:
7-
from apify_client.clients.resource_clients import ActorClientAsync
7+
from apify_client._resource_clients import ActorClientAsync
88

99
from apify._models import ActorRun
1010

tests/integration/test_dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ async def test_force_cloud(
117117
try:
118118
dataset_details = await dataset_client.get()
119119
assert dataset_details is not None
120-
assert dataset_details.get('name') == dataset_name
120+
assert dataset_details.name == dataset_name
121121

122122
dataset_items = await dataset_client.list_items()
123123
assert dataset_items.items == [dataset_item]

tests/integration/test_key_value_store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ async def test_force_cloud(
156156
try:
157157
key_value_store_details = await key_value_store_client.get()
158158
assert key_value_store_details is not None
159-
assert key_value_store_details.get('name') == key_value_store_name
159+
assert key_value_store_details.name == key_value_store_name
160160

161161
key_value_store_record = await key_value_store_client.get_record('foo')
162162
assert key_value_store_record is not None

tests/integration/test_request_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ async def test_request_deduplication_edge_cases(
703703
"""Test edge cases in request deduplication."""
704704
rq_access_mode = request.node.callspec.params.get('request_queue_apify')
705705
if rq_access_mode == 'shared':
706-
pytest.skip(reason='Test is flaky, see https://github.com/apify/apify-sdk-python/issues/786') # ty: ignore[invalid-argument-type, parameter-already-assigned]
706+
pytest.skip(reason='Test is flaky, see https://github.com/apify/apify-sdk-python/issues/786')
707707

708708
rq = request_queue_apify
709709
Actor.log.info('Request queue opened')

tests/unit/actor/test_actor_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ async def test_remote_method_with_timedelta_timeout(
267267
calls = apify_client_async_patcher.calls[client_resource][client_method]
268268
assert len(calls) == 1
269269
_, kwargs = calls[0][0], calls[0][1]
270-
assert kwargs.get('timeout_secs') == 120
270+
assert kwargs.get('timeout') == timedelta(seconds=120)
271271

272272

273273
async def test_call_actor_with_remaining_time_deprecation(

tests/unit/actor/test_actor_lifecycle.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ async def handler(websocket: websockets.asyncio.server.ServerConnection) -> None
302302
assert event_data == EventPersistStateData(is_migrating=False)
303303

304304

305-
306305
async def test_actor_fail_prevents_further_execution(caplog: pytest.LogCaptureFixture) -> None:
307306
"""Test that calling Actor.fail() prevents further code execution in the Actor context."""
308307
caplog.set_level(logging.INFO)

0 commit comments

Comments
 (0)