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

Made semsimian an optional dependency #704

Merged
merged 40 commits into from
Mar 14, 2024
Merged

Made semsimian an optional dependency #704

merged 40 commits into from
Mar 14, 2024

Conversation

hrshdhgd
Copy link
Collaborator

@hrshdhgd hrshdhgd commented Mar 6, 2024

Fixes #703

@hrshdhgd hrshdhgd requested a review from cmungall March 6, 2024 22:07
@codecov-commenter
Copy link

codecov-commenter commented Mar 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 75.34%. Comparing base (388c78b) to head (efd8858).
Report is 1 commits behind head on main.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #704   +/-   ##
=======================================
  Coverage   75.34%   75.34%           
=======================================
  Files         266      266           
  Lines       31083    31083           
=======================================
  Hits        23420    23420           
  Misses       7663     7663           

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

Copy link
Collaborator

@cmungall cmungall left a comment

Choose a reason for hiding this comment

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

I think this might break things as-is

from oaklib.implementations.semsimian.semsimian_implementation import (
SemSimianImplementation,
)

@hrshdhgd
Copy link
Collaborator Author

hrshdhgd commented Mar 6, 2024

I think this might break things as-is

from oaklib.implementations.semsimian.semsimian_implementation import (
SemSimianImplementation,
)

Aah! great catch ...that would have introduced more headaches. I think this is why we had semsimian as a required package. Thinking of a smart solution.....

@hrshdhgd hrshdhgd requested a review from cmungall March 6, 2024 23:28
Copy link
Collaborator

@cmungall cmungall left a comment

Choose a reason for hiding this comment

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

I think this is a bit complicated and will raise an error if someone imports semsimian_implementation. In general it should be safe to import any module in the current package.

Look at gilda_implementation for inspiration

@hrshdhgd
Copy link
Collaborator Author

hrshdhgd commented Mar 8, 2024

Look at gilda_implementation for inspiration

You mean

if TYPE_CHECKING:
    from semsimian import Semsimian

Done.

Copy link
Collaborator

@cmungall cmungall left a comment

Choose a reason for hiding this comment

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

There should be no need for dynamic manipulation of __all__

This can be simplified further. When I say look at gilda, I mean make it completely parallel. It's completely analogous, gilda==semsimian. __init__.py still imports GildaImplementation. It's completely safe as gilda is only ever imported within a method that is explicitly executed by a client

@hrshdhgd
Copy link
Collaborator Author

hrshdhgd commented Mar 8, 2024

Done

@@ -22,6 +20,8 @@
from oaklib.interfaces.semsim_interface import SemanticSimilarityInterface
from oaklib.types import CURIE, PRED_CURIE

Semsimian: Optional["Semsimian"] = None # type: ignore
Copy link
Collaborator

Choose a reason for hiding this comment

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

sorry... still pretty confusing. So this is a global variable? With a leading uppercase that makes it sound like a class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is a class but it is instantiated as a None. The class only exists once it is imported from the semsimian package. I know it is super confusing. I still prefer my previous solution but this one works too. Mimicking Gilda comes with complications like this because we are caching the Semsimian object but Gilda does not cache anything. So something that works for Gilda implementation doesn't necessaarily seem to work for Semsimian implementation.

@cmungall
Copy link
Collaborator

cmungall commented Mar 12, 2024 via email

@hrshdhgd hrshdhgd merged commit 8b9e6a3 into main Mar 14, 2024
6 checks passed
@hrshdhgd hrshdhgd deleted the semsimian-optional branch March 14, 2024 03:16
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.

Missing support for Python 3.12
3 participants