Skip to content

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

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

Merged
merged 5 commits into from
Dec 30, 2020

Conversation

mrstegeman
Copy link
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 iterative#5119
@shcheklein
Copy link
Member

@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 iterative/dvc#5119
References iterative/dvc#5126
@mrstegeman
Copy link
Contributor Author

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

iterative/dvc.org#2028

@shcheklein
Copy link
Member

@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
Copy link
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
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
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
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
Contributor Author

For my own reference: 2.0 checklist

Copy link
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.

@@ -48,9 +48,15 @@ def _do_test(self, local=False):
self.assertEqual(ret, 0)
self.assertTrue(self._contains(section, field, value, local))

ret = main(base + [section_field, value, "--show-origin"])
Copy link
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
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
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
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
Contributor Author

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

Copy link
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 iterative:master Dec 30, 2020
@mrstegeman mrstegeman deleted the show-origin branch December 30, 2020 22:40
@efiop
Copy link
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 iterative#5126 and iterative#5184 by showing the full merged config when
listing or getting config options.

References iterative#5126
References iterative#5184
References iterative/dvc.org#2028
Fixes iterative#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 iterative/dvc#5119
References iterative/dvc#5126
@mrstegeman
Copy link
Contributor Author

@efiop Done, see #5188

efiop added 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 iterative/dvc.org#2028
Fixes #5119

* Add additional tests.

* Add test for merged config.

* config: rename methods

Co-authored-by: OLOLO ALALA <[email protected]>
shcheklein pushed a commit to iterative/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 iterative/dvc#5119
References iterative/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 <[email protected]>
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