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

Added explicit utf-8 encoding parameter to write methods #2010

Merged

Conversation

cansik
Copy link
Contributor

@cansik cansik commented May 31, 2024

As in #999 I experienced the same encoding issue on Windows (see trace-log). Since the write commands should be explicitly use the UTF-8 encoding, I have replaced it at the occurrences in the code.

Error executing job with overrides: []
Traceback (most recent call last):
  File "D:\supergradients-lab\train.py", line 137, in <module>
    main()
  File "D:\supergradients-lab\train.py", line 133, in main
    _main()
  File "C:\envs\supergradients-lab\Lib\site-packages\hydra\main.py", line 94, in decorated_main
    _run_hydra(
  File "C:\envs\supergradients-lab\Lib\site-packages\hydra\_internal\utils.py", line 394, in _run_hydra
    _run_app(
  File "C:\envs\supergradients-lab\Lib\site-packages\hydra\_internal\utils.py", line 457, in _run_app
    run_and_report(
  File "C:\envs\supergradients-lab\Lib\site-packages\hydra\_internal\utils.py", line 223, in run_and_report
    raise ex
  File "C:\envs\supergradients-lab\Lib\site-packages\hydra\_internal\utils.py", line 220, in run_and_report
    return func()
           ^^^^^^
  File "C:\envs\supergradients-lab\Lib\site-packages\hydra\_internal\utils.py", line 458, in <lambda>
    lambda: hydra.run(
            ^^^^^^^^^^
  File "C:\envs\supergradients-lab\Lib\site-packages\hydra\_internal\hydra.py", line 132, in run
    _ = ret.return_value
        ^^^^^^^^^^^^^^^^
  File "C:\envs\supergradients-lab\Lib\site-packages\hydra\core\utils.py", line 260, in return_value
    raise self._return_value
  File "C:\envs\supergradients-lab\Lib\site-packages\hydra\core\utils.py", line 186, in run_job
    ret.return_value = task_function(task_cfg)
                       ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\supergradients-lab\train.py", line 68, in _main
    results = trainer.train(
              ^^^^^^^^^^^^^^
  File "D:\supergradients-lab\super-gradients\src\super_gradients\training\sg_trainer\sg_trainer.py", line 1253, in train
    self._initialize_sg_logger_objects(additional_configs_to_log)
  File "D:\supergradients-lab\super-gradients\src\super_gradients\training\sg_trainer\sg_trainer.py", line 2022, in _initialize_sg_logger_objects
    self.sg_logger = sg_logger_cls(**sg_logger_params)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\supergradients-lab\super-gradients\src\super_gradients\common\sg_loggers\base_sg_logger.py", line 99, in __init__
    self._init_log_file()
  File "D:\supergradients-lab\super-gradients\src\super_gradients\common\environment\ddp_utils.py", line 68, in wrapper
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "D:\supergradients-lab\super-gradients\src\super_gradients\common\sg_loggers\base_sg_logger.py", line 154, in _init_log_file
    AutoLoggerConfig.setup_logging(filename=self.logs_path, copy_already_logged_messages=True)
  File "D:\supergradients-lab\super-gradients\src\super_gradients\common\auto_logging\auto_logger.py", line 126, in setup_logging
    self._setup_logging(filename, copy_already_logged_messages, filemode, log_level)
  File "D:\supergradients-lab\super-gradients\src\super_gradients\common\auto_logging\auto_logger.py", line 56, in _setup_logging
    dst.write(src.read())
  File "C:\envs\supergradients-lab\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u2713' in position 127114: character maps to <undefined>

@BloodAxe
Copy link
Contributor

BloodAxe commented Jun 2, 2024

Thanks for your PR!

Appreciate taking a time and updating that. Before we continue, can you please update your PR to contain only signed commits? https://github.com/Deci-AI/super-gradients/blob/master/CONTRIBUTING.md#signed-commits That is a hard requirement for a PRs to be accepted.

Thanks in advance!

added explicit utf-8 encoding parameter to write methods signed
@cansik cansik force-pushed the hotfix/explicit-utf8-encoding-on-write branch from 75e1290 to b88965f Compare June 2, 2024 17:50
@cansik
Copy link
Contributor Author

cansik commented Jun 2, 2024

@BloodAxe Done.

Copy link
Contributor

@BloodAxe BloodAxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@BloodAxe BloodAxe merged commit af93ec3 into Deci-AI:master Jun 3, 2024
5 of 6 checks passed
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

Successfully merging this pull request may close these issues.

2 participants