Skip to content

cli: config: add support for --show-origin#5126

Merged
efiop merged 5 commits into
treeverse:masterfrom
mrstegeman:show-origin
Dec 30, 2020
Merged

cli: config: add support for --show-origin#5126
efiop merged 5 commits into
treeverse:masterfrom
mrstegeman:show-origin

Conversation

@mrstegeman
Copy link
Copy Markdown
Contributor

Support the --show-origin option for config, which, similar to git,
prefixes each config option with the source file it originated from.

Fixes #5119

Thank you for the contribution - we'll try to review it as soon as possible. 🙏

Support the --show-origin option for config, which, similar to git,
prefixes each config option with the source file it originated from.

Fixes treeverse#5119
@shcheklein
Copy link
Copy Markdown
Contributor

@mrstegeman hey! 👋 Thanks for the PR! I see that you set the docs checkbox, but I don't see any issues/PRs in the docs repo? Is it still WIP?

mrstegeman added a commit to mrstegeman/dvc.org that referenced this pull request Dec 17, 2020
Support the --show-origin option for config, which, similar to git,
prefixes each config option with the source file it originated from.

References treeverse/dvc#5119
References treeverse/dvc#5126
@mrstegeman
Copy link
Copy Markdown
Contributor Author

Ah, apologies. I was thinking it was just documentation in this repo.

treeverse/dvc.org#2028

@shcheklein
Copy link
Copy Markdown
Contributor

@mrstegeman no worries at all (the layout is not very usual indeed when you have a separate repo with docs). Thanks for the PR, we'll take a look asap!! Give us please a bit of time for this.

@shcheklein shcheklein requested a review from efiop December 18, 2020 03:40
Comment thread dvc/command/config.py Outdated
Copy link
Copy Markdown
Contributor

@efiop efiop left a comment

Choose a reason for hiding this comment

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

Hi @mrstegeman !

Thanks for the PR! 🙏 Looks good!

I totally forgot that we still didn't introduce --repo flag for dvc config and didn't switch to loading the merged config in dvc config without --repo/--local/--global/--system 🤦‍♂️ 🤦‍♂️ 🤦‍♂️ It is on our 2.0 todo list though. Which would make the task a bit harder :)

@mrstegeman
Copy link
Copy Markdown
Contributor Author

I totally forgot that we still didn't introduce --repo flag for dvc config and didn't switch to loading the merged config in dvc config without --repo/--local/--global/--system 🤦‍♂️ 🤦‍♂️ 🤦‍♂️ It is on our 2.0 todo list though. Which would make the task a bit harder :)

Yep, that was the biggest difference I noticed versus git config --list. It shouldn't make the logic much more difficult, though.

@efiop
Copy link
Copy Markdown
Contributor

efiop commented Dec 18, 2020

Yep, that was the biggest difference I noticed versus git config --list. It shouldn't make the logic much more difficult, though.

@mrstegeman Would you be willing to introduce the changes for that? Our master branch is currently preparing for 2.0, so we can do backward-incompatible changes without any problems. But we could merge this first and then think about the next step too, no problem.

@mrstegeman
Copy link
Copy Markdown
Contributor Author

@efiop The two changes are really independent of each other, but should be done separately. It probably makes the most sense to just merge this as is, and then figure out the logic to merge and print all of the configs in a separate PR. I'd be happy to take on the other PR as well, after this is merged.

@mrstegeman
Copy link
Copy Markdown
Contributor Author

For my own reference: 2.0 checklist

Copy link
Copy Markdown
Contributor

@efiop efiop left a comment

Choose a reason for hiding this comment

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

@mrstegeman Sounds good!

Ok, this PR looks good, but we need to add a test that tests the output. Please see tests/func/test_config.py::test_config_remote for an example of using caplog.

Comment thread dvc/command/config.py
Comment thread tests/func/test_config.py
self.assertEqual(ret, 0)
self.assertTrue(self._contains(section, field, value, local))

