-
-
Notifications
You must be signed in to change notification settings - Fork 650
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
[Bug] root logger has FileHandler after using hydra_task_runner
#833
Comments
Thanks for reporting. |
Actually I wanted to unit test my app that uses hydra. I first tried Compose API and found that |
You can pass return_hydra_conf=true to compose to get the Hydra config node. |
Thank you for your kind explanation! I didn't notice HydraConfig singleton has to be initialized. I'll give it a try. |
Well, normally it is initialized automatically by @hydra.main(). It just occurred to me after seeing your question that initializing it might be a solution in your situation. The problem you are seeing is likely due to the TaskTestFunction shutting down the logging on exit. During the run of the task the logging subsystem is initialized and it's shutdown after the task. |
🐛 Bug
Once
hydra_task_runner
is called from a unit test, a FileHandler seems to be registered to the root logger oflogging
. When a logger tries to log something from another test, it fails because of the staled FileHandler.I could successfully make the tests pass by manually removing the FileHandler, i.e., adding
getLogger().handlers.pop()
at the end oftest_1()
. But it doesn't seem to be an elegant solution. Probably is it possible to remove additional handlers inTaskTestFunction.__exit__()
or somewhere?To reproduce
Then run pytest.
** Stack trace/error message **
System information
The text was updated successfully, but these errors were encountered: