-
Notifications
You must be signed in to change notification settings - Fork 559
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
Improve save and load repocard metadata #355
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the behavior when local_path does not exist, where we still want to create a file and output the metadata block
(@LysandreJik was right that we needed to add a test for this 😆 )
Other than that, looks good!
Fixed that and added a test |
I'm proposing to replace pyyaml by ruamel.yaml, which is better maintained and optimized for safe loading with preservation of the existing formatting. WDYT @LysandreJik ? |
I'd much rather we stay with the |
it's also what we use in our other codebases |
The reason I choose Real bugs found in the hub while using PyYAML
I pushed the rollback to PyYAML, but it's your call. It's not usable for my case anyway, I'd have to patch a local copy of hf_hub for scripting README.md metadata bulk-corrections |
Thank you for the explanation @elishowk - this explanation, along with a PR description would be very useful to understand the core issue and the solution you provide, as it's impossible to review without having the full context. Now that you have explained, I understand why you chose |
Hi @LysandreJik, Sorry for the lack of context. I started this PR and discovered bugs on the road while working on real-world metadata, and didn't always remembered to explain all the context... So, now I pushed back I completed the top-description of this PR #355 (comment) in order to show what happens with the new test case when keeping I hope this give you all the elements to review 😅 Cheers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the explanation. Looks good, only left a nit.
Thank you @elishowk! Feel free to merge when green. |
Problem
Loading and Saving repocard shouldn't modify implicitely the YAML.
Summary
Newlines
Replacing pyyaml by ruamel.yaml
RepocardTest.test_metadata_roundtrip
that works fine with ruamel.yaml and not with pyyaml.How tests fail with pyyaml ?
Bug 1 : 'no' string parsed to False
Bug 2 : UTF-8 string broken.