-
Notifications
You must be signed in to change notification settings - Fork 1.2k
remote: fix remote default call with no arguments #2821
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
Conversation
remote default command with no arguments now returns default remote instead of setting default remote to None. Fixes #2813
Noticed too late that this probably breaks --unset option, I'll fix it. |
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.
Thanks a lot for the pull request! Could you please add a test for this?
The rest looks good to me)
@kaiogu, adding some more guidance, the test would be under You can take a look at other tests to get an idea of how we usually test stuff. In general, there's So the test would be something like: def test_show_default(dvc_repo, caplog):
assert main(["remote", "default", "foo"]) == 0
assert main(["remote", "default"]) == 0
assert "foo" in caplog.text It uses a DVC repository and run the commands |
LGTM, we can merge after the test is written. |
Hi @pared, thanks for the info! I could write a test over the weekend if this isn't that time critical. I've got no experience wit pytest (or unittest) but would be willing to learn. |
@kaiogu please take your time, if you need our help, feel free to write here, or message us directly on our discord :) |
@kaiogu, it is better to use |
tests/func/test_remote.py
Outdated
@@ -145,6 +145,12 @@ def test(self): | |||
self.assertEqual(default, None) | |||
|
|||
|
|||
def test_show_default(caplog): |
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.
No need to remove
def test_show_default(caplog): | |
def test_show_default(dvc_repo, caplog): |
as it makes the test run in the repo itself instead of in the test env. I think you've removed it because DS was complaining, but it was wrong there 🙂
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.
That's right. 😄 Some tool said something about prepending the argument with unused or something like that, but I can't find the message anymore. So should I just keep the argument and let the build fail?
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.
@kaiogu Yes, DS will probably fail, but the tests themselves (run on travis) won't, so we are fine 🙂
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.
Ill accept after this dvc_repo
is reintroduced. :)
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.
@pared Done :)
@MrOutis Or we could call |
So I checked again and if I run the test exactly as recommended in the contributions guidelines it fails on my end to. @efiop The above does not work in the test environment though. I tried wrapping the body of the test with Just doing the solution proposed by @MrOutis works, but I'd change Alternatively, the recommendation in the python logging docs is to actually use print statements instead of logging in the call to |
tests/func/test_remote.py
Outdated
def test_show_default(caplog): | ||
assert main(["remote", "default", "foo"]) == 0 | ||
assert main(["remote", "default"]) == 0 | ||
assert "foo" == caplog.record_tuples[0][2] |
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.
How about using caplog.records[0].message
?
Seems more readable than record_tuples
:)
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.
Obsolete after efiop comment
@kaiogu You are absolutely right about |
Turns out that the argument was needed after all
Python logging recommends using print instead of logging for ordinary output of command line program. Also changed the test to reflect this.
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.
Perfect! Thank you so much! 🙏
Thank you for the guidance! Happy to contribute! 😄 |
@kaiogu 0.71.0 is out, please upgrade and give it a try 🙂 Thank you! |
remote default command with no arguments now returns default remote instead of
setting default remote to None.
Fixes #2813
❗ Have you followed the guidelines in the Contributing to DVC list?
📖 Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.
❌ Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addresses. Please review them carefully and fix those that actually improve code or fix bugs.
Thank you for the contribution - we'll try to review it as soon as possible. 🙏