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 5659c0e
Browse filesBrowse the repository at this point in the historyBrowse files
BODY="This PR updates the auto-generated Pydantic models based on OpenAPI specification changes in [apify-docs PR #${DOCS_PR_NUMBER}](${DOCS_PR_URL})."
133
+
BODY="This PR updates the auto-generated Pydantic models and TypedDicts based on OpenAPI specification changes in [apify-docs PR #${DOCS_PR_NUMBER}](${DOCS_PR_URL})."
134
134
else
135
-
BODY="This PR updates the auto-generated Pydantic models from the [published OpenAPI specification](https://docs.apify.com/api/openapi.json)."
135
+
BODY="This PR updates the auto-generated Pydantic models and TypedDicts from the [published OpenAPI specification](https://docs.apify.com/api/openapi.json)."
COMMENT="A PR to update the Python client models has been created: ${PR_URL}
160
+
MENTION=""
161
+
if [[ -n "$DOCS_PR_AUTHOR" ]]; then
162
+
MENTION="@${DOCS_PR_AUTHOR} "
163
+
fi
161
164
162
-
This was automatically triggered by OpenAPI specification changes in this PR."
165
+
if [[ "$PR_CREATED" = "true" ]]; then
166
+
HEADLINE="A companion PR has been opened in \`apify-client-python\` with the regenerated models: ${PR_URL}"
163
167
else
164
-
COMMENT="The Python client model PR has been updated with the latest OpenAPI spec changes: ${PR_URL}"
168
+
HEADLINE="The companion \`apify-client-python\` PR has been updated with the latest spec changes: ${PR_URL}"
165
169
fi
166
170
171
+
COMMENT=$(printf '%s\n' \
172
+
"> [!IMPORTANT]" \
173
+
"> **Action required** — ${MENTION}please coordinate this docs PR with the Python API client PR linked below." \
174
+
">" \
175
+
"> Because this PR modifies the OpenAPI specification, the generated models in \`apify-client-python\` must be regenerated to stay in sync. This has already been done automatically:" \
176
+
">" \
177
+
"> ${HEADLINE}" \
178
+
">" \
179
+
"> - Please make sure to review and merge both PRs together to keep the OpenAPI spec and API clients in sync." \
180
+
"> - You can ask for review and help from the Tooling team if needed.")
Copy file name to clipboardExpand all lines: .rules.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ uv run poe type-check # Run ty type checker
19
19
uv run poe unit-tests # Run unit tests
20
20
uv run poe check-docstrings # Verify async docstrings match sync
21
21
uv run poe fix-docstrings # Auto-fix async docstrings
22
-
uv run poe generate-models # Regenerate _models.py from live OpenAPI spec
22
+
uv run poe generate-models # Regenerate _models_generated.py and _typeddicts_generated.py from live OpenAPI spec
23
23
uv run poe generate-models-from-file <path># Regenerate from a local OpenAPI spec file
24
24
25
25
# Run a single test
@@ -73,7 +73,7 @@ Docstrings are written on sync clients and **automatically copied** to async cli
73
73
74
74
### Data Models
75
75
76
-
`src/apify_client/_models.py`is **auto-generated** — do not edit it manually.
76
+
`src/apify_client/_models_generated.py`and `src/apify_client/_typeddicts_generated.py` are **auto-generated** — do not edit them manually. The hand-maintained `src/apify_client/_models.py` and `src/apify_client/_typeddicts.py` hold only shapes that are not exposed by the OpenAPI spec (or that need local logic); import generated types directly from the `_*_generated` modules.
77
77
78
78
- Generated by `datamodel-code-generator` from the OpenAPI spec at `https://docs.apify.com/api/openapi.json` (config in `pyproject.toml` under `[tool.datamodel-codegen]`, aliases in `datamodel_codegen_aliases.json`)
79
79
- After generation, `scripts/postprocess_generated_models.py` is run to apply additional fixes
Copy file name to clipboardExpand all lines: CHANGELOG.md
+6Lines changed: 6 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,11 +12,17 @@ All notable changes to this project will be documented in this file.
12
12
- Accept Pydantic models as alternatives to dicts in resource client methods ([#663](https://github.com/apify/apify-client-python/pull/663)) ([b778c20](https://github.com/apify/apify-client-python/commit/b778c2040228ff9f5a97765de10535cec3f0353e)) by [@vdusek](https://github.com/vdusek), closes [#421](https://github.com/apify/apify-client-python/issues/421)
13
13
- Add ownership parameter to storage collection listing methods ([#696](https://github.com/apify/apify-client-python/pull/696)) ([51a92a3](https://github.com/apify/apify-client-python/commit/51a92a31dac5dd433acfaea76155011d0892d8c8)) by [@nmanerikar](https://github.com/nmanerikar)
14
14
- Add filter and cursor parameters to list_requests method ([#743](https://github.com/apify/apify-client-python/pull/743)) ([3445ff7](https://github.com/apify/apify-client-python/commit/3445ff74e61d5f1f9a964f2ee3c14d198298f709)) by [@mvolfik](https://github.com/mvolfik)
15
+
- Add ApifyApiError subclasses grouped by HTTP status ([#737](https://github.com/apify/apify-client-python/pull/737)) ([a6daff7](https://github.com/apify/apify-client-python/commit/a6daff754e5e1af8a6230f4c504db24a246c734f)) by [@vdusek](https://github.com/vdusek)
16
+
- Generate TypedDict types for input-side models ([#738](https://github.com/apify/apify-client-python/pull/738)) ([2fd66d0](https://github.com/apify/apify-client-python/commit/2fd66d0adf253dff470f40d0bfdbc620da0ed608)) by [@vdusek](https://github.com/vdusek), closes [#666](https://github.com/apify/apify-client-python/issues/666)
15
17
16
18
### 🐛 Bug Fixes
17
19
18
20
- Guard integration test resource names against 63-char API limit ([#729](https://github.com/apify/apify-client-python/pull/729)) ([47a7a69](https://github.com/apify/apify-client-python/commit/47a7a6967e28c7042fa8e75cd4c138356495fa2c)) by [@vdusek](https://github.com/vdusek)
19
21
- Prevent `_prepare_request_call` from mutating caller's headers dict ([#746](https://github.com/apify/apify-client-python/pull/746)) ([d553162](https://github.com/apify/apify-client-python/commit/d5531621535f5a491be5b5791ea4b80e46de1405)) by [@vdusek](https://github.com/vdusek)
22
+
- Don't block StatusMessageWatcher exit with 6s sleep on exception ([#753](https://github.com/apify/apify-client-python/pull/753)) ([48f5037](https://github.com/apify/apify-client-python/commit/48f50378e92e2058ff8e5aaba45ef9e3a6e5f081)) by [@vdusek](https://github.com/vdusek)
23
+
- Treat naive datetime query params as UTC ([#752](https://github.com/apify/apify-client-python/pull/752)) ([9ab096a](https://github.com/apify/apify-client-python/commit/9ab096a7453080a3079c7459079f99a30bd6a7cb)) by [@vdusek](https://github.com/vdusek)
24
+
- Raise NotFoundError on ambiguous 404 responses ([#755](https://github.com/apify/apify-client-python/pull/755)) ([701185e](https://github.com/apify/apify-client-python/commit/701185e6e8a98f0b14d83cab10139f1e19be3f47)) by [@vdusek](https://github.com/vdusek)
25
+
- Correct deadline logic in _wait_for_finish ([#749](https://github.com/apify/apify-client-python/pull/749)) ([fd0663e](https://github.com/apify/apify-client-python/commit/fd0663e22b31ddd289325146c9750ff07c068d6b)) by [@vdusek](https://github.com/vdusek)
Copy file name to clipboardExpand all lines: docs/04_upgrading/upgrading_to_v3.mdx
+65-2Lines changed: 65 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -55,7 +55,7 @@ run.status
55
55
Models also use `populate_by_name=True`, which means you can use either the Python field name or the camelCase alias when **constructing** a model:
56
56
57
57
```python
58
-
from apify_client._modelsimport Run
58
+
from apify_client._models_generatedimport Run
59
59
60
60
# Both work when constructing models
61
61
Run(default_dataset_id='abc') # Python field name
@@ -86,7 +86,7 @@ rq_client.add_request({
86
86
After (v3) — both forms are accepted:
87
87
88
88
```python
89
-
from apify_client._typesimport RequestInput
89
+
from apify_client._modelsimport RequestInput
90
90
91
91
# Option 1: dict (still works)
92
92
rq_client.add_request({
@@ -186,6 +186,69 @@ The default timeout tier assigned to each method on non-storage resource clients
186
186
187
187
If your code relied on the previous global timeout behavior, review the timeout tier on the methods you use and adjust via the `timeout` parameter or by overriding tier defaults on the <ApiLinkto="class/ApifyClient">`ApifyClient`</ApiLink> constructor (see [Tiered timeout system](#tiered-timeout-system) above).
188
188
189
+
## Exception subclasses for API errors
190
+
191
+
<ApiLinkto="class/ApifyApiError">`ApifyApiError`</ApiLink> now dispatches to a dedicated subclass based on the HTTP status code of the failed response. Instantiating `ApifyApiError` directly still works — it returns the most specific subclass for the status — so existing `except ApifyApiError` handlers are unaffected.
You can now branch on error kind without inspecting `status_code` or `type`:
206
+
207
+
```python
208
+
from apify_client import ApifyClient
209
+
from apify_client.errors import NotFoundError, RateLimitError
210
+
211
+
client = ApifyClient(token='MY-APIFY-TOKEN')
212
+
213
+
try:
214
+
run = client.run('some-run-id').get()
215
+
except NotFoundError:
216
+
run =None
217
+
except RateLimitError:
218
+
...
219
+
```
220
+
221
+
### Behavior change: 404 on ambiguous endpoints now raises `NotFoundError`
222
+
223
+
Direct, ID-identified fetches like `client.dataset(id).get()` or `client.run(id).get()` continue to swallow 404 into `None` — a 404 there unambiguously means the named resource does not exist. Similarly, `.delete()` on an ID-identified client keeps its idempotent behavior (404 is silently swallowed).
224
+
225
+
For calls where a 404 is *ambiguous*, the client now propagates <ApiLinkto="class/NotFoundError">`NotFoundError`</ApiLink> instead of returning `None` / silently succeeding. Three categories of endpoints are affected:
226
+
227
+
1.**Chained calls that target a default sub-resource without an ID** — `run.dataset()`, `run.key_value_store()`, `run.request_queue()`, `run.log()`. A 404 here could mean the parent run is missing OR the default sub-resource is missing, and the API body does not disambiguate. Applies to both `.get()` and `.delete()`.
228
+
2.**`.get()` / `.get_as_bytes()` / `.stream()` on a chained `LogClient`** — e.g. `run.log().get()`. Direct `client.log(build_or_run_id).get()` still returns `None` on 404.
229
+
3.**Singleton sub-resource endpoints fetched via a fixed path** — <ApiLinkto="class/ScheduleClient#get_log">`ScheduleClient.get_log()`</ApiLink>, <ApiLinkto="class/TaskClient#get_input">`TaskClient.get_input()`</ApiLink>, <ApiLinkto="class/DatasetClient#get_statistics">`DatasetClient.get_statistics()`</ApiLink>, <ApiLinkto="class/UserClient#monthly_usage">`UserClient.monthly_usage()`</ApiLink>, <ApiLinkto="class/UserClient#limits">`UserClient.limits()`</ApiLink>, <ApiLinkto="class/WebhookClient#test">`WebhookClient.test()`</ApiLink>. These hit paths like `/schedules/{id}/log` or `/actor-tasks/{id}/input`, so a 404 effectively means the parent is missing. Return types moved from `T | None` to `T`.
# `get_log()` previously returned `None` when the schedule was missing; now it raises.
247
+
schedule_log =None
248
+
```
249
+
250
+
Direct `.get()` also now swallows every 404 regardless of the `error.type` string in the response body (previously only `record-not-found` and `record-or-token-not-found` types were swallowed). If your code needs to distinguish between "resource missing" and "404 with an unexpected type", inspect `.type` on a caught <ApiLinkto="class/NotFoundError">`NotFoundError`</ApiLink> from a non-`.get()` call path.
251
+
189
252
## Snake_case `sort_by` values on `actors().list()`
190
253
191
254
The `sort_by` parameter of <ApiLinkto="class/ActorCollectionClient#list">`ActorCollectionClient.list()`</ApiLink> and <ApiLinkto="class/ActorCollectionClientAsync#list">`ActorCollectionClientAsync.list()`</ApiLink> now accepts pythonic snake_case values instead of the raw camelCase values used by the API.
0 commit comments