Repository navigation
Share the fetch and the stratum loop across the corpus builders - #699
Merged
Merged
Conversation
corpus_build.fetch_bytes replaces four hand-written urlopen closures (CLDR, GND, Wikidata, the LC cross-check); build_strata in build_wikidata_corpus.py replaces the two near-identical build() loops. The tests' time.sleep patch moves into the shared serve fixture. Offline rebuilds of both Wikidata corpora leave every committed file unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The _Counted Protocol did not type-check (NamedTuple fields are read-only): make its members properties and bind the callbacks to the stratum type with a TypeVar. Pin Wikidata's POST, Accept header and politeness delay, the LC delay, and that keep() sees only taken people. Fix the corpus_build roster and the shared-helper comments. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #699 +/- ##
=======================================
Coverage 99.03% 99.03%
=======================================
Files 46 46
Lines 4541 4541
=======================================
Hits 4497 4497
Misses 44 44 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Item 3 of #696 (items 1 and 2 landed in #697).
corpus_build.fetch_bytes()replaces the four hand-written Request/User-Agent/urlopen/sleep closures: CLDR, GND, Wikidata and the LC cross-check. Each keeps its own timeout and delay.build_strata()inbuild_wikidata_corpus.pyreplaces the two near-identicalbuild()loops (a person taken once across strata, the missing-person stop, the floor stop). What differs is passed in: how entities are fetched, the property list, the progress-line width, and akeepcallback the native builder uses for LCCNs.time.sleeppatches move into the sharedservefixture. Four new tests pinfetch_bytesdirectly (User-Agent and extra headers, POST, delay only after a response, no delay on failure).fetch_bytestests.Closes #696
🤖 Generated with Claude Code