feat: Persist DefaultRenderingTypePredictor state#1340
Merged
Pijukatel merged 3 commits intoapify:masterfrom Aug 12, 2025
Merged
feat: Persist DefaultRenderingTypePredictor state#1340Pijukatel merged 3 commits intoapify:masterfrom
DefaultRenderingTypePredictor state#1340Pijukatel merged 3 commits intoapify:masterfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds persistence capabilities to the DefaultRenderingTypePredictor by implementing state management that saves and restores the trained model and associated data to/from a key-value store. This allows the predictor to maintain its learned patterns across different runs.
- Adds persistence support with configurable key-value storage integration
- Implements async context manager pattern for proper resource management
- Introduces state serialization/deserialization for scikit-learn models
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/crawlee/crawlers/_adaptive_playwright/_rendering_type_predictor.py |
Core implementation of persistence with RecoverableState integration and async context manager |
src/crawlee/crawlers/_adaptive_playwright/_utils.py |
Utility functions for scikit-learn model serialization and validation |
src/crawlee/crawlers/_adaptive_playwright/_adaptive_playwright_crawler.py |
Integration of predictor into crawler's context managers |
tests/unit/crawlers/_adaptive_playwright/test_predictor.py |
Updated tests to use async context manager and added persistence tests |
tests/unit/crawlers/_adaptive_playwright/test_adaptive_playwright_crawler.py |
Added super().init() call to test mock class |
docs/guides/code_examples/playwright_crawler_adaptive/init_prediction.py |
Updated example to properly call parent constructor |
Comments suppressed due to low confidence (1)
tests/unit/crawlers/_adaptive_playwright/test_predictor.py:27
- The function name 'ictor_same_label' appears to be truncated or misspelled. It should likely be 'test_predictor_same_label' or similar.
async def ictor_same_label(url: str, expected_prediction: RenderingType, label: str | None) -> None:
Pijukatel
reviewed
Aug 6, 2025
Collaborator
Pijukatel
left a comment
There was a problem hiding this comment.
Just two tiny comments
src/crawlee/crawlers/_adaptive_playwright/_rendering_type_predictor.py
Outdated
Show resolved
Hide resolved
Pijukatel
approved these changes
Aug 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
DefaultRenderingTypePredictorstateIssues
DefaultRenderingTypePredictorstate #1272