Skip to content

fix(crawlers)!: Count requests in the statistics passed to AdaptivePlaywrightCrawler factory methods - #2447

Merged
vdusek merged 2 commits into
apify:v2from
Mantisus:adaptive-factory-statistics
Nov 20, 2026
Merged

vdusek merged 2 commits into
apify:v2from
Mantisus:adaptive-factory-statistics

Conversation

@Mantisus

Copy link
Copy Markdown
Collaborator

Description

  • AdaptivePlaywrightCrawler.with_beautifulsoup_static_parser and with_parsel_static_parser pass statistics to the crawler as is, so the instance you pass is the one that counts, with all its settings.
  • AdaptivePlaywrightCrawler raises a ValueError when statistics don't use AdaptivePlaywrightCrawlerStatisticState as their state model.
  • Statistics.replace_state_model is removed.

For how to update your code, see the upgrade guide.

Issues

Testing

  • Unit and integration tests for statistics passed to the factory methods, including the ValueError for another state model.

✍️ Drafted by Claude Code

@Mantisus
Mantisus marked this pull request as draft November 14, 2026 22:37
@Mantisus Mantisus self-assigned this Nov 14, 2026
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 14, 2026
@Mantisus
Mantisus force-pushed the adaptive-factory-statistics branch from bd176e9 to fa2fa4b Compare November 15, 2026 22:30
@Mantisus
Mantisus force-pushed the adaptive-factory-statistics branch from fa2fa4b to a6a9c44 Compare November 18, 2026 14:27
@Mantisus
Mantisus marked this pull request as ready for review November 18, 2026 14:28
@Mantisus
Mantisus requested a review from vdusek November 18, 2026 14:28
@vdusek vdusek changed the title fix(statistics)!: Count requests in statistics passed to adaptive crawler factories and require the adaptive state model fix(crawlers)!: Count requests in the statistics passed to AdaptivePlaywrightCrawler factory methods Nov 18, 2026

@vdusek vdusek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: docs/03_concepts/22_statistics.mdx:65 (outside the diff) still says to use Statistics.with_default_state to get an instance. With this PR, such an instance makes AdaptivePlaywrightCrawler raise a ValueError. Can we add a sentence that the adaptive crawler needs Statistics(state_model=AdaptivePlaywrightCrawlerStatisticState)?

✍️ Drafted by Claude Code

Comment thread docs/06_upgrading/upgrading_to_v2.md Resolved
Comment thread src/crawlee/statistics/_statistics.py Resolved
@Mantisus
Mantisus requested a review from vdusek November 19, 2026 22:07

@vdusek vdusek left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

✍️ Drafted by Claude Code

@vdusek
vdusek merged commit cccb9aa into apify:v2 Nov 20, 2026
43 checks passed
vdusek pushed a commit that referenced this pull request Nov 29, 2026
…laywrightCrawler` factory methods (#2447)

### Description

- `AdaptivePlaywrightCrawler.with_beautifulsoup_static_parser` and
`with_parsel_static_parser` pass `statistics` to the crawler as is, so
the instance you pass is the one that counts, with all its settings.
- `AdaptivePlaywrightCrawler` raises a `ValueError` when `statistics`
don't use `AdaptivePlaywrightCrawlerStatisticState` as their state
model.
- `Statistics.replace_state_model` is removed.

For how to update your code, see the upgrade guide.

### Issues

- Part of: #2301
- Follow-up: #2445

### Testing

- Unit and integration tests for statistics passed to the factory
methods, including the `ValueError` for another state model.

*✍️ Drafted by Claude Code*
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.

Let crawlers manage only the collaborators they create and extract per-run state

2 participants