Add PubMed metadata source - #366
Open
shuchenliu wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a new pubmed_metadata plugin that ingests RENCI pubmed2db PubMed citation metadata (16 gzip NDJSON shards), including a streaming/validating parser, Elasticsearch mapping, and BioThings Hub dumper/uploader integration.
Changes:
- Added PubMed metadata plugin modules: dumper (download), uploader (parallel shard upload), parser (stream + validate + transform), mapping, and release-pinned constants.
- Added source documentation describing schema, validation guarantees, shard/concurrency behavior, and deployment/alias guidance.
- Added unit tests covering parser validation/date handling, mapping expectations, static release constants, and uploader shard partitioning.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_pubmed_metadata_uploader.py | Tests uploader job partitioning and load behavior with a stubbed BioThings environment. |
| tests/test_pubmed_metadata_static.py | Verifies pinned release constants and expected shard list/URLs. |
| tests/test_pubmed_metadata_parser.py | Validates record schema enforcement, date construction rules, and gzip/NDJSON streaming errors. |
| tests/test_pubmed_metadata_mapping.py | Confirms ES mapping choices (non-indexed abstract, sortable fields, date formats). |
| plugins/pubmed_metadata/uploader.py | Implements shard presence checks, 4-way partitioned jobs, and document streaming upload. |
| plugins/pubmed_metadata/static.py | Defines pinned upstream release, base URL, shard count, filenames, and terms URLs. |
| plugins/pubmed_metadata/README.md | Documents source, schema, validation behavior, and operational/deployment notes. |
| plugins/pubmed_metadata/parser.py | Provides strict streaming parser with schema/type/ID/date validation and contextual error reporting. |
| plugins/pubmed_metadata/mapping.py | Adds ES mapping for pubmed documents with sortable journal.name.raw and partial-date formats. |
| plugins/pubmed_metadata/dumper.py | Adds HTTP dumper configured for bounded parallel downloads and pinned release. |
| plugins/pubmed_metadata/init.py | Exposes dumper/uploader classes for plugin discovery/import. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
tests/test_pubmed_metadata_uploader.py:58
- The fixture removes existing
plugins.pubmed_metadata*modules fromsys.modulesusing directpop()and then restores them manually. If the import fails before theyield, the teardown section will never run and the test session can be left with a corruptedsys.modulesstate. Usemonkeypatch.delitem()for the removals so pytest reliably restores state even when setup fails, and simplify the teardown accordingly.
original_plugin_modules = {
name: module
for name, module in tuple(sys.modules.items())
if name == "plugins.pubmed_metadata" or name.startswith("plugins.pubmed_metadata.")
}
plugins/pubmed_metadata/uploader.py:38
- The FileNotFoundError message hard-codes "16 shards" even though the expected shard list comes from
PUBMED_METADATA_FILES. If the shard count changes (eg a new release), this message becomes inaccurate. Build the message fromlen(PUBMED_METADATA_FILES)instead of a magic number.
raise FileNotFoundError(
"PubMed metadata upload requires all 16 shards; missing: "
+ ", ".join(missing_paths)
)
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.
add support for PubMed