You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3caaa2b
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: website/versioned_docs/version-3.1/02_concepts/11_timeouts.mdx
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ Every client method has a pre-assigned tier that matches the expected duration o
25
25
26
26
## Configuring default timeouts
27
27
28
-
You can override the default values for each tier in the <ApiLinkto="class/ApifyClient">`ApifyClient`</ApiLink> or <ApiLinkto="class/ApifyClientAsync">`ApifyClientAsync`</ApiLink> constructor. The `timeout_max` parameter sets an upper cap on the timeout for any individual API request, limiting exponential growth during retries.
28
+
You can override the default values for each tier in the <ApiLinkto="class/ApifyClient">`ApifyClient`</ApiLink> or <ApiLinkto="class/ApifyClientAsync">`ApifyClientAsync`</ApiLink> constructor. The `timeout_max` parameter sets an upper cap on the timeout for any individual API request, limiting exponential growth during retries. It caps tier and per-call timeouts as well, so raise it whenever you need a timeout longer than the default 360 seconds. A tier configured above the cap is capped too, and the client logs a warning to make the cut-off visible.
A `timedelta` longer than `timeout_max` is capped at `timeout_max`, and the client logs a warning. To let such a call use its full timeout, raise `timeout_max` in the client constructor.
61
+
60
62
## Interaction with retries
61
63
62
64
Timeouts work together with the [retry system](/api/client/python/docs/concepts/retries). When a request times out, it counts as a failed attempt and triggers a retry (up to `max_retries`). The timeout applies to each individual attempt, not the total time across all retries.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-3.1/02_concepts/12_typed_models.mdx
+44Lines changed: 44 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -36,6 +36,50 @@ Every method that returns a structured payload returns a Pydantic model. Fields
36
36
37
37
Date strings are automatically parsed into timezone-aware `datetime.datetime` objects, enums into `Literal` aliases, and nested objects into their own typed models, so you can compose attribute access without manual conversion.
38
38
39
+
## URL fields
40
+
41
+
Fields holding a URL, such as `Run.container_url` or `Dataset.console_url`, are typed as [`AnyUrl`](https://docs.pydantic.dev/latest/api/networks/#pydantic.networks.AnyUrl). Their values are validated and normalized, so the string you read back can differ from the one the API sent. Both forms denote the same URL under [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-6.2.3), they're just different strings.
Because of the normalization, compare URLs in their normalized form instead of as raw strings. `AnyUrl` compares the parsed URL, not the input text.
63
+
64
+
```python
65
+
run = client.run('my-run-id').get()
66
+
stored_url ='https://abc123.runs.apify.net'
67
+
68
+
# Wrong, compares a raw string with a normalized one.
69
+
stored_url ==str(run.container_url) # False
70
+
71
+
# Right, both sides are normalized before the comparison.
72
+
AnyUrl(stored_url) == run.container_url # True
73
+
```
74
+
75
+
To build a longer URL out of a URL field, use [`urljoin`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin) rather than string concatenation. It gives the same result whether or not the base ends with a slash.
A Pydantic model returned from one client call can be passed directly into any other method that accepts the same shape — useful for round-trip flows where you read a resource, tweak it, and write it back.
Copy file name to clipboardExpand all lines: website/versioned_docs/version-3.1/04_upgrading/upgrading_to_v3.mdx
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,6 +30,27 @@ Two endpoints still return plain types because their payloads are user-defined:
30
30
31
31
On the input side, methods now also accept Pydantic models in addition to dicts. Plain dicts continue to work — keys may use either snake_case or camelCase, and each input shape has a matching [`TypedDict`](https://docs.python.org/3/library/typing.html#typing.TypedDict) so editors and type checkers can validate the keys. See [Typed models](/api/client/python/docs/concepts/typed-models) for details.
32
32
33
+
## URL fields are normalized
34
+
35
+
URL fields on the returned models are typed as [`AnyUrl`](https://docs.pydantic.dev/latest/api/networks/#pydantic.networks.AnyUrl), which normalizes the value during validation. In v2 the client handed back the raw string from the API. In v3 the string can differ, most visibly by an added trailing slash. Normalization also lowercases the host, drops default ports, punycodes internationalized hosts, and percent-encodes unsafe characters.
36
+
37
+
Code that compares a stored URL with a URL field has to compare normalized values.
38
+
39
+
```python
40
+
from pydantic import AnyUrl
41
+
42
+
run = client.run('my-run-id').get()
43
+
stored_url ='https://abc123.runs.apify.net'
44
+
45
+
# Before, the raw string matched the API response.
46
+
stored_url ==str(run.container_url) # False in v3
47
+
48
+
# After, normalize both sides before comparing.
49
+
AnyUrl(stored_url) == run.container_url # True
50
+
```
51
+
52
+
The affected fields are `container_url`, `console_url`, `standby_url`, `request_url`, `url`, `picture_url`, `user_picture_url`, `website_url`, and the `*_public_url` fields on storage models. To build longer URLs out of them, use [`urljoin`](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urljoin) instead of string concatenation. For details, see [Typed models](/api/client/python/docs/concepts/typed-models#url-fields).
53
+
33
54
## Tiered timeouts
34
55
35
56
The single global timeout has been replaced by four tiers — `short` (5 s), `medium` (30 s), `long` (360 s), and `no_timeout`. Each method picks an appropriate default. Override per call, or change tier defaults on the constructor:
0 commit comments