Repository navigation
fix: keep fallback_fetch_function and other fields in CrawlerRunConfig.clone() - #2385
Open
Parsiffall1 wants to merge 1 commit into
Open
Parsiffall1 wants to merge 1 commit into
Parsiffall1 wants to merge 1 commit into
Conversation
…g.clone() CrawlerRunConfig.clone() rebuilds the config from to_dict(), which left out fallback_fetch_function, check_cache_freshness, cache_validation_timeout and virtual_scroll_config. Deep crawl strategies clone the run config for every batch, so these settings were silently reset and the fallback fetcher was never called during deep crawls. Add the missing keys to to_dict() and cover them with unit tests. Fixes unclecode#2379
6 tasks done
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.
Summary
Fixes #2379
CrawlerRunConfig.clone()rebuilds the config fromto_dict(), andto_dict()did not includefallback_fetch_function. BFS, DFS and BestFirst deep crawls clone the run config for every batch (config.clone(deep_crawl_strategy=None, stream=...)), so the fallback fetcher was dropped and never used for deep-crawled pages, while the same page fetched witharun()/arun_many()did use it.check_cache_freshness,cache_validation_timeoutandvirtual_scroll_configwere missing fromto_dict()for the same reason and were also reset to their defaults on clone. This adds the four keys toto_dict();clone()keeps working as before and still lets callers override any of them throughkwargs.List of files changed and why
crawl4ai/async_configs.py: addfallback_fetch_function,check_cache_freshness,cache_validation_timeoutandvirtual_scroll_configtoCrawlerRunConfig.to_dict().tests/unit/test_run_config_clone_fields.py: new tests that clone a config the way deep crawl strategies do and check these fields survive, and thatfallback_fetch_functioncan still be overridden.How Has This Been Tested?
pytest tests/unit/test_run_config_clone_fields.py: 3 passed; 2 of them fail ondevelopwithout the change.pytest tests/unit: the same set of failures before and after the change (they need network/browser access locally); no new failures.Checklist: