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

improve hydra.utils.get_{class,method,object} #2520

Merged
merged 4 commits into from Jan 11, 2023

Conversation

Jasha10
Copy link
Collaborator

@Jasha10 Jasha10 commented Dec 24, 2022

Implement hydra.utils.get_object for an easier way to look up objects from a dotpath.

Commits:

Previously the error message for get_class failure-to-locate
was imprecise.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Dec 24, 2022
@Jasha10 Jasha10 changed the title implement hydra.utils.get_object improve hydra.utils.get_{class,method,object} Dec 24, 2022
@Jasha10 Jasha10 force-pushed the implement-get_object branch 2 times, most recently from 24d0949 to 47c9ac0 Compare December 24, 2022 10:35
@Jasha10 Jasha10 merged commit 8efa747 into facebookresearch:main Jan 11, 2023
@Jasha10 Jasha10 deleted the implement-get_object branch January 11, 2023 10:53
@omry
Copy link
Collaborator

omry commented Jan 11, 2023

Duh. didn't submit my pending comment.

Comment on lines +79 to +80
obj = _locate(path)
return obj
Copy link
Collaborator

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?

Copy link
Collaborator Author

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.
Copy link
Collaborator

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.

Copy link
Collaborator Author

@Jasha10 Jasha10 Jan 12, 2023

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.

@Jasha10
Copy link
Collaborator Author

Jasha10 commented Nov 7, 2023

Closes #1975

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] hydra.utils.get_object method Document hydra.utils.{get_class,get_method}
3 participants