Skip to content

Conversation

@skshetry
Copy link
Collaborator

@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 efiop, pared and pmrowla August 18, 2020 11:38
@skshetry skshetry self-assigned this Aug 18, 2020
@skshetry

This comment has been minimized.

from collections import defaultdict

import dpath.util
import toml
Copy link
Collaborator 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 ._yaml import * # noqa, pylint: disable=wildcard-import

PARSERS = defaultdict(lambda: parse_yaml) # noqa: F405
PARSERS.update({".toml": parse_toml}) # noqa: F405
Copy link
Collaborator 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 treeverse:master Aug 19, 2020
@skshetry skshetry deleted the yaml1.2 branch August 19, 2020 14:57
skshetry added a commit to treeverse/dvc.org that referenced this pull request Sep 8, 2020
shcheklein pushed a commit to treeverse/dvc.org that referenced this pull request Oct 19, 2020
* Document that YAML files are expected to be in YAML1.2

Refer treeverse/dvc#4415

* remove note, embed the note in the paragraph

* Apply suggestions from code review

Co-authored-by: Jorge Orpinel <jorgeorpinel@users.noreply.github.com>

* Restyled by prettier

Co-authored-by: Jorge Orpinel <jorgeorpinel@users.noreply.github.com>
Co-authored-by: Restyled.io <commits@restyled.io>
@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