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
Properly handle decorated functions #2303
Conversation
Hi @dolfinus! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
I think this should be fine unguarded |
Hmm, I may have been overly eager in giving approval above -- ideally we should add some documentation before merging this. |
Do you mean adding example of using |
I guess so. Or maybe just a sentence (e.g. in the docstring of the I'm worried that if we don't document this somewhere, future users will be ignorant of this special treatment of |
@Jasha10 done |
Any chance this change will be released as 1.2.1? |
@dolfinus I've just uploaded Hydra |
Motivation
I've implemented some decorator which wraps the
main
function, accepts argument of type DictConfig to have access to job config, and performs some operations:But when I try to use it like this:
I get an error:
This is because
hydra
tries to detect config path based on file location there function is stored, and instead ofmain
it is searching forenter_context
function, which is stored in a file in '/usr/local/lib/python3.7/conf' directory:hydra/hydra/_internal/utils.py
Line 53 in dd9e83a
To avoid this, I've added a block with upwrapping all the decorators up to the core function, using
__wrapped__
attribute added by@functools.wraps
:https://github.com/python/cpython/blob/3f2dd0a7c0b1a5112f2164dce78fcfaa0c4b39c7/Lib/functools.py#L61
Have you read the Contributing Guidelines on pull requests?
Yes
Test Plan
Added
app_with_config_decorated
and related testRelated Issues and PRs
None