feat: Refactor scraping pipeline with DB-backed persistence, UK spelling migration, and legacy cleanup - #323
Merged
Merged
Conversation
This reverts commit bf270df.
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.
This branch introduces several interconnected changes across the scraping system, database layer, CLI tooling, and frontend templates. The primary goal is to improve maintainability, correctness of error handling, and consistency in naming conventions throughout the codebase.
New repository scraper system with DB-backed persistence
src/oss4climate/src/repository_scraper.py— A newRepositoryScraperclass that orchestrates the full scraping lifecycle: syncing from TOML index (upsert orgs/repos, discover repos, prune inactive), incremental re-scraping based on a configurable refresh interval (refresh_days=28by default), and exporting results to feather files plus summary/failure TOML outputs.src/oss4climate/src/database/repos.py— New SQLModel-backed tables forOrganisationandRepository, replacing the flat-file approach with structured, queryable database records including error tracking (last_error,error_count) and staleness management viamark_repos_inactive.src/oss4climate/src/database/scrape_cache.py— Extracted the old cache logic into its own module to separate concerns between scrape caching (HTTP-level) and repository persistence.Database refactoring
__init__.py) was restructured: models are now lazily imported from their respective modules, engine creation uses a connection string from settings instead of hardcoded paths, and the global_ENGINEis initialized on first use rather than at import time to avoid eager table creation.UK spelling migration (
license→licence)src/oss4climate/src/parsers/licenses.pytolicences.py.organisation,license→organisation_id,licence), model field names, and template bindings. This aligns with the project's UK English convention.Legacy cleanup
_base.html,_navbar.html,results.html) in favour of consolidated v2 templates undersrc/oss4climate_app/templates/v2/.src/oss4climate_scripts/src/search.py(TypeScript-style CLI search) as it was superseded by the Typesense-powered web UI..github/workflows/repo-assist.lock.ymland.github/workflows/repo-assist.md.Logging improvements
print()calls in logging utilities with properlogging.info()/logging.warning(), configured at INFO level by default.oss4climate) and app (oss4climate_app).Performance fix
Typesense schema updates
readme,embedding_readme,organisation_id,licence,language,url, andlast_commit_timestamp. This prevents indexing failures for repos with incomplete metadata.idxfield type fromint32tostringfor compatibility with database IDs.Documentation
docs/scraping-process.mddocumenting the scraping pipeline, its stages (TOML sync → scrape → export), and configuration options.