-
Notifications
You must be signed in to change notification settings - Fork 296
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
Bug entry point #818
base: main
Are you sure you want to change the base?
Bug entry point #818
Changes from all commits
667a79b
078155f
bca75a3
8507279
4edcb0c
5d6d554
09dbd76
c5497f0
9fefdc9
96d9976
a5ba938
4a81edd
bcee652
0351637
bc6147d
fbb26cb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,12 @@ | |
|
||
import warnings | ||
from importlib.metadata import EntryPoint, entry_points | ||
|
||
# NOTE: This is for backport compatibility, some entry points seem to be using this old class | ||
# Exact cause of this is unknown but it seems to be related to multiple versions | ||
# of importlib being present in the environment | ||
from importlib_metadata import EntryPoint as EntryPointOld | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you add a small comment explaining what this is, why it here? importlib_metadata is a back port of new APIs for previous python vesions, also users dont necessarily need this installed. If it happens to be installed, we should check it. Or does this come with base python (I dont think so but maybe) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Best guess is somehow older versions of importlib are getting being used and some how this impacts the return type on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
from typing import List, Union | ||
|
||
import physicsnemo | ||
|
@@ -120,8 +126,10 @@ def factory(self, name: str) -> "physicsnemo.Module": | |
|
||
model = self._model_registry.get(name) | ||
if model is not None: | ||
if isinstance(model, EntryPoint): | ||
if isinstance(model, EntryPoint) or isinstance(model, EntryPointOld): | ||
model = model.load() | ||
else: | ||
raise TypeError(f"Model {name} is not a valid entry point.") | ||
return model | ||
|
||
raise KeyError(f"No model is registered under the name {name}") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we avoid this import from
importlib_metadata
? This has been deprecated in the newer versions of Python