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

[REF] Refactor utilities #385

Merged
merged 15 commits into from
Nov 11, 2024
Merged

[REF] Refactor utilities #385

merged 15 commits into from
Nov 11, 2024

Conversation

alyssadai
Copy link
Contributor

@alyssadai alyssadai commented Nov 7, 2024

Changes proposed in this pull request:

  • move all utility files into a utilities module
  • rename utility.py to model_utils.py (includes utility functions related to generating + extracting entities from graph dataset instances, etc.)
  • split test_utility.py into:
    • test_putil.py
    • test_butil.py
    • test_dutil.py
    • test_futil.py
    • test_mutil.py
    • and organized them into integration/ and unit/ subdirs
  • remove test test_generate_context() (it replicates logic of function being tested and is hard to maintain)
  • refactor out into utility functions:
    • merging context + final dataset instance for output to JSONLD
    • saving final JSONLD

Checklist

This section is for the PR reviewer

  • PR has an interpretable title with a prefix ([ENH], [FIX], [REF], [TST], [CI], [MNT], [INF], [MODEL], [DOC]) (see our Contributing Guidelines for more info)
  • PR has a label for the release changelog or skip-release (to be applied by maintainers only)
  • 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.

@alyssadai alyssadai added the pr-internal Non-user-facing code improvement, will increment patch version when merged (0.0.+1) label Nov 7, 2024
Copy link

codecov bot commented Nov 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.36%. Comparing base (e93423d) to head (e387f06).
Report is 11 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #385      +/-   ##
==========================================
- Coverage   98.37%   98.36%   -0.01%     
==========================================
  Files          16       21       +5     
  Lines         982      980       -2     
==========================================
- Hits          966      964       -2     
  Misses         16       16              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

@coveralls
Copy link
Collaborator

coveralls commented Nov 7, 2024

Pull Request Test Coverage Report for Build 11784441718

Details

  • 229 of 229 (100.0%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.004%) to 98.367%

Totals Coverage Status
Change from base Build 11716298122: -0.004%
Covered Lines: 964
Relevant Lines: 980

💛 - Coveralls

@alyssadai alyssadai marked this pull request as ready for review November 7, 2024 22:07
@rmanaem rmanaem requested a review from surchs November 8, 2024 17:03
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 @alyssadai for this refactor. I think it looks very nice!
I have some very minor clarity comments, take a look.

remove test test_generate_context() (it replicates logic of function being tested and is hard to maintain)

agreed, but I think we already had the case that we didn't include a class in the context and that then breaks things in confusing ways. So I don't think removing the test completely is a solution either. I don't have a great idea, but let's discuss this in a follow-up issue.

🧑‍🍳

bagel/cli.py Outdated Show resolved Hide resolved
bagel/utilities/model_utils.py Outdated Show resolved Hide resolved
tests/unit/test_butil.py Outdated Show resolved Hide resolved
@alyssadai
Copy link
Contributor Author

Hey @surchs, just to reply to your concern regarding the removed test:

I think we already had the case that we didn't include a class in the context and that then breaks things in confusing ways. So I don't think removing the test completely is a solution either

To clarify, we added two new tests in PR #349, test_all_used_namespaces_have_urls and test_used_namespaces_in_context, that should catch these issues without requiring us to remember to update the test parameters whenever we update the data model! :) The removed test was just leftover from a #TODO in that PR.

@alyssadai alyssadai merged commit 3f33239 into main Nov 11, 2024
11 checks passed
@alyssadai alyssadai deleted the refactor-utils branch November 11, 2024 19:02
Copy link
Contributor

🚀 PR was released in v0.3.4 🚀

@neurobagel-bot neurobagel-bot bot added the released This issue/pull request has been released. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-internal Non-user-facing code improvement, will increment patch version when merged (0.0.+1) released This issue/pull request has been released.
Projects
None yet
3 participants