Reputation: 1360
Is there an option to get from the function under @hydra.main decorator the configuration object as a dictionary?
I tried something like this, but it returns None
@hydra.main(config_path="conf", config_name="config")
def my_app(cfg) -> dict:
print(cfg) # --> work, the cfg object exists inside the function scope
return cfg
a = my_app()
print(a)
I know I can use the compose API, but I prefer not to use it due to its limited functionality (Tab completion, Multirun etc.)
Upvotes: 4
Views: 1564
Reputation: 33646
No.
@hydra.main()
does not return a value intentionally. (What would you expect the return value to be if you use --multirun
and your function returns multiple times?)
Call your logic from within your @hydra.main
function and pass the cfg object to it.
Upvotes: 3