Repository navigation
fix(nodes): stop FetchNodeLevelK from skipping the page after an empty one - #1177
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
This branch has not been deployed
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
FetchNodeLevelK.obtain_contentremoves documents with empty content fromdocumentswhile it iterates over that same list. Removing an item during iteration shifts the list, so the loop skips the next document. On the last depth level, the skipped page is never fetched andDepthSearchGraphreturns without it, with no warning.This change iterates over a copy of the list, so removing a failed document no longer affects the loop.
Fixes #1176
Changes
scrapegraphai/nodes/fetch_node_level_k.py: iterate overlist(documents)inobtain_content.tests/test_fetch_node_level_k.py: new test. Withdepth: 2, the root page links to an empty page and then to a page with content. The test checks that the second page is fetched and returned.Testing
uv run pytest tests/test_fetch_node_level_k.py: fails before the fix (/fullis never fetched), passes after..github/workflows/test-suite.ymlplus the new file: 82 passed.ruff check,black --checkandisort --check-onlypass on the changed files.The new test file is not in the explicit file list in
.github/workflows/test-suite.yml. You can add it there if you want CI to run it.