ret = main(base + [section_field, value, "--show-origin"])
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we parametrize these tests?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The tests are being reworked in #5179.

@karajan1001
Copy link
Copy Markdown
Contributor

I totally forgot that we still didn't introduce --repo flag for dvc config and didn't switch to loading the merged config in dvc config without --repo/--local/--global/--system 🤦‍♂️ 🤦‍♂️ 🤦‍♂️ It is on our 2.0 todo list though. Which would make the task a bit harder :)

@efiop
Excuse me, any details for the coming changes in 2.0? Currently dvc config --list and dvc config behave differently in default ( without --repo/--local/--global/--system)? dvc config only changes --repo config while dvc config --list shows a merged one?

@efiop
Copy link
Copy Markdown
Contributor

efiop commented Dec 29, 2020

I totally forgot that we still didn't introduce --repo flag for dvc config and didn't switch to loading the merged config in dvc config without --repo/--local/--global/--system man_facepalming man_facepalming man_facepalming It is on our 2.0 todo list though. Which would make the task a bit harder :)

@efiop
Excuse me, any details for the coming changes in 2.0? Currently dvc config --list and dvc config behave differently in default ( without --repo/--local/--global/--system)? dvc config only changes --repo config while dvc config --list shows a merged one?

No, dvc config --list and dvc config(in read mode) behave the same by default, but the problem is that they show repo level config by default, and not the merged config. But if you try to write something with it - it writes to repo config by default, which is correct. So in read mode we should use merged config and in write mode - continue using repo config by default. This is the same behavior as git config has.

@efiop efiop mentioned this pull request Dec 29, 2020
2 tasks
@mrstegeman
Copy link
Copy Markdown
Contributor Author

Apologies for the delay. I added a couple tests for the output.

Comment thread tests/func/test_config.py Outdated
Copy link
Copy Markdown
Contributor

@efiop efiop left a comment

Choose a reason for hiding this comment

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

Thank you!

@efiop efiop merged commit 34ed545 into treeverse:master Dec 30, 2020
@mrstegeman mrstegeman deleted the show-origin branch December 30, 2020 22:40
@efiop
Copy link
Copy Markdown
Contributor

efiop commented Dec 30, 2020

@mrstegeman I've added --repo flag and changed dvc config behaviour in #5179 (we need it for the upcoming 2.0 soon anyway), but temporarily forbid the use of --show-origin without --system/--global/--repo/--local flag so you could continue your work on a proper implementation as we've discussed here before. Please feel free to send a PR for that 🙂

mrstegeman added a commit to mrstegeman/dvc that referenced this pull request Dec 31, 2020
Builds on treeverse#5126 and treeverse#5184 by showing the full merged config when
listing or getting config options.

References treeverse#5126
References treeverse#5184
References treeverse/dvc.org#2028
Fixes treeverse#5119
mrstegeman added a commit to mrstegeman/dvc.org that referenced this pull request Dec 31, 2020
Support the --show-origin option for config, which, similar to git,
prefixes each config option with the source file it originated from.

References treeverse/dvc#5119
References treeverse/dvc#5126
@mrstegeman
Copy link
Copy Markdown
Contributor Author

@efiop Done, see #5188

efiop pushed a commit that referenced this pull request Jan 4, 2021
* cli: config: show merged config with --show-origin

Builds on #5126 and #5184 by showing the full merged config when
listing or getting config options.

References #5126
References #5184
References treeverse/dvc.org#2028
Fixes #5119

* Add additional tests.

* Add test for merged config.

* config: rename methods

Co-authored-by: OLOLO ALALA <ruslan@iterative.ai>
shcheklein pushed a commit to treeverse/dvc.org that referenced this pull request Feb 4, 2021
* cli: config: add docs for --show-origin

Support the --show-origin option for config, which, similar to git,
prefixes each config option with the source file it originated from.

References treeverse/dvc#5119
References treeverse/dvc#5126

* Update wording.

* Add note about the options near config file locations.

* Update content/docs/command-reference/config.md

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

config: add support for --show-origin

4 participants