예제 #1
0
    def should_remove_persistent_outs(self, file, stage_file):
        ret = main(["remove", stage_file, "--outs"])
        self.assertEqual(0, ret)

        self.assertFalse(os.path.exists(file))
예제 #2
0
    def test(self):
        ret = main(["add", self.FOO])
        self.assertEqual(ret, 0)

        ret = main(["add", "non-existing-file"])
        self.assertNotEqual(ret, 0)
예제 #3
0
    def test_dir(self):
        ret = main(["add", self.DATA_DIR])
        self.assertEqual(ret, 0)

        ret = main(["add", self.DATA_DIR])
        self.assertEqual(ret, 0)
예제 #4
0
def run_dvc(*argv):
    assert main(argv) == 0
예제 #5
0
def test_modify_missing_remote(tmp_dir, dvc):
    assert main(["remote", "modify", "myremote", "user", "xxx"]) == 251
예제 #6
0
 def main(self, args):
     ret = main(args)
     self.assertEqual(ret, 0)
예제 #7
0
 def test_cli(self):
     ret = main(['gc', '-f'])
     self.assertEqual(ret, 0)
     self._test_gc()
예제 #8
0
파일: test_repro.py 프로젝트: zeta1999/dvc
 def setUp(self):
     super().setUp()
     self.tmpdir = self.mkdtemp()
     ret = main(["config", "cache.type", "hardlink"])
     self.assertEqual(ret, 0)
     self.dvc = DvcRepo(".")
예제 #9
0
파일: test_repro.py 프로젝트: zeta1999/dvc
 def test(self):
     shutil.rmtree(self.dvc.cache.local.cache_dir)
     ret = main(["repro", self.file1_stage, "--no-commit"])
     self.assertEqual(ret, 0)
     self.assertFalse(os.path.exists(self.dvc.cache.local.cache_dir))
예제 #10
0
def test_gc_cloud_positive(tmp_dir, dvc, tmp_path_factory, setup_remote):
    setup_remote(dvc)

    for flag in ["-cw", "-ca", "-cT", "-caT", "-cwT"]:
        assert main(["gc", "-vf", flag]) == 0
예제 #11
0
 def test_cli(self):
     ret = main(["gc", "-wf"])
     self.assertEqual(ret, 0)
     self._test_gc()
예제 #12
0
def test_gc_cloud_without_any_specifier(tmp_dir, dvc, caplog):
    with caplog.at_level(logging.WARNING, logger="dvc"):
        assert main(["gc", "-cvf"]) == 255

    assert ("Either of `-w|--workspace`, `-a|--all-branches`, `-T|--all-tags` "
            "or `--all-commits` needs to be set.") in caplog.text
예제 #13
0
def test_get_url_git_only_repo(tmp_dir, scm, caplog):
    tmp_dir.scm_gen({"foo": "foo"}, commit="initial")

    with caplog.at_level(logging.ERROR):
        assert main(["get", fspath(tmp_dir), "foo", "--show-url"]) == 1
        assert "failed to show URL" in caplog.text
예제 #14
0
def test_get_url_not_existing(tmp_dir, erepo_dir, caplog):
    with caplog.at_level(logging.ERROR, logger="dvc"):
        assert (main(
            ["get",
             fspath(erepo_dir), "not-existing-file", "--show-url"]) == 1)
        assert "failed to show URL" in caplog.text
예제 #15
0
파일: test_cache.py 프로젝트: yk/dvc
    def test(self):
        ret = main(["config", "cache.type", "reflink,copy"])
        self.assertEqual(ret, 0)

        ret = main(["add", self.FOO])
        self.assertEqual(ret, 0)
예제 #16
0
파일: test_repro.py 프로젝트: zeta1999/dvc
 def test(self):
     ret = main(["repro", self.file1_stage])
     self.assertEqual(ret, 0)
예제 #17
0
파일: test_cache.py 프로젝트: yk/dvc
 def test(self):
     ret = main(["cache", "dir"])
     self.assertEqual(ret, 254)
