def setUp(self): super(TestReproExternalLOCAL, self).setUp() self.tmpdir = TestDvc.mkdtemp() ret = main(["config", "cache.type", "hardlink"]) self.assertEqual(ret, 0) self.dvc = DvcRepo(".")
def setUp(self): super().setUp() ret = main(["config", "cache.type", "hardlink"]) self.assertEqual(ret, 0) self.dvc = DvcRepo(".")
def test(self, mock_prompt): if not self.should_test(): return 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) ret = main(["remote", "modify", "myrepo", "type", "hardlink"]) 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) ret = main(["remote", "modify", remote_name, "type", "hardlink"]) 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(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( 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(), {}) stages = self.dvc.reproduce(import_stage.path) self.assertEqual(len(stages), 1) 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.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), {})
def setUp(self): super(TestShouldNotCheckoutUponCorruptedLocalHardlinkCache, self).setUp() ret = main(["config", "cache.type", "hardlink"]) self.assertEqual(ret, 0) self.dvc = DvcRepo(".")
def _test_metrics(self, func): self.dvc.scm.commit("init") self.dvc.scm.branch("one") self.dvc.scm.branch("two") func("master") func("one") func("two") # TestDvc currently is based on TestGit, so it is safe to use # scm.git for now self.dvc.scm.repo.git.clean("-fd") self.dvc = DvcRepo(".") res = self.dvc.metrics.show("metrics.json", all_branches=True, typ="json", xpath="metrics") self.assertEqual( res, { "master": { "metrics.json": ["master"] }, "one": { "metrics.json": ["one"] }, "two": { "metrics.json": ["two"] }, "working tree": { "metrics.json": ["two"] }, }, ) res = self.dvc.metrics.show("", all_branches=True, typ="json", xpath="metrics") self.assertEqual( res, { "master": { "metrics.json": ["master"] }, "one": { "metrics.json": ["one"] }, "two": { "metrics.json": ["two"] }, "working tree": { "metrics.json": ["two"] }, }, )