-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Upgrade from toml to tomlkit library #7468
Conversation
Ok, I think I need to change the way I'm doing the mock toml file |
Hey @syntapy, thank you so much for contributing.
We don't need to maintain a legacy toml library. We don't directly depend on it, and only expect:
Regarding tests, we probably don't need anything other than that the ordering/formatting/comments are preserved on |
372e154
to
33b6b3c
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
050c06f
to
b0b5fdb
Compare
@skshetry Ok, I think I'm ready to have this looked at. I still want to add a test for the format preservation of I dont know whats going on with the linter error though and I can't tell what the error in the code is Also, when I run tests locally, they pass even though theres some tracebacks being shown As one example from running
But it doesn't cause any test in that batch to fail locally |
Another traceback from running that local command in the above comment is below. And also not sure which test this or the above traceback is from. Edit I just checked. I am getting same looking tracebacks on
|
Oh ok, those are the linter error messages. I tried running pre-commit locally on main branch and now I see |
Waiting on python-poetry/tomlkit#187? |
@dberenbaum I think I may have finished the last aspects just now. If so then I believe this PR should be mostly done |
Final failing test under Seems like The test code is in 1: def test_read_params_toml(tmp_dir, dvc):
2: parameters_file = "parameters.toml"
3: dump_toml(parameters_file, {"some": {"path": {"foo": ["val1", "val2"]}}})
4: dep = ParamsDependency(Stage(dvc), parameters_file, ["some.path.foo"])
5: assert dep.read_params() == {"some.path.foo": ["val1", "val2"]} on line 4 in above snippet, I haven't modified this test, so I shouldn't touch it |
The issue described in the above comment is fixed by python-poetry/tomlkit@1cb4c25 so I believe we're waiting for a new release to incorporate that |
Thanks @syntapy! Looks like this should be ready now (see https://github.com/sdispater/tomlkit/releases/tag/0.11.1)? |
I added that release in the |
π€¦ Sorry @syntapy, I missed your updates somehow. |
I mean, its not like I haven't just let this sit anyhow. So yeah, thanks for checking in on this for me |
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.
Changes look alright to me, but all of these commits need to be squashed before we can merge
@skshetry can you take another look at the current PR
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.
Overall it looks great, I have a few cosmetic suggestions. π₯
Also thank you so much for all the upstream patches, and for helping us keep implementation simpler. Also, apologies for the late reviews. :)
Still maintains functionality to use legacy toml lib in case they pass a decoder to the parser
Todo
β I have followed the Contributing to DVC checklist.
π If this PR requires documentation updates, I have created a separate PR (or issue, at least) in dvc.org and linked it here.
Fix lint errors
Functional test to ensure comments preserved on
parse_toml_for_update
Unit test that
parse_toml
: returnsdict
if not preserving comments, orTOMLDocument
if preserving commentsUnit test that
parse_toml_for_update
returnsTOMLDocument
Test that
modify_toml
to preserves formattingThank you for the contribution - we'll try to review it as soon as possible. π
Fixes #7253