Skip to content
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

tests: remotes: use TmpDir-like fixtures #4140

Merged
merged 1 commit into from
Jul 2, 2020
Merged

Conversation

efiop
Copy link
Contributor

@efiop efiop commented Jul 1, 2020

  • ❗ I have followed the Contributing to DVC checklist.

  • πŸ“– If this PR requires documentation updates, I have created a separate PR (or issue, at least) in dvc.org and linked it here.

  • ❌ I will check DeepSource, CodeClimate, and other sanity checks below. (We consider them recommendatory and don't expect everything to be addressed. Please fix things that actually improve code or fix bugs.)

Thank you for the contribution - we'll try to review it as soon as possible. πŸ™



@pytest.fixture
def workspace(tmp_dir, dvc, request):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

will introduce a similar remote fixture as well instead of current explicit ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, this really illustrates the need for #3920

@@ -30,7 +33,7 @@ def get_url():
def azure():
if not Azure.should_test():
pytest.skip("no azure running")
yield Azure()
yield Azure(Azure.get_url())
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This CLS(CLS.get_url()) mess will be removed once no tests use it. Likely in this PR.

else:
path.write_text(contents, encoding="utf-8")

def gen(self, struct, text=""):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be unified with TmpDir in the future.

Comment on lines +66 to +68
@property
def _gc(self):
from google.cloud.storage import Client
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cloud fixtures try to implement methods by itself without relying on Tree too much, so that our tests are separated from our code. But sometimes it is just too hard to do that so in stuff like ssh, we use SSHConnection for now, but I might switch to plain paramiko after all, to make it more isolated.

Comment on lines +9 to +32
def is_file(self):
raise NotImplementedError

def is_dir(self):
raise NotImplementedError

def exists(self):
raise NotImplementedError

def mkdir(self, mode=0o777, parents=False, exist_ok=False):
raise NotImplementedError

def write_text(self, contents, encoding=None, errors=None):
raise NotImplementedError

def write_bytes(self, contents):
raise NotImplementedError

def read_text(self, encoding=None, errors=None):
raise NotImplementedError

def read_bytes(self):
raise NotImplementedError

Copy link
Contributor Author

Choose a reason for hiding this comment

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

All of these are your regular pathlib.Path's methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For now we have a bare minimum, but it is easy to extend with what we need in the future.

tests/remotes/local.py Outdated Show resolved Hide resolved
conn.close()

def is_file(self):
with self._ssh() as _ssh:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not very nice, might just create a connection and then add a closing logic to close, as it is really intended to be, and then register a fixture finaliser or something.

@efiop
Copy link
Contributor Author

efiop commented Jul 1, 2020

For now running tests to see what i've missed in the ones that are not (easily) runnable locally.

tests/func/test_import_url.py Outdated Show resolved Hide resolved
@efiop efiop force-pushed the test_external_outs branch from e72691c to 9cbbdfb Compare July 1, 2020 03:04
@codecov
Copy link

codecov bot commented Jul 1, 2020

Codecov Report

Merging #4140 into master will decrease coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4140      +/-   ##
==========================================
- Coverage   92.71%   92.58%   -0.13%     
==========================================
  Files         162      162              
  Lines       11293    11293              
==========================================
- Hits        10470    10456      -14     
- Misses        823      837      +14     
Impacted Files Coverage Ξ”
dvc/stage/imports.py 88.23% <0.00%> (-5.89%) ⬇️
dvc/remote/ssh/__init__.py 74.35% <0.00%> (-2.57%) ⬇️
dvc/remote/ssh/connection.py 82.21% <0.00%> (-1.45%) ⬇️
dvc/remote/gs.py 94.11% <0.00%> (-0.85%) ⬇️
dvc/remote/base.py 95.00% <0.00%> (-0.42%) ⬇️
dvc/output/base.py 94.98% <0.00%> (-0.36%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Ξ” = absolute <relative> (impact), ΓΈ = not affected, ? = missing data
Powered by Codecov. Last update 5d2ac9f...10f667f. Read the comment docs.

@efiop efiop force-pushed the test_external_outs branch 6 times, most recently from 77c6d59 to 69546ce Compare July 2, 2020 00:02
self.dvc.update([import_remote_stage.path])
self.assertEqual(self.dvc.status([import_remote_stage.path]), {})

stages = self.dvc.reproduce(cmd_stage.addressing)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got rid of the repro test in favor of add/import/update/run(no-exec) tests because running commands is not trivial in a unified way, as there is no mechanism of translating our remote:// notation to a user-consumable one. So let's not have it for now (we are not loosing much) until #3920 is looked into, as this problem again illustrates the need for proper workspaces.

@efiop efiop force-pushed the test_external_outs branch from 69546ce to b04b4f4 Compare July 2, 2020 00:34
@efiop efiop force-pushed the test_external_outs branch from b04b4f4 to 10f667f Compare July 2, 2020 01:09
@efiop efiop changed the title [WIP] tests: remotes: use TmpDir-like fixtures tests: remotes: use TmpDir-like fixtures Jul 2, 2020
@efiop efiop merged commit 07da9f1 into master Jul 2, 2020
@delete-merged-branch delete-merged-branch bot deleted the test_external_outs branch July 2, 2020 01:46
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.

1 participant