oss-slu / oss-slu/PilotDataSynchronization

inference scripts crash on Windows when output is redirected or piped

Open
#193 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug python
Dominant language
Rust
Stars
4
Forks
8
Avg merge
5d 17h
Merged PRs (30d)
2

Description

Describe the bug
The inference scripts print check, cross and warning characters. On Windows, when stdout is redirected or piped (CI, IDE run panes, Git Bash, > file), Python encodes output with the locale code page, usually cp1252, and those characters raise UnicodeEncodeError. The error handler then raises the same exception again while trying to report it. A real console window is not affected, since Python 3.6 and later write to it as UTF-8 (PEP 528).

To Reproduce

  1. On Windows, run py inference/validate_labels.py > out.txt.
  2. It fails on the first status line with UnicodeEncodeError: 'charmap' codec can't encode character '✓'.

Expected behavior
The scripts run regardless of how output is captured.

Additional context
Setting PYTHONIOENCODING=utf-8 or PYTHONUTF8=1 works around it, which confirms the cause. A code fix would be ASCII status markers, or sys.stdout.reconfigure(encoding="utf-8") at startup. PR #177 replaces some of these in validate_labels.py but not the warning lines. generate_balanced_data.py:218-219 has the same issue. Logger calls in label_generator.py, train_model.py and test_model.py print "--- Logging error ---" tracebacks instead of crashing.

Found while writing the setup documentation in #138 / #178.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run py inference/validate_labels.py > out.txt on Windows to reproduce the encoding failure. Inspect inference/validate_labels.py, generate_balanced_data.py:218-219, and the logging paths in label_generator.py, train_model.py, and test_model.py. Done means captured or piped output runs without UnicodeEncodeError or logging-error tracebacks.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
67/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.