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

Logging path hardcoded to '/dev/null', which does not exist on Windows #141

Open
grschneider opened this issue Jul 31, 2024 · 0 comments
Open

Comments

@grschneider
Copy link

https://github.com/PixArt-alpha/PixArt-sigma/blob/master/diffusion/utils/logger.py#L21 hardcodes the log path to "/dev/null".
On Windows11 this gives:

Traceback (most recent call last):
  File "C:\Users\Greg\Desktop\PixArt-sigma\scripts\interface.py", line 156, in <module>
    logger = get_root_logger()
  File "C:\Users\Greg\Desktop\PixArt-sigma\diffusion\utils\logger.py", line 22, in get_root_logger
    logger = get_logger(name=name, log_file=log_file, log_level=log_level)
  File "C:\Users\Greg\Desktop\PixArt-sigma\diffusion\utils\logger.py", line 68, in get_logger
    file_handler = logging.FileHandler(log_file, 'w')
  File "C:\Users\Greg\.conda\envs\pixart\lib\logging\__init__.py", line 1146, in __init__
    StreamHandler.__init__(self, self._open())
  File "C:\Users\Greg\.conda\envs\pixart\lib\logging\__init__.py", line 1175, in _open
    return open(self.baseFilename, self.mode, encoding=self.encoding,
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\dev\\null'

What about using https://docs.python.org/3/library/os.html#os.devnull or passing log_file=None on Windows instead?

>>> import os
>>> os.devnull
'nul'
>>> import logging
>>> logger = logging.getLogger('test')
>>> logging.FileHandler(os.devnull, 'w')
<FileHandler \\.\nul (NOTSET)>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant