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

[Feature Request] Implement hydra.utils.get_object to locate arbitrary object. #1975

Closed
Jasha10 opened this issue Jan 19, 2022 · 2 comments
Closed
Labels
enhancement Enhanvement request good first issue Good for newcomers
Milestone

Comments

@Jasha10
Copy link
Collaborator

Jasha10 commented Jan 19, 2022

The hydra.utils.get_class and hydra.utils.get_method functions are useful to look up python objects based on dot-paths.

>>> import hydra
>>> hydra.utils.get_method("numpy.float32")
<class 'numpy.float32'>

Internally, these functions use the same mechanism as the hydra.utils.instantiate function.

These two functions fail when looking up an object that is not a type and is not callable:

>>> hydra.utils.get_method("tensorflow.float16")
...
ValueError: Invalid type (<class 'tensorflow.python.framework.dtypes.DType'>) found for tensorflow.float16

I propose a hydra.utils.get_object function that has the same behavior as get_class and get_method but is more permissive with regard to non-callable objects.

For a motivating use-case, see this stackoverflow post.

@Jasha10 Jasha10 added enhancement Enhanvement request good first issue Good for newcomers labels Jan 19, 2022
@Jasha10 Jasha10 added this to the Hydra 1.3.0 milestone Nov 22, 2022
@Zekrom-7780
Copy link

@Jasha10 , please can I work on this issue?

@Jasha10
Copy link
Collaborator Author

Jasha10 commented Nov 7, 2023

@Zekrom-7780 thank you for volunteering -- this feature has already been implemented (PR #2520).
I will close this issue now.

@Jasha10 Jasha10 closed this as completed Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhanvement request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants