Skip to content

Commit 445ab5d

Browse files
authored
refactor!: Remove Request.id field (#553)
### Description - Remove `request.id` and replace all usages of `id` with `unique_key` - Add transformation from `unique_key` to `id` and use it when calling id-based client methods - Requires: - apify/crawlee-python#1366 ### Issues - Part of: apify/crawlee-python#1358
1 parent 209ef13 commit 445ab5d

File tree

11 files changed

+142
-117
lines changed

11 files changed

+142
-117
lines changed

docs/03_concepts/code/03_rq.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ async def main() -> None:
2020

2121
# If you try to add an existing request again, it will not do anything
2222
add_request_info = await queue.add_request(
23-
Request.from_url('http://different-example.com/5')
23+
Request.from_url('http://example.com/5')
2424
)
2525
Actor.log.info(f'Add request info: {add_request_info}')
2626

27-
processed_request = await queue.get_request(add_request_info.id)
28-
Actor.log.info(f'Processed request: {processed_request}')
29-
3027
# Finally, process the queue until all requests are handled
3128
while not await queue.is_finished():
3229
# Fetch the next unhandled request in the queue

docs/04_upgrading/upgrading_to_v3.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
2-
id: upgrading-to-v2
3-
title: Upgrading to v2
2+
id: upgrading-to-v3
3+
title: Upgrading to v3
44
---
55

66
This page summarizes the breaking changes between Apify Python SDK v2.x and v3.0.

src/apify/scrapy/requests.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def to_scrapy_request(apify_request: ApifyRequest, spider: Spider) -> ScrapyRequ
122122

123123
# Update the meta field with the meta field from the apify_request
124124
meta = scrapy_request.meta or {}
125-
meta.update({'apify_request_id': apify_request.id, 'apify_request_unique_key': apify_request.unique_key})
125+
meta.update({'apify_request_unique_key': apify_request.unique_key})
126126
# scrapy_request.meta is a property, so we have to set it like this
127127
scrapy_request._meta = meta # noqa: SLF001
128128

@@ -134,7 +134,6 @@ def to_scrapy_request(apify_request: ApifyRequest, spider: Spider) -> ScrapyRequ
134134
url=apify_request.url,
135135
method=apify_request.method,
136136
meta={
137-
'apify_request_id': apify_request.id,
138137
'apify_request_unique_key': apify_request.unique_key,
139138
},
140139
)

src/apify/storage_clients/_apify/_models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ class CachedRequest(BaseModel):
9494
Only internal structure.
9595
"""
9696

97-
id: str
98-
"""The ID of the request."""
97+
unique_key: str
98+
"""Unique key of the request."""
9999

100100
was_already_handled: bool
101101
"""Whether the request was already handled."""

0 commit comments

Comments
 (0)