Skip to content

BDMS 55: lexicon coverage & other updates#106

Merged
jirhiker merged 34 commits into
pre-productionfrom
jab-api-coverage-lexicon
Aug 27, 2025
Merged

BDMS 55: lexicon coverage & other updates#106
jirhiker merged 34 commits into
pre-productionfrom
jab-api-coverage-lexicon

Conversation

@jacob-a-brown

Copy link
Copy Markdown
Contributor

Why

This PR addresses the following problem / context:

  • The lexicon router should be fully covered with GET, GET by ID, POST, PATCH, and DELETE endpoints
  • tests that relied on spillover need to be amended for the use of fixtures
  • proper authentication and permissions need to be vetted at endpoints
  • staging data scripts need to be usable by all operating systems

How

Implementation summary - the following was changed / added / removed:

  • Cleaned up POST /triple and /category to adhere with most recent styles (i.e. use model_adder)
  • Added PATCH /term/{term_id}, /category/{category_id}, /triple/{triple_id}
  • Added GET /category/{category_id}, /triple, /triple/{triple_id}
  • Added DELETE /term/{term_id}, /category/{category_id}, /triple/{triple_id}

Notes

Any special considerations, workarounds, or follow-up work to note?

  • adder was moved from db/__init__.py to services/crud_helper/py and renamed model_adder to maintain a consistent style and nomenclature for crud functions.
  • Lexicon was renamed LexiconTerm for clarity. Category was renamed LexiconCategory for clarity.
  • LexiconTerm and LexiconCategory are now associated via their IDs, not the term's term and category's name.
  • LexiconTerm
    • Previously a new LexiconTerm could only be associated with a single LexiconCategory. In this PR it can now be associated with multiple LexiconCategories.
    • When creating a new LexiconTerm, if any associated LexiconCategories are not present in the database they will be added (this functionality was maintained, though expanded to create multiple new records if they didn't previously exist). Do we want to maintain this functionality? Or should categories only be created via POST /category?
    • Newly crated LexiconTerms must be associated with at least one category.
    • Because when a lexicon term is added it can be associated with multiple categories, core/lexicon.json was updated to rename category categories, which evaluates to a list of dictionaries with the category name and description.
  • LexiconTriple
    • A LexiconTriple is now deleted if the subject or object_ are deleted because of foreign key constraints.
    • When a LexiconTriple is added it can be associated with any LexiconTerm (subject and object_). If that LexiconTerm does not exist it will be created (and therefore new LexiconCategories can be created when the terms are created). Do we want to maintain this functionality? Or should terms and categories only be created via their POST endpoints?
  • transfers
    • transfers/transfer.py was deleted since it is out of date. transfers/transfer2.py was then renamed transfers/transfer.py.
    • __init__.py was added to transfers/ and all import paths are defined relative to the root directory.
    • Data transfers can now be done by calling python -m transfers.transfer from the root directory.

@codecov-commenter

codecov-commenter commented Aug 26, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.25373% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
db/lexicon.py 83.33% 3 Missing ⚠️
services/crud_helper.py 91.66% 1 Missing ⚠️
Files with missing lines Coverage Δ
api/contact.py 100.00% <100.00%> (ø)
api/geochronology.py 86.66% <100.00%> (ø)
api/group.py 100.00% <100.00%> (ø)
api/lexicon.py 98.82% <100.00%> (+7.39%) ⬆️
api/location.py 92.30% <100.00%> (-0.20%) ⬇️
api/observation.py 100.00% <100.00%> (ø)
api/sample.py 100.00% <100.00%> (ø)
api/sensor.py 77.77% <100.00%> (-0.41%) ⬇️
api/thing.py 86.51% <100.00%> (-0.15%) ⬇️
core/app.py 66.66% <100.00%> (ø)
... and 8 more

... and 3 files with indirect coverage changes

@jirhiker jirhiker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the images in the transfer folder should not be included. the transfer directory contains an assets folder where images go. this folder is in .gitignore. All the data in the transfer folder is just for testing and does not need to be version controlled

@jirhiker jirhiker left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the changes to transfer should be removed. These are in conflict with https://github.com/DataIntegrationGroup/NMSampleLocations/tree/jir-transfer

@jacob-a-brown jacob-a-brown requested a review from jirhiker August 27, 2025 14:41
@jirhiker jirhiker merged commit a0a9de4 into pre-production Aug 27, 2025
3 checks passed
@jirhiker jirhiker deleted the jab-api-coverage-lexicon branch December 3, 2025 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants