Skip to content

Conversation

@godfryd
Copy link
Contributor

@godfryd godfryd commented Oct 29, 2020

Other paths beside gdrive_user_credentials_file and cache.dir should be recalculated.
Added the following ones:

  • gdrive_service_account_p12_file_path
  • credentialpath
  • keyfile
  • cert_path
  • key_path

Will fix #4136.

@godfryd godfryd force-pushed the rel-paths branch 4 times, most recently from 5255622 to 7a0eb1d Compare October 29, 2020 05:40
@pmrowla pmrowla added the bugfix fixes bug label Oct 29, 2020
@pmrowla pmrowla self-requested a review October 29, 2020 08:17
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.

Thanks for the PR! Looks great!

Could we slim down the tests to just test that the paths are adjusted properly when loading a config with these fields? Current tests do the job, but they are quite heavy for such a simple function. Also, I see a lot of code duplication in the tests, would it be possible to reasonably us e pytest parametrize helper?

Copy link
Contributor

Choose a reason for hiding this comment

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

Linter CI job is complaining about this one

Suggested change
assert main(["remote", "add", "-d", remote_name, remote_url,]) == 0
assert main(["remote", "add", "-d", remote_name, remote_url]) == 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

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.

Looks much better now! Thank you! 🙏

What do you think about creating instead a unit test(maybe -ish) for the Config class, to check that when it contains all of these fields - they are are all getting resolved properly when loading?

@godfryd
Copy link
Contributor Author

godfryd commented Nov 2, 2020

I'm not sure. Current tests involve setting paths and loading them in a config. Proposed test would do only the second part.

Comment on lines 29 to 37
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like this is testing how it is written to the config file, but not really how it is loaded. Or am I missing something?

@efiop
Copy link
Contributor

efiop commented Nov 3, 2020

@godfryd The setting part is pretty safe. You are currently using CLI and realoding the whole repo instance in order to test it, but you could really just do something like:

with config.edit() as conf:
    # set the options you want to test

# check if written paths are correct

# load config and check that it contains what we expect (relative paths are evaluated correctly)

which should be easily parametrizable (or could even shove everything into one test without parametrizations), simple and lightweight. What do you think?

@efiop efiop added awaiting response we are waiting for your reply, please respond! :) and removed needs-review labels Nov 5, 2020
@pmrowla pmrowla removed their request for review November 5, 2020 06:06
@godfryd godfryd force-pushed the rel-paths branch 3 times, most recently from ac17e14 to 2b4223c Compare November 7, 2020 09:18
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.

Looks great! Please take a look at the windows tests, looks like there is a bug

2020-11-07T09:49:32.2041318Z     def test_load_relative_paths(dvc, field, remote_url):
2020-11-07T09:49:32.2041690Z         # set field to test
2020-11-07T09:49:32.2042032Z         with dvc.config.edit() as conf:
2020-11-07T09:49:32.2042463Z             conf["remote"]["test"] = {"url": remote_url, field: "file.txt"}
2020-11-07T09:49:32.2042793Z     
2020-11-07T09:49:32.2043269Z         # check if written paths are correct
2020-11-07T09:49:32.2043710Z         dvc_dir = dvc.config.dvc_dir
2020-11-07T09:49:32.2044307Z >       assert dvc.config["remote"]["test"][field] == os.path.join(
2020-11-07T09:49:32.2044735Z             dvc_dir, "..", "file.txt"
2020-11-07T09:49:32.2045003Z         )
2020-11-07T09:49:32.2045425Z E       AssertionError: assert 'C:\\Users\\r...\\../file.txt' == 'C:\\Users\\r...\..\\file.txt'
2020-11-07T09:49:32.2046433Z E         - C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\popen-gw3\test_load_relative_paths_cert_0\.dvc\..\file.txt
2020-11-07T09:49:32.2047086Z E         ?                                                                                                                         ^
2020-11-07T09:49:32.2047786Z E         + C:\Users\runneradmin\AppData\Local\Temp\pytest-of-runneradmin\pytest-0\popen-gw3\test_load_relative_paths_cert_0\.dvc\../file.txt
2020-11-07T09:49:32.2048624Z E         ?     

@godfryd godfryd force-pushed the rel-paths branch 7 times, most recently from a8dc8dd to 9396c3c Compare November 10, 2020 05:22
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.

Looks great! Thank you! 🙏

@efiop efiop merged commit 4b27fd7 into treeverse:master Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting response we are waiting for your reply, please respond! :) bugfix fixes bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

conf: credentialpath is not recalculated when it's a relpath

3 participants