예제 #18
0
파일: test_repro.py 프로젝트: zeta1999/dvc
 def test_cli(self):
     ret = main(["repro", "--pipeline", "-f", self.file1_stage])
     self.assertEqual(ret, 0)
예제 #19
0
 def main_fail(self, args):
     ret = main(args)
     self.assertNotEqual(ret, 0)
예제 #20
0
파일: test_repro.py 프로젝트: zeta1999/dvc
 def test_cli(self):
     ret = main(["repro", "-f", "-P"])
     self.assertEqual(ret, 0)
예제 #21
0
 def test(self):
     ret = main(["checkout", "--force"])
     self.assertEqual(ret, 0)
     self._test_checkout()
예제 #22
0
파일: test_repro.py 프로젝트: zeta1999/dvc
    def test_non_existing(self):
        with self.assertRaises(StageFileDoesNotExistError):
            self.dvc.lock_stage("non-existing-stage")

        ret = main(["lock", "non-existing-stage"])
        self.assertNotEqual(ret, 0)
예제 #23
0
def test_show_default(dvc, capsys):
    assert main(["remote", "add", "foo", "s3://bucket/name"]) == 0
    assert main(["remote", "default", "foo"]) == 0
    assert main(["remote", "default"]) == 0
    out, _ = capsys.readouterr()
    assert out == "foo\n"
예제 #24
0
파일: test_repro.py 프로젝트: zeta1999/dvc
    def test(self):
        os.unlink(self.CODE)

        ret = main(["repro", self.file1_stage])
        self.assertNotEqual(ret, 0)
예제 #25
0
    def test_referencing_other_remotes(self):
        assert main(["remote", "add", "foo", "ssh://localhost/"]) == 0
        assert main(["remote", "add", "bar", "remote://foo/dvc-storage"]) == 0

        config = configobj.ConfigObj(self.dvc.config.files["repo"])
        assert config['remote "bar"']["url"] == "remote://foo/dvc-storage"
예제 #26
0
파일: test_repro.py 프로젝트: zeta1999/dvc
    def test(self, mock_prompt):
        if not self.should_test():
            raise SkipTest("Test {} is disabled".format(
                self.__class__.__name__))

        cache = (self.scheme + self.scheme_sep + self.bucket + self.sep +
                 str(uuid.uuid4()))

        ret = main(["config", "cache." + self.cache_scheme, "myrepo"])
        self.assertEqual(ret, 0)
        ret = main(["remote", "add", "myrepo", cache])
        self.assertEqual(ret, 0)
        if self.cache_type:
            ret = main(["remote", "modify", "myrepo", "type", self.cache_type])
            self.assertEqual(ret, 0)

        remote_name = "myremote"
        remote_key = str(uuid.uuid4())
        remote = (self.scheme + self.scheme_sep + self.bucket + self.sep +
                  remote_key)

        ret = main(["remote", "add", remote_name, remote])
        self.assertEqual(ret, 0)
        if self.cache_type:
            ret = main(
                ["remote", "modify", remote_name, "type", self.cache_type])
            self.assertEqual(ret, 0)

        self.dvc = DvcRepo(".")

        foo_key = remote_key + self.sep + self.FOO
        bar_key = remote_key + self.sep + self.BAR

        foo_path = (self.scheme + self.scheme_sep + self.bucket + self.sep +
                    foo_key)
        bar_path = (self.scheme + self.scheme_sep + self.bucket + self.sep +
                    bar_key)

        # Using both plain and remote notation
        out_foo_path = "remote://" + remote_name + "/" + self.FOO
        out_bar_path = bar_path

        self.write(self.bucket, foo_key, self.FOO_CONTENTS)

        import_stage = self.dvc.imp_url(out_foo_path, "import")

        self.assertTrue(os.path.exists("import"))
        self.assertTrue(filecmp.cmp("import", self.FOO, shallow=False))
        self.assertEqual(self.dvc.status([import_stage.path]), {})
        self.check_already_cached(import_stage)

        import_remote_stage = self.dvc.imp_url(out_foo_path,
                                               out_foo_path + "_imported")
        self.assertEqual(self.dvc.status([import_remote_stage.path]), {})

        cmd_stage = self.dvc.run(
            outs=[out_bar_path],
            deps=[out_foo_path],
            cmd=self.cmd(foo_path, bar_path),
        )

        self.assertEqual(self.dvc.status([cmd_stage.path]), {})
        self.assertEqual(self.dvc.status(), {})
        self.check_already_cached(cmd_stage)

        self.write(self.bucket, foo_key, self.BAR_CONTENTS)

        self.assertNotEqual(self.dvc.status(), {})

        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]), {})

        self.dvc.update(import_remote_stage.path)
        self.assertEqual(self.dvc.status([import_remote_stage.path]), {})

        stages = self.dvc.reproduce(cmd_stage.path)
        self.assertEqual(len(stages), 1)
        self.assertEqual(self.dvc.status([cmd_stage.path]), {})

        self.assertEqual(self.dvc.status(), {})
        self.dvc.gc()
        self.assertEqual(self.dvc.status(), {})

        self.dvc.remove(cmd_stage.path, outs_only=True)
        self.assertNotEqual(self.dvc.status([cmd_stage.path]), {})

        self.dvc.checkout([cmd_stage.path], force=True)
        self.assertEqual(self.dvc.status([cmd_stage.path]), {})
