bug causes error uploading to huggingface, unicode issue on windows. #450
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 this does
This PR resolves a bug in the LeRobot repository that causes an error when uploading a dataset to Huggingface on Windows due to a Unicode encoding issue. The problem arises because Windows, by default, uses cp1252 encoding, which cannot handle certain Unicode characters, such as emojis. The error is caused by the dataset card containing an emoji.
Error trace:
The error produced is 'Traceback (most recent call last):
File "D:\dev\lerobot\lerobot\scripts\control_robot.py", line 885, in
record(robot, **kwargs)
File "D:\dev\lerobot\lerobot\scripts\control_robot.py", line 681, in record
push_dataset_card_to_hub(repo_id, revision="main", tags=tags)
File "D:\dev\lerobot\lerobot\scripts\push_dataset_to_hub.py", line 124, in push_dataset_card_to_hub
card.push_to_hub(repo_id=repo_id, repo_type="dataset", revision=revision)
File "C:\Users\tblocal.conda\envs\lerobot\lib\site-packages\huggingface_hub\repocard.py", line 277, in push_to_hub
tmp_path.write_text(str(self))
File "C:\Users\tblocal.conda\envs\lerobot\lib\pathlib.py", line 1155, in write_text
return f.write(data)
File "C:\Users\tblocal.conda\envs\lerobot\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 '\U0001f917' in position 102: character maps to
This fix removes the emoji 🤗 which prevents UnicodeEncodeError.
How it was tested
python lerobot/scripts/control_robot.py record --robot-path lerobot/configs/robot/koch_original.yaml --fps 30 --root data --repo-id RESOLVER101757/koch_test_2 --tags tutorial --warmup-time-s 5 --episode-time-s 30 --reset-time-s 30 --num-episodes 1
How to checkout & try? (for the reviewer)
python lerobot/scripts/control_robot.py record --robot-path lerobot/configs/robot/koch_original.yaml --fps 30 --root data --repo-id RESOLVER101757/koch_test_2 --tags tutorial --warmup-time-s 5 --episode-time-s 30 --reset-time-s 30 --num-episodes 1