Skip to content

Add API to locate package modules #6275

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

Closed
Nic-Ma opened this issue Apr 3, 2023 · 0 comments
Closed

Add API to locate package modules #6275

Nic-Ma opened this issue Apr 3, 2023 · 0 comments

Comments

@Nic-Ma
Copy link
Contributor

Nic-Ma commented Apr 3, 2023

Is your feature request related to a problem? Please describe.
Originally posted by @ericspod in #6181 (review):
I see you're using pydoc.locate and I wonder if we should have our own function in monai.utils.module for doing this. This is a topic for some other time and place but I had used something like this in the past that worked well enough:

def find_type_def(qualified_name: str):
    if "." not in qualified_name:
        modname, defname = "builtins", qualified_name
    else:
        modname, defname = qualified_name.rsplit(".", 1)

    mod = __import__(modname)
    return getattr(mod, defname)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants