Skip to content

Conversation

@ghost
Copy link

@ghost ghost commented Jan 19, 2020

Close #2309

],
)
def test_commands_outside_dvc_repository(tmp_dir, cmd):
assert 253 == main(cmd)
Copy link
Author

Choose a reason for hiding this comment

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

253 is returned when NotDvcRepoError is raised.

efiop
efiop previously requested changes Jan 19, 2020
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.

This issue is relevant for dvc config in general and should be fixed there instead. dvc_dir defaults to None and so https://github.com/iterative/dvc/blob/master/dvc/config.py#L261 loads empty configs with filename == None, adjusts them and then doesn't save them because of filename == None. Need a general approach here.

@ghost ghost requested a review from efiop January 19, 2020 08:31
@ghost ghost dismissed efiop’s stale review January 19, 2020 08:31

@efiop, moved the logic up to config

COMPILED_SCHEMA = Schema(SCHEMA)

def __init__(self, dvc_dir=None, validate=True):
def __init__(self, dvc_dir=None, validate=True, verify_repo=False):
Copy link
Author

@ghost ghost Jan 19, 2020

Choose a reason for hiding this comment

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

Added a new parameter because I didn't want to mess up with any previous logic dealing with having an empty dvc_dir.

Copy link
Contributor

Choose a reason for hiding this comment

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

@MrOutis This looks like a hack rather than a proper solution 🙂

Copy link
Author

Choose a reason for hiding this comment

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

@efiop, could you explain? Not sure how to proceed with such observation 😅

Copy link
Contributor

Choose a reason for hiding this comment

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

You are hacking your way through the bug instead of solving the bug. This verify_repo shouldn't be an option at all. Config should always raise if you try to modify in-repo config when there isn't one.

remote_config.modify("myremote", "gdrive_client_id", "xxx")


@pytest.mark.parametrize(
Copy link
Contributor

Choose a reason for hiding this comment

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

Solution is for config in general, but tests are for remote specifically, not nice 🙂Also not clear why are you testing CLI again and not API?

Copy link
Author

Choose a reason for hiding this comment

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

My bad, that's a left over. Those tests are not relevant since they were replaced for the ones in test_config.py

Copy link
Author

Choose a reason for hiding this comment

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

Copy link
Author

Choose a reason for hiding this comment

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

I prefer testing the CLI in this case, it is more complete, but if you want, I use the API.

Copy link
Contributor

Choose a reason for hiding this comment

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

@MrOutis CLI is a dumb wrapper for API. We always test API, so let's do the same here. If you want to check that CLI returns proper codes on corresponding exceptions, just add a unit test to tests/unit/command/.

@efiop
Copy link
Contributor

efiop commented Jan 28, 2020

Ok, looks like there is no good quick and neat way to solve it, it will look like a hack in any case. What we need here is a redesign. 🙁

@efiop
Copy link
Contributor

efiop commented Jan 30, 2020

Closing for now, this will require a config redesign first.

@efiop efiop closed this Jan 30, 2020
@ghost ghost deleted the fix-3191 branch January 31, 2020 04:37
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: dvc config doesn't throw an error when used outside of a dvc repository without --system or --global

1 participant