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

optimize get_classes_by_slot() in schemaview.py #300

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

sujaypatil96
Copy link
Member

The motivation to optimize this PR is that we are having to remove the Applicable classes section in the generated slot markdown/web documentation pages: https://github.com/linkml/linkml/blob/main/linkml/generators/docgen/slot.md.jinja2#L36-L46 for large schemas like mixs.

The optimizations that have been applied here are:

  • Use set() for accumulating class names
  • reduce repetitive calls to self.all_classes()
  • reduce number of iterations over all_classes
  • direct/induced handled in separate loops

Copy link

codecov bot commented Feb 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (51d2fce) 62.80% compared to head (54d9515) 62.90%.
Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #300      +/-   ##
==========================================
+ Coverage   62.80%   62.90%   +0.10%     
==========================================
  Files          61       62       +1     
  Lines        8506     8530      +24     
  Branches     2239     2239              
==========================================
+ Hits         5342     5366      +24     
- Misses       2553     2554       +1     
+ Partials      611      610       -1     

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

@sujaypatil96
Copy link
Member Author

sujaypatil96 commented Feb 20, 2024

After wonderful optimizations by Jonny in #296 I thought this would be an appropriate time to take advantage of his modifications and apply it to large schemas (like mixs) that need this performance improvement.

@sujaypatil96
Copy link
Member Author

sujaypatil96 commented Feb 21, 2024

@cmungall thanks for approving this PR. I'm still benchmarking if it's easier/faster to return ClassDefinition instead of ClassDefinitionName (corresponding changes will be required in slot.md.jinja2).

I won't merge this in till I have results from the benchmarking. I'm experimenting with these changes on the mixs schema.

@cmungall cmungall marked this pull request as draft February 21, 2024 21:58
@sujaypatil96 sujaypatil96 marked this pull request as ready for review February 23, 2024 22:42
@sujaypatil96
Copy link
Member Author

I think we are good to go with this PR as is @cmungall.

@sujaypatil96 sujaypatil96 merged commit 5fa3115 into main Feb 23, 2024
7 checks passed
@sujaypatil96 sujaypatil96 deleted the optimize-applicable-classes branch March 1, 2024 20:56
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.

2 participants