diff --git a/dvc/dependency/base.py b/dvc/dependency/base.py index ecd4a3b5d..f76f4e022 100644 --- a/dvc/dependency/base.py +++ b/dvc/dependency/base.py @@ -22,4 +22,4 @@ class DependencyBase(object): IsNotFileOrDirError = DependencyIsNotFileOrDirError def update(self): - raise NotImplementedError + pass diff --git a/dvc/repo/imp_url.py b/dvc/repo/imp_url.py index 8d42d6bb1..9125c9340 100644 --- a/dvc/repo/imp_url.py +++ b/dvc/repo/imp_url.py @@ -3,7 +3,7 @@ from dvc.repo.scm_context import scm_context @scm_context -def imp_url(self, url, out=None, fname=None, erepo=None, locked=False): +def imp_url(self, url, out=None, fname=None, erepo=None, locked=True): from dvc.stage import Stage out = out or pathlib.PurePath(url).name diff --git a/dvc/stage.py b/dvc/stage.py index 0ec0f9f8a..509d49a62 100644 --- a/dvc/stage.py +++ b/dvc/stage.py @@ -334,7 +334,7 @@ class Stage(object): return self def update(self): - if not self.is_repo_import: + if not self.is_repo_import and not self.is_import: raise StageUpdateError(self.relpath) self.deps[0].update() diff --git a/tests/func/test_repro.py b/tests/func/test_repro.py index 7c8fc60ba..a827e6441 100644 --- a/tests/func/test_repro.py +++ b/tests/func/test_repro.py @@ -837,7 +837,9 @@ class TestReproExternalBase(TestDvc): with patch_download as mock_download: with patch_checkout as mock_checkout: with patch_run as mock_run: + stage.locked = False stage.run() + stage.locked = True mock_run.assert_not_called() mock_download.assert_not_called() @@ -918,14 +920,12 @@ class TestReproExternalBase(TestDvc): self.assertNotEqual(self.dvc.status(), {}) - stages = self.dvc.reproduce(import_stage.path) - self.assertEqual(len(stages), 1) + self.dvc.update(import_stage.path) self.assertTrue(os.path.exists("import")) self.assertTrue(filecmp.cmp("import", self.BAR, shallow=False)) self.assertEqual(self.dvc.status(import_stage.path), {}) - stages = self.dvc.reproduce(import_remote_stage.path) - self.assertEqual(len(stages), 1) + self.dvc.update(import_remote_stage.path) self.assertEqual(self.dvc.status(import_remote_stage.path), {}) stages = self.dvc.reproduce(cmd_stage.path) @@ -1323,6 +1323,7 @@ class TestReproAlreadyCached(TestRepro): with patch_download as mock_download: with patch_checkout as mock_checkout: + assert main(["unlock", "bar.dvc"]) == 0 ret = main(["repro", "--force", "bar.dvc"]) self.assertEqual(ret, 0) self.assertEqual(mock_download.call_count, 1) diff --git a/tests/func/test_update.py b/tests/func/test_update.py index 9234b0ed4..7345627aa 100644 --- a/tests/func/test_update.py +++ b/tests/func/test_update.py @@ -1,4 +1,6 @@ import os +import shutil +import filecmp from dvc.repo import Repo @@ -40,3 +42,28 @@ def test_update_import(dvc_repo, erepo): assert os.path.isfile(dst) with open(dst, "r+") as fobj: assert fobj.read() == "updated" + + +def test_update_import_url(repo_dir, dvc_repo): + src = "file" + dst = src + "_imported" + + shutil.copyfile(repo_dir.FOO, src) + + stage = dvc_repo.imp_url(src, dst) + + assert os.path.exists(dst) + assert os.path.isfile(dst) + assert filecmp.cmp(src, dst, shallow=False) + + # update data + os.unlink(src) + shutil.copyfile(repo_dir.BAR, src) + + assert dvc_repo.status(stage.path) == {} + dvc_repo.update(stage.path) + assert dvc_repo.status(stage.path) == {} + + assert os.path.exists(dst) + assert os.path.isfile(dst) + assert filecmp.cmp(src, dst, shallow=False)