oss-slu / oss-slu/PilotDataSynchronization
inference scripts crash on Windows when output is redirected or piped
Nobody has claimed this yet.
- 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
- On Windows, run
py inference/validate_labels.py > out.txt. - 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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