Feature/external id scientif journals#130
Merged
Merged
Conversation
…raction and validation
jmsevin
approved these changes
Apr 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes how scientific journal scrapers/rest collectors populate external_id (DOI) and external_id_type, refactors the OpenAlex plugin for clearer responsibilities, and updates tests/dependencies to validate the new behavior.
Changes:
- Standardize DOI extraction and assignment to
document.external_idwithExternalIdType.DOIacross OpenAlex, PeerJ, and PLOS. - Refactor OpenAlex document construction (publisher/access/license checks, details/content/author building).
- Add
NoDOIFoundError, adjust exception inheritance, and extend tests to assert external ID fields.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| welearn_datastack/plugins/scrapers/plos.py | Refactors DOI/journal/ISSN extraction helpers and sets external_id / external_id_type. |
| welearn_datastack/plugins/scrapers/peerj.py | Sets DOI as external_id, adds explicit missing-DOI exception, and sets external_id_type. |
| welearn_datastack/plugins/rest_requesters/open_alex.py | Major refactor to modularize checks/build steps and normalize DOI handling for external_id. |
| welearn_datastack/exceptions.py | Switches custom exceptions to inherit from Exception and adds NoDOIFoundError. |
| tests/document_collector_hub/plugins_test/test_scraping_peerj.py | Adds assertions for DOI external_id and external_id_type. |
| tests/document_collector_hub/plugins_test/test_open_alex.py | Adjusts DOI input format and asserts normalized DOI in external_id/type. |
| pyproject.toml | Bumps python-dotenv version constraint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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 pull request introduces several improvements and refactorings to the document processing plugins, focusing on standardizing the handling of external identifiers (especially DOIs), improving exception handling, and refactoring the OpenAlex plugin for clarity and maintainability. It also updates dependencies and enhances tests to validate the new logic.
Refactoring and Standardization of External Identifiers:
external_idand specify its type asExternalIdType.DOI. The OpenAlex DOI extraction method strips thehttps://doi.org/prefix if present. [1] [2] [3] [4] [5]Exception Handling Improvements:
welearn_datastack/exceptions.pynow inherit fromExceptioninstead ofBaseException, aligning with Python best practices.NoDOIFoundErrorexception is introduced to explicitly handle cases where a DOI cannot be found during scraping. [1] [2]OpenAlex Plugin Refactor:
_update_welearn_documentmethod is refactored for clarity: publisher authorization, access, and license checks are now performed in dedicated methods before document construction. Details construction, content resolution, and author extraction are modularized. [1] [2]_invert_abstractmethod now returnsNoneif the input isNone, improving robustness.Dependency and Typing Updates:
python-dotenvdependency is updated from^1.1.0to^1.2.1.Test Enhancements:
external_idandexternal_id_typeare set on documents, ensuring the new logic is validated. [1] [2]Refactoring and Standardization:
external_idwith the correct type, and refactor extraction logic for maintainability. [1] [2] [3] [4] [5]Exception Handling:
Exceptioninstead ofBaseException.NoDOIFoundErrorfor missing DOI cases. [1] [2]Dependency and Typing:
python-dotenvdependency version.Testing:
external_idandexternal_id_typeextraction and assignment. [1] [2]