Merge branch 'master' into refactor-remote-s3

This commit is contained in:
Ruslan Kuprieiev
2020-01-06 20:43:10 +02:00
committed by GitHub
10 changed files with 47 additions and 48 deletions
+3
View File
@@ -98,6 +98,7 @@ jobs:
tags: true
repo: iterative/dvc
- name: Snapcraft snap
stage: deploy
addons:
snaps:
- name: snapcraft
@@ -121,6 +122,8 @@ jobs:
snap: dvc_*.snap
channel: ${SOURCE_TAG:+stable}${SOURCE_TAG:-edge}
skip_cleanup: true
on:
branch: master
before_install:
- bash ./scripts/ci/before_install.sh
+1 -1
View File
@@ -27,7 +27,7 @@ class NoRemoteError(ConfigError):
def __init__(self, command):
msg = (
"no remote specified. Setup default remote with\n"
" dvc config core.remote <name>\n"
" dvc remote default <name>\n"
"or use:\n"
" dvc {} -r <name>\n".format(command)
)
+8 -8
View File
@@ -188,16 +188,16 @@ class TestShouldCacheBeReflinkOrCopyByDefault(TestDvc):
"protected,dir_mode,file_mode",
[(False, 0o775, 0o664), (True, 0o775, 0o444)],
)
def test_shared_cache(repo_dir, dvc_repo, protected, dir_mode, file_mode):
assert main(["config", "cache.shared", "group"]) == 0
def test_shared_cache(tmp_dir, dvc, protected, dir_mode, file_mode):
dvc.config.set("cache", "shared", "group")
dvc.config.set("cache", "protected", str(protected))
dvc.cache = Cache(dvc)
if protected:
assert main(["config", "cache.protected", "true"]) == 0
tmp_dir.dvc_gen(
{"file": "file content", "dir": {"file2": "file 2 " "content"}}
)
assert main(["add", repo_dir.FOO]) == 0
assert main(["add", repo_dir.DATA_DIR]) == 0
for root, dnames, fnames in os.walk(dvc_repo.cache.local.cache_dir):
for root, dnames, fnames in os.walk(dvc.cache.local.cache_dir):
for dname in dnames:
path = os.path.join(root, dname)
assert stat.S_IMODE(os.stat(path).st_mode) == dir_mode
+5 -6
View File
@@ -33,11 +33,11 @@ from tests.utils import spy
from tests.remotes import (
_should_test_gcp,
_should_test_hdfs,
_should_test_oss,
_should_test_ssh,
Azure,
GDrive,
S3,
OSS,
TEST_CONFIG,
TEST_SECTION,
TEST_GCP_CREDS_FILE,
@@ -47,7 +47,6 @@ from tests.remotes import (
get_gcp_url,
get_hdfs_url,
get_local_url,
get_oss_url,
get_ssh_url,
get_ssh_url_mocked,
)
@@ -272,10 +271,10 @@ class TestRemoteAZURE(TestDataCloudBase):
class TestRemoteOSS(TestDataCloudBase):
def _should_test(self):
return _should_test_oss()
return OSS.should_test()
def _get_url(self):
return get_oss_url()
return OSS.get_url()
def _get_cloud_class(self):
return RemoteOSS
@@ -544,10 +543,10 @@ class TestRemoteAZURECLI(TestDataCloudCLIBase):
class TestRemoteOSSCLI(TestDataCloudCLIBase):
def _should_test(self):
return _should_test_oss()
return OSS.should_test()
def _test(self):
url = get_oss_url()
url = OSS.get_url()
self.main(["remote", "add", TEST_REMOTE, url])
+2 -2
View File
@@ -18,5 +18,5 @@ def _get_dep(dvc, path):
@pytest.mark.parametrize("url,scheme", TESTS)
def test_scheme(dvc_repo, url, scheme):
assert type(_get_dep(dvc_repo, url)) == DEP_MAP[scheme]
def test_scheme(dvc, url, scheme):
assert type(_get_dep(dvc, url)) == DEP_MAP[scheme]
+19 -22
View File
@@ -66,18 +66,6 @@ def _should_test_gcp():
return True
def _should_test_oss():
do_test = env2bool("DVC_TEST_OSS", undefined=None)
if do_test is not None:
return do_test
return (
os.getenv("OSS_ENDPOINT")
and os.getenv("OSS_ACCESS_KEY_ID")
and os.getenv("OSS_ACCESS_KEY_SECRET")
)
def _should_test_ssh():
do_test = env2bool("DVC_TEST_SSH", undefined=None)
if do_test is not None:
@@ -165,14 +153,6 @@ def get_gcp_url():
return "gs://" + get_gcp_storagepath()
def get_oss_storagepath():
return "{}/{}".format(TEST_OSS_REPO_BUCKET, (uuid.uuid4()))
def get_oss_url():
return "oss://{}".format(get_oss_storagepath())
# NOTE: staticmethod is only needed in Python 2
class Local:
should_test = staticmethod(lambda: True)
@@ -268,8 +248,25 @@ class Azure:
class OSS:
should_test = staticmethod(_should_test_oss)
get_url = staticmethod(get_oss_url)
@staticmethod
def should_test():
do_test = env2bool("DVC_TEST_OSS", undefined=None)
if do_test is not None:
return do_test
return (
os.getenv("OSS_ENDPOINT")
and os.getenv("OSS_ACCESS_KEY_ID")
and os.getenv("OSS_ACCESS_KEY_SECRET")
)
@staticmethod
def get_storagepath():
return "{}/{}".format(TEST_OSS_REPO_BUCKET, (uuid.uuid4()))
@staticmethod
def get_url():
return "oss://{}".format(OSS.get_storagepath())
class SSH:
+1 -1
View File
@@ -2,7 +2,7 @@ from dvc.cli import parse_args
from dvc.command.imp import CmdImport
def test_import(mocker, dvc_repo):
def test_import(mocker):
cli_args = parse_args(
["import", "repo_url", "src", "--out", "out", "--rev", "version"]
)
+2 -2
View File
@@ -5,7 +5,7 @@ from dvc.command.imp_url import CmdImportUrl
from dvc.exceptions import DvcException
def test_import_url(mocker, dvc_repo):
def test_import_url(mocker):
cli_args = parse_args(["import-url", "src", "out", "--file", "file"])
assert cli_args.func == CmdImportUrl
@@ -17,7 +17,7 @@ def test_import_url(mocker, dvc_repo):
m.assert_called_once_with("src", out="out", fname="file")
def test_failed_import_url(mocker, caplog, dvc_repo):
def test_failed_import_url(mocker, caplog):
cli_args = parse_args(["import-url", "http://somesite.com/file_name"])
assert cli_args.func == CmdImportUrl
+4 -4
View File
@@ -7,7 +7,7 @@ from dvc.remote.http import RemoteHTTP
from tests.utils.httpd import StaticFileServer
def test_no_traverse_compatibility(dvc_repo):
def test_no_traverse_compatibility(dvc):
config = {
"url": "http://example.com/",
"path_info": "file.html",
@@ -15,15 +15,15 @@ def test_no_traverse_compatibility(dvc_repo):
}
with pytest.raises(ConfigError):
RemoteHTTP(dvc_repo, config)
RemoteHTTP(dvc, config)
def test_download_fails_on_error_code(dvc_repo):
def test_download_fails_on_error_code(dvc):
with StaticFileServer() as httpd:
url = "http://localhost:{}/".format(httpd.server_port)
config = {"url": url}
remote = RemoteHTTP(dvc_repo, config)
remote = RemoteHTTP(dvc, config)
with pytest.raises(HTTPError):
remote._download(URLInfo(url) / "missing.txt", "missing.txt")
+2 -2
View File
@@ -83,8 +83,8 @@ def test_send(mock_post, tmp_path):
({"analytics": "false", "unknown": "broken"}, False),
],
)
def test_is_enabled(dvc_repo, config, result, monkeypatch, tmp_global_config):
configobj = dvc_repo.config._repo_config
def test_is_enabled(dvc, config, result, monkeypatch, tmp_global_config):
configobj = dvc.config._repo_config
configobj["core"] = config
configobj.write()