Skip to content
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] Importing ForwardHookManager messes up logging to file globally #465

Closed
nirgoren opened this issue May 9, 2024 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@nirgoren
Copy link

nirgoren commented May 9, 2024

Describe the bug
Importing ForwardHookManager via from torchdistill.core.forward_hook import ForwardHookManager causes logging to file not to work properly.

import logging
from torchdistill.core.forward_hook import ForwardHookManager

logger = logging.getLogger(__name__)
logging.basicConfig(filename='test.log', encoding='utf-8', level=logging.DEBUG)
logging.debug('This message should go to the log file')
logger.debug('This should also go to the log file')

The messages do not go to the log file. Commenting out from torchdistill.core.forward_hook import ForwardHookManager, the messages go to the log file as expected.

To Reproduce
Provide

  1. Exact command to run your code - provided above
  2. Whether or not you made any changes in Python code (if so, how you made the changes?) - Did not make changes
  3. YAML config file - not relevant
  4. Log file - not relevant

Expected behavior
A clear and concise description of what you expected to happen.
The messages should go the log file, global logging behaviour should not change due to the import.

Environment (please complete the following information):

  • OS: [e.g. Ubuntu 20.04 LTS] macOS Sonoma 14.4.1
  • Python ver. [e.g. 3.8] 3.11.9
  • torchdistill ver. [e.g. v0.3.2] 1.1.0

Additional context
Probably related to the logging configuration in torchdistill/common/constant.py

@nirgoren nirgoren added the bug Something isn't working label May 9, 2024
@yoshitomo-matsubara
Copy link
Owner

Hi @nirgoren ,

Thank you for the feedback.

The behavior is expected. As mentioned, torchdistill.core.forward_hook indirectly imports torchdistill/common/constant.py and sets basicConfig.

I am currently on leave and will think about some workaround.

@yoshitomo-matsubara
Copy link
Owner

Hi @nirgoren

It should be resolved now. The update will be available in the next PyPI package release.

Feel free to re-open the issue if it doesn't resolve your issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants