Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Add endpoint that returns term ID-label mappings for vocab of a given attribute (nb:Assessment) #201

Merged
merged 17 commits into from
Oct 18, 2023

Conversation

alyssadai
Copy link
Contributor

@alyssadai alyssadai commented Oct 15, 2023

Closes #197

Changes proposed in this pull request:

  • New API path created under /attributes router: /attributes/{data_element_URI}/vocab
    • New response model created for this endpoint which includes info about the vocab namespace and the term-label mappings as a dict
    • {data_element_URI} validated as enum to flag unrecognized CDEs
  • Workflow to fetch raw vocab implemented for Cognitive Atlas (i.e., when data_element_URI=="nb:Assessment")
    • Involves startup events that will:
      1. Attempt to request the raw cogatlas JSON blob using their API
      2. If a. fails, emit a warning and default to a backup JSON dump of the vocab stored in the repo
  • Tests added for new startup events and response from new endpoint

Checklist

  • PR has an interpretable title with a prefix ([ENH], [FIX], [REF], [TST], [CI], [MNT], [INF], [MODEL], [DOC]) (see https://neurobagel.org/contributing/pull_requests for more info)
  • PR links to GitHub issue with mention Closes #XXXX
  • Tests pass
  • Checks pass

For new features:

  • Tests have been added

For bug fixes:

  • There is at least one test that would fail under the original bug conditions.

@coveralls
Copy link
Collaborator

coveralls commented Oct 15, 2023

Pull Request Test Coverage Report for Build 6565245867

  • 113 of 113 (100.0%) changed or added relevant lines in 6 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.04%) to 99.826%

Totals Coverage Status
Change from base Build 6474650526: 0.04%
Covered Lines: 575
Relevant Lines: 576

💛 - Coveralls

@surchs surchs self-requested a review October 16, 2023 19:56
Copy link
Contributor

@surchs surchs left a comment

Choose a reason for hiding this comment

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

Thanks for this impressive PR @alyssadai. This took me a second to work through because it is complex, mostly necessarily, I think. I did leave a couple of comments where I think we can make the code clearer or provide context for the future.

Since this is the cogatlas / assessment tool endpoint, I'd also update the PR title to reflect that.

Take a look, apply what you agree with - everything works so after that: 🧑‍🍳

app/api/crud.py Outdated Show resolved Hide resolved
app/main.py Show resolved Hide resolved
app/main.py Show resolved Hide resolved
tests/test_query.py Outdated Show resolved Hide resolved
app/main.py Outdated Show resolved Hide resolved
app/main.py Outdated Show resolved Hide resolved
app/api/utility.py Show resolved Hide resolved
app/api/routers/attributes.py Outdated Show resolved Hide resolved
app/api/routers/attributes.py Outdated Show resolved Hide resolved
app/api/utility.py Outdated Show resolved Hide resolved
@alyssadai alyssadai changed the title [ENH] Add endpoint that returns term ID-label mappings for vocab of a given attribute [ENH] Add endpoint that returns term ID-label mappings for vocab of a given attribute (nb:Assessment) Oct 18, 2023
@alyssadai alyssadai merged commit 036fb3b into main Oct 18, 2023
@alyssadai alyssadai deleted the iss-197/add-term-label-endpoint branch October 18, 2023 18:49
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.

Create an endpoint returning all term ID-label mappings for a vocabulary
3 participants