Skip to content

Commit 9cc1438

Browse files
committed
resolve
2 parents 94977d2 + b880231 commit 9cc1438

File tree

15 files changed

+36
-62
lines changed

15 files changed

+36
-62
lines changed

src/apify_client/_http_client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@
1313
import impit
1414
from apify_shared.utils import ignore_docs
1515

16-
from apify_client._errors import ApifyApiError, is_retryable_error
1716
from apify_client._logging import log_context, logger_name
1817
from apify_client._statistics import Statistics
19-
from apify_client._utils import retry_with_exp_backoff, retry_with_exp_backoff_async
18+
from apify_client._utils import is_retryable_error, retry_with_exp_backoff, retry_with_exp_backoff_async
19+
from apify_client.errors import ApifyApiError
2020

2121
if TYPE_CHECKING:
2222
from collections.abc import Callable

src/apify_client/_utils.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from http import HTTPStatus
1010
from typing import TYPE_CHECKING, Any, TypeVar, cast
1111

12+
import impit
1213
from apify_shared.utils import (
1314
is_content_type_json,
1415
is_content_type_text,
@@ -17,14 +18,14 @@
1718
maybe_extract_enum_member_value,
1819
)
1920

20-
from apify_client._errors import InvalidResponseBodyError
21+
from apify_client.errors import InvalidResponseBodyError
2122

2223
if TYPE_CHECKING:
2324
from collections.abc import Awaitable
2425

2526
from impit import Response
2627

27-
from apify_client._errors import ApifyApiError
28+
from apify_client.errors import ApifyApiError
2829

2930
PARSE_DATE_FIELDS_MAX_DEPTH = 3
3031
PARSE_DATE_FIELDS_KEY_SUFFIX = 'At'
@@ -180,3 +181,16 @@ def maybe_parse_response(response: Response) -> Any:
180181
raise InvalidResponseBodyError(response) from err
181182
else:
182183
return response_data
184+
185+
186+
def is_retryable_error(exc: Exception) -> bool:
187+
"""Check if the given error is retryable."""
188+
return isinstance(
189+
exc,
190+
(
191+
InvalidResponseBodyError,
192+
impit.NetworkError,
193+
impit.TimeoutException,
194+
impit.RemoteProtocolError,
195+
),
196+
)

src/apify_client/clients/base/actor_job_base_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
from apify_shared.consts import ActorJobStatus
1010
from apify_shared.utils import ignore_docs, parse_date_fields
1111

12-
from apify_client._errors import ApifyApiError
1312
from apify_client._utils import catch_not_found_or_throw, pluck_data
1413
from apify_client.clients.base.resource_client import ResourceClient, ResourceClientAsync
14+
from apify_client.errors import ApifyApiError
1515

1616
DEFAULT_WAIT_FOR_FINISH_SEC = 999999
1717

src/apify_client/clients/base/resource_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44

55
from apify_shared.utils import ignore_docs, parse_date_fields
66

7-
from apify_client._errors import ApifyApiError
87
from apify_client._utils import catch_not_found_or_throw, pluck_data
98
from apify_client.clients.base.base_client import BaseClient, BaseClientAsync
9+
from apify_client.errors import ApifyApiError
1010

1111

1212
@ignore_docs

src/apify_client/clients/resource_clients/dataset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
from apify_shared.models import ListPage
99
from apify_shared.utils import filter_out_none_values_recursively, ignore_docs
1010

11-
from apify_client._errors import ApifyApiError
1211
from apify_client._utils import catch_not_found_or_throw, pluck_data
1312
from apify_client.clients.base import ResourceClient, ResourceClientAsync
13+
from apify_client.errors import ApifyApiError
1414

1515
if TYPE_CHECKING:
1616
from collections.abc import AsyncIterator, Iterator

src/apify_client/clients/resource_clients/key_value_store.py

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
from __future__ import annotations
22

33
import json as jsonlib
4-
import warnings
54
from contextlib import asynccontextmanager, contextmanager
65
from http import HTTPStatus
76
from typing import TYPE_CHECKING, Any
87

98
from apify_shared.utils import filter_out_none_values_recursively, ignore_docs, parse_date_fields
109

11-
from apify_client._errors import ApifyApiError
1210
from apify_client._utils import (
1311
catch_not_found_or_throw,
1412
encode_key_value_store_record_value,
1513
maybe_parse_response,
1614
pluck_data,
1715
)
1816
from apify_client.clients.base import ResourceClient, ResourceClientAsync
17+
from apify_client.errors import ApifyApiError
1918