예제 #27
0
    def test_file(self):
        ret = main(["add", self.FOO])
        self.assertEqual(ret, 0)

        ret = main(["add", self.FOO])
        self.assertEqual(ret, 0)
예제 #28
0
파일: test_diff.py 프로젝트: ye-man/dvc
 def test(self):
     ret = main(["diff", "-t", self.new_file, self.a_ref])
     self.assertEqual(ret, 0)
예제 #29
0
 def test(self):
     ret = main(["add", "--recursive", self.DATA_DIR])
     self.assertEqual(ret, 0)
예제 #30
0
    def test(self):
        # NOTE: using sleep() is a workaround  for filesystems
        # with low mtime resolution. We have to use mtime since
        # comparing mtime's is the only way to check that the stage
        # file didn't change(size and inode in the first test down
        # below don't change).
        import time

        ret = main([
            "run",
            "-d",
            self.FOO,
            "-d",
            self.CODE,
            "-o",
            "out",
            "--file",
            "out.dvc",
            "--single-stage",
            "python",
            self.CODE,
            self.FOO,
            "out",
        ])
        self.assertEqual(ret, 0)

        stage_mtime = os.path.getmtime("out.dvc")

        time.sleep(1)

        ret = main([
            "run",
            "-d",
            self.FOO,
            "-d",
            self.CODE,
            "-o",
            "out",
            "--file",
            "out.dvc",
            "--single-stage",
            "python",
            self.CODE,
            self.FOO,
            "out",
        ])
        self.assertEqual(ret, 0)

        # NOTE: check that dvcfile was NOT overwritten
        self.assertEqual(stage_mtime, os.path.getmtime("out.dvc"))
        stage_mtime = os.path.getmtime("out.dvc")

        time.sleep(1)

        ret = main([
            "run",
            "-d",
            self.FOO,
            "-d",
            self.CODE,
            "--force",
            "--no-run-cache",
            "--single-stage",
            "-o",
            "out",
            "--file",
            "out.dvc",
            "python",
            self.CODE,
            self.FOO,
            "out",
        ])
        self.assertEqual(ret, 0)

        # NOTE: check that dvcfile was overwritten
        self.assertNotEqual(stage_mtime, os.path.getmtime("out.dvc"))
        stage_mtime = os.path.getmtime("out.dvc")

        time.sleep(1)

        ret = main([
            "run",
            "--force",
            "--single-stage",
            "--file",
            "out.dvc",
            "-d",
            self.BAR,
            f"cat {self.BAR}",
        ])
        self.assertEqual(ret, 0)

        # NOTE: check that dvcfile was overwritten
        self.assertNotEqual(stage_mtime, os.path.getmtime("out.dvc"))