-
-
Notifications
You must be signed in to change notification settings - Fork 659
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
Allow instantiation from class methods #498
Allow instantiation from class methods #498
Conversation
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.
Hi, thanks for the PR.
See my comments.
bd36485
to
1439acc
Compare
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.
Starting to look good.
As for the failing CI: |
This pull request introduces 1 alert when merging 52e99cc into 67a525b - view on LGTM.com new alerts:
|
ping |
The test failues look like they are due to the upgrade in omegaconf. Do you prefer a |
I prefer rebase. |
* instantiate an object from a class method of that object * add tests for this * simplify get_static_method function Signed-off-by: David Pollack <d.pollack@solvemate.com>
* works with class, classmethod, or staticmethod * still requires the user to specify the module * simplifies importing of all types into a single method Signed-off-by: David Pollack <david@da3.net>
Signed-off-by: David Pollack <david@da3.net>
this is a reimplementation of the pydoc.locate function. That function would attempt to load a module from beginning to end and if any link in the chain did not load properly then it would fail. The reimplemented function searches for the module to load from the end of the path to the beginning. Additionally, this reimplementation will raise exceptions instead of returning None if the path cannot be located. Signed-off-by: David Pollack <david@da3.net>
cbe1a65
to
ae26554
Compare
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. A few more comments about the docs and the tests.
ae26554
to
6d57655
Compare
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.
awesome. almost there.
Alright, I think that I solved the mypy issues by using As for the documentation, let me know what you think. I tried to keep it as compact as possible, but may be doing too many things with the same class. P.S. the win37 failure looks unrelated to this PR. Looks like the conda servers glitched. |
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.
I would like to split hydra.utils into hydra.utils for public API and some other internal class with non public API. but this can be a followup diff.
Made one last suggestion.
Co-Authored-By: Omry Yadan <omry@fb.com>
As for the docs, they look good here but I would like to see them in the website. |
I didn't but I'll check it tomorrow |
Split the current objects docs into two sections. Moved the call section to the top and the db example to the bottom. Renamed the header to reflect the ability to call functions and methods.
Awesome. edited the doc a bit and added the issue #505 for API cleanup before 1.0. |
Ohh, forgot. |
Awesome, thanks David! |
Signed-off-by: David Pollack d.pollack@solvemate.com
Motivation
I wanted to use hydra with the huggingface transfromers library and they extensively use a class method named
from_pretrained
.Currently one could do this by using the
get_static_method
and then manually converting theparams
key and passing them to the gotten method. However that's not very straight forward or intuitive and this doesn't add much logic to the utility function.Have you read the Contributing Guidelines on pull requests?
Yes - passed tests in test_utils.py and flake8
Test Plan
I added a test that tests the basic case.