Repository navigation
Conversation
folder uploads, Project.upload() and roboflow image annotate opened annotation files and labelmaps without an encoding, so on windows they were decoded with the locale code page (cp1252). a utf-8 class name like café was uploaded as café, and characters like ď failed the whole upload with UnicodeDecodeError.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
on windows, uploading a dataset whose class names aren't plain ascii silently corrupts the names, or fails outright.
the annotation readers open files without an
encoding, so python falls back to the locale code page (cp1252 on a default windows install) while the files are utf-8. hit by:Workspace.upload_dataset/roboflow image upload <dir>):folderparserreading coco / createml json, csv and jsonl, plusload_labelmapfordata.yamland.labelsProject.upload(annotation_path=...), which is what reads voc xml and the other 1:1 annotation filesroboflow image annotate(annotation file and--labelmap)repro on windows 11, python 3.12, main at 6e10039:
the first case is the worse one since nothing fails, the project just ends up with mojibake class names. cjk names mostly go the same way.
changes
encoding="utf-8"on the 4 reads infolderparser.py, the 2 inload_labelmap, the one inProject._annotation_paramsand the 2 inroboflow image annotate_annotation_paramsthe read now goes through thewithhandle instead of a secondopen(), since that line had to change anywaytesting
the ci workflow sets
PYTHONUTF8: 1, which turns this off on the windows runners, so the new test runs the parser in a child process with-X utf8=0,LC_ALL=CandPYTHONCOERCECLOCALE=0. that gives ascii on linux and cp1252 on windows, and it checks coco categories anddata.yamlnames come back unchanged.UnicodeDecodeError ... byte 0x8f, linux/wsl: wrong names / decode error), with it it passespython -m unittest: 1313 tests ok on linux (wsl, python 3.12),tests.util.test_folderparserok on windowsmake check_code_qualityclean,ruff format --check/ruff checkon tests cleannotes
_annotation_paramslines (the leaked handle). this pr fixes that too as a side effect, so whichever lands second just needs a trivial rebase, happy to drop that hunk if you'd rather keep it with fix: close annotation file handle via context manager #484setup.pyhas the same problem withREADME.md(the 🏆 in it), which is probably why ci setsPYTHONUTF8. kept it out of this pr since it's a different path