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
improve hydra.utils.get_{class,method,object} #2520
Conversation
Previously the error message for get_class failure-to-locate was imprecise.
24d0949
to
47c9ac0
Compare
47c9ac0
to
ddc605e
Compare
Duh. didn't submit my pending comment. |
obj = _locate(path) | ||
return obj |
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.
Is the only new thing here that this function does not check the object for being a callable?
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.
Yes, exactly!
@@ -51,6 +67,22 @@ def get_method(path: str) -> Callable[..., Any]: | |||
get_static_method = get_method | |||
|
|||
|
|||
def get_object(path: str) -> Any: | |||
""" | |||
Look up a callable based on a dotpath. |
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.
the comment he is incorrect. object may not be a callable.
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.
Thanks. I've opened PR #2544 with a fixup.
Closes #1975 |
Implement
hydra.utils.get_object
for an easier way to look up objects from a dotpath.Commits:
hydra.utils.get_object
method #2139)