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

Add inheritance ordering, unify element ordering #313

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

sneakers-the-rat
Copy link
Contributor

Schemaview seems like the right place to keep sorting methods that will be used by all the generators. Lo and behold, it already is!

Added the inheritance ordering method used by pythongen and pydanticgen, put all ordering into a single method.

Must be merged before the adjoining linkml PR (will add link in a second) and linkml lockfile must be regenerated to reflect the release containing this PR

Copy link

codecov bot commented Mar 21, 2024

Codecov Report

Attention: Patch coverage is 52.17391% with 22 lines in your changes are missing coverage. Please review.

Project coverage is 62.84%. Comparing base (deb2ba3) to head (e5b903e).
Report is 4 commits behind head on main.

Files Patch % Lines
linkml_runtime/utils/schemaview.py 51.11% 20 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #313      +/-   ##
==========================================
- Coverage   62.92%   62.84%   -0.09%     
==========================================
  Files          62       63       +1     
  Lines        8532     8580      +48     
  Branches     2436     2444       +8     
==========================================
+ Hits         5369     5392      +23     
- Misses       2553     2576      +23     
- Partials      610      612       +2     

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

@@ -342,6 +370,32 @@ def _order_rank(self, elements: dict):
rank_ordered_elements.update(unranked_map)
return rank_ordered_elements

def _order_inheritance(self, elements: DefDict) -> DefDict:
"""
sort classes such that if C is a child of P then C appears after P in the list
Copy link
Member

Choose a reason for hiding this comment

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

Quick nit: it's not just classes, inheritance can be applied to slots and subsets as well, so this is for elements generally?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally - I was just copying the existing comment there. Specifically the type bound is for Definitions since you need the is_a property

Copy link
Member

@sujaypatil96 sujaypatil96 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 adding the ability to order elements by inheritance @sneakers-the-rat we might want to use this functionality in the documentation generator at some point as well!

The code changes look good to me, this PR is ready to go 🚀

@cmungall cmungall merged commit 27990c1 into linkml:main Mar 21, 2024
9 checks passed
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