Skip to content
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

Move to yaml1.2 #4415

Merged
merged 2 commits into from
Aug 19, 2020
Merged

Move to yaml1.2 #4415

merged 2 commits into from
Aug 19, 2020

Conversation

skshetry
Copy link
Member

@skshetry skshetry commented Aug 18, 2020

This PR:

Thank you for the contribution - we'll try to review it as soon as possible. πŸ™

Closes #4281

This commit:
* gets rid of pyyaml
* uses ruamel everywhere
* tries to unite toml and yaml

However, this will require a few more changes that will come soonish.
Eg: Current `parse_yaml` and `parse_toml` behavior could be error-prone,
so, it's better to introduce `tree` inside these serialization methods
(which I will try to tackle next).

Another is, yaml load can be slow for json. We could speed it up just by
using `json.load(s)` here (also in upcoming patch).
@skshetry skshetry requested review from pmrowla, efiop and pared August 18, 2020 11:38
@skshetry skshetry self-assigned this Aug 18, 2020
@skshetry

This comment has been minimized.

@@ -2,12 +2,11 @@
from collections import defaultdict

import dpath.util
import toml
Copy link
Member Author

@skshetry skshetry Aug 18, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pmrowla, tomlkit preserves ordering and comments. We can move to it in the future.

from ._toml import * # noqa, pylint: disable=wildcard-import
from ._yaml import * # noqa, pylint: disable=wildcard-import

PARSERS = defaultdict(lambda: parse_yaml) # noqa: F405
PARSERS.update({".toml": parse_toml}) # noqa: F405
Copy link
Member Author

@skshetry skshetry Aug 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it'd be good to have JSON utils after the upcoming PR with trees are done. Maybe even move to ujson as it has now wheels on all platforms.

In [1]: %timeit json.loads('{"ja": "son"}')
2.32 Β΅s Β± 35 ns per loop (mean Β± std. dev. of 7 runs, 100000 loops each)

In [2]: %timeit YAML(typ='safe').load('{"ja": "son"}')
180 Β΅s Β± 1.28 Β΅s per loop (mean Β± std. dev. of 7 runs, 10000 loops each)

In [3]: %timeit ujson.loads('{"ja": "son"}')
372 ns Β± 13.4 ns per loop (mean Β± std. dev. of 7 runs, 1000000 loops each)

@skshetry skshetry mentioned this pull request Aug 19, 2020
2 tasks
@efiop efiop merged commit 1474503 into iterative:master Aug 19, 2020
@skshetry skshetry deleted the yaml1.2 branch August 19, 2020 14:57
skshetry added a commit to iterative/dvc.org that referenced this pull request Sep 8, 2020
shcheklein pushed a commit to iterative/dvc.org that referenced this pull request Oct 19, 2020
* Document that YAML files are expected to be in YAML1.2

Refer iterative/dvc#4415

* remove note, embed the note in the paragraph

* Apply suggestions from code review

Co-authored-by: Jorge Orpinel <[email protected]>

* Restyled by prettier

Co-authored-by: Jorge Orpinel <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
@jorgeorpinel jorgeorpinel mentioned this pull request Dec 22, 2020
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LockFile class dump/load uses different libraries
4 participants