refactor!: switch crawler and statistics IDs from int to str by Mantisus · Pull Request #2340 · apify/crawlee-python · GitHub
Skip to content

refactor!: switch crawler and statistics IDs from int to str - #2340

Merged
vdusek merged 2 commits into
apify:v2from
Mantisus:string-id
Oct 21, 2026
Merged

vdusek merged 2 commits into
apify:v2from
Mantisus:string-id

Conversation

@Mantisus

Copy link
Copy Markdown
Collaborator

The id argument of BasicCrawler is now a str, and so are StatisticsState.stats_id and EventCrawlerStatusData.crawler_id. Statistics takes a new id argument, and the statistics a crawler creates by default use the crawler's id, following apify/crawlee#3834. Crawlers that share an id now share the persisted statistics as well as the use_state state.

A generated id is the crawler's creation index, which now counts crawlers with an explicit id too. EventCrawlerStatusData.crawler_id holds the crawler's id instead of the Python object ID. Statistics persisted by v1 with a numeric ID still load. The upgrade guide gets a section for the change.

Closes: #1699

✍️ Drafted by Claude Code

@Mantisus Mantisus self-assigned this Oct 19, 2026
@Mantisus
Mantisus requested a review from vdusek October 19, 2026 14:23
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 19, 2026
@Mantisus
Mantisus requested a review from Pijukatel October 19, 2026 14:23
Comment thread src/crawlee/crawlers/_basic/_basic_crawler.py
@vdusek vdusek changed the title feat!: Use string IDs for crawlers and statistics refactor!: switch crawler and statistics IDs from int to str Oct 20, 2026
Comment thread src/crawlee/statistics/_statistics.py Outdated
Comment thread tests/unit/_statistics/test_persistence.py Outdated
Comment thread tests/unit/crawlers/_basic/test_basic_crawler.py
Co-authored-by: Vlada Dusek <v.dusek96@gmail.com>
@vdusek
vdusek merged commit 86faf87 into apify:v2 Oct 21, 2026
35 checks passed
@vdusek vdusek linked an issue Oct 21, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Consider changing id from int to string

4 participants