[Bug] return configuration variable from hydra.main function
See original GitHub issue🐛 Hydra return config variable
I try to return the config from a function but get a None return instead. I am trying to keep the config as a global variable for other modules to import the config
To reproduce
import hydra
from omegaconf import DictConfig
from runner import Runner
@hydra.main(config_path="config_hydra/config.yaml")
def my_app(cfg : DictConfig) -> DictConfig:
# print(cfg.pretty())
return cfg
if __name__ == "__main__":
cfg = my_app()
print(cfg)
** Minimal Code/Config snippet to reproduce **
** Stack trace/error message **
None
// Paste the bad output here!
Expected Behavior
System information
Additional context
Add any other context about the problem here.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Specializing configuration - Hydra
We want to specialize the config based on the choice of the selected dataset and model: Furthermore, we only want to do it...
Read more >python 3.x - Using hydra.main on main method - Stack Overflow
I'm running a requests call on an API endpoint, whose request params are hidden in a config file and I decided to try...
Read more >Complete tutorial on how to use Hydra in Machine Learning ...
@hydra.main(config_path="config", config_name="config") This is the main decorator function that is used when any function requires contents ...
Read more >Configuration Management For Data Science Made Easy With ...
Here's my FREE 7-step guide to help you consistently design great software: https://arjancodes.com/designguide.Dealing with configuration ...
Read more >Tutorial: Learning Hydra for configuring ML experiments
Sometimes, we might need to load our configuration file outside the main function. While we can do this with OmegaConf , it does...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you! That helps.
I encountered this thread because some of the debugger frames were getting lost when there is an error in the function encapsulated by the Hydra decorator. Hence I was trying to get the config in the same way as @noklam did.
It turned out it’s already solved in this PR #930
To not lose any debugger stack frames, set HYDRA_FULL_ERROR to 1. That should do the trick.
I hope that helps!