2019
if TYPE_CHECKING:
2120
from collections.abc import AsyncIterator, Iterator
@@ -107,43 +106,18 @@ def list_keys(
107106

108107
return parse_date_fields(pluck_data(jsonlib.loads(response.text)))
109108

110-
def get_record(self, key: str, *, as_bytes: bool = False, as_file: bool = False) -> dict | None:
109+
def get_record(self, key: str) -> dict | None:
111110
"""Retrieve the given record from the key-value store.
112111
113112
https://docs.apify.com/api/v2#/reference/key-value-stores/record/get-record
114113
115114
Args:
116115
key: Key of the record to retrieve.
117-
as_bytes: Deprecated, use `get_record_as_bytes()` instead. Whether to retrieve the record as raw bytes,
118-
default False.
119-
as_file: Deprecated, use `stream_record()` instead. Whether to retrieve the record as a file-like object,
120-
default False.
121116
122117
Returns:
123118
The requested record, or None, if the record does not exist.
124119
"""
125120
try:
126-
if as_bytes and as_file:
127-
raise ValueError('You cannot have both as_bytes and as_file set.')
128-
129-
if as_bytes:
130-
warnings.warn(
131-
'`KeyValueStoreClient.get_record(..., as_bytes=True)` is deprecated, '
132-
'use `KeyValueStoreClient.get_record_as_bytes()` instead.',
133-
DeprecationWarning,
134-
stacklevel=2,
135-
)
136-
return self.get_record_as_bytes(key)
137-
138-
if as_file:
139-
warnings.warn(
140-
'`KeyValueStoreClient.get_record(..., as_file=True)` is deprecated, '
141-
'use `KeyValueStoreClient.stream_record()` instead.',
142-
DeprecationWarning,
143-
stacklevel=2,
144-
)
145-
return self.stream_record(key) # type: ignore[return-value]
146-
147121
response = self.http_client.call(
148122
url=self._url(f'records/{key}'),
149123
method='GET',
@@ -380,10 +354,6 @@ async def get_record(self, key: str) -> dict | None:
380354
381355
Args:
382356
key: Key of the record to retrieve.
383-
as_bytes: Deprecated, use `get_record_as_bytes()` instead. Whether to retrieve the record as raw bytes,
384-
default False.
385-
as_file: Deprecated, use `stream_record()` instead. Whether to retrieve the record as a file-like object,
386-
default False.
387357
388358
Returns:
389359
The requested record, or None, if the record does not exist.

src/apify_client/clients/resource_clients/log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313

1414
from apify_shared.utils import ignore_docs
1515

16-
from apify_client._errors import ApifyApiError
1716
from apify_client._utils import catch_not_found_or_throw
1817
from apify_client.clients.base import ResourceClient, ResourceClientAsync
18+
from apify_client.errors import ApifyApiError
1919

2020
if TYPE_CHECKING:
2121
from collections.abc import AsyncIterator, Iterator

src/apify_client/clients/resource_clients/request_queue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from apify_shared.utils import filter_out_none_values_recursively, ignore_docs, parse_date_fields
1212
from more_itertools import constrained_batches
1313

14-
from apify_client._errors import ApifyApiError
1514
from apify_client._utils import catch_not_found_or_throw, pluck_data
1615
from apify_client.clients.base import ResourceClient, ResourceClientAsync
16+
from apify_client.errors import ApifyApiError
1717

1818
if TYPE_CHECKING:
1919
from datetime import timedelta

src/apify_client/clients/resource_clients/schedule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
from apify_shared.utils import filter_out_none_values_recursively, ignore_docs
77

8-
from apify_client._errors import ApifyApiError
98
from apify_client._utils import catch_not_found_or_throw, pluck_data_as_list
109
from apify_client.clients.base import ResourceClient, ResourceClientAsync
10+
from apify_client.errors import ApifyApiError
1111

1212

1313
def _get_schedule_representation(

src/apify_client/clients/resource_clients/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
parse_date_fields,
1111
)
1212

13-
from apify_client._errors import ApifyApiError
1413
from apify_client._utils import catch_not_found_or_throw, encode_webhook_list_to_base64, pluck_data
1514
from apify_client.clients.base import ResourceClient, ResourceClientAsync
1615
from apify_client.clients.resource_clients.run import RunClient, RunClientAsync
@@ -19,6 +18,7 @@
1918
WebhookCollectionClient,
2019
WebhookCollectionClientAsync,
2120
)
21+
from apify_client.errors import ApifyApiError
2222

2323
if TYPE_CHECKING:
2424
from apify_shared.consts import ActorJobStatus, MetaOrigin

0 commit comments

Comments
 (0)