Exemple #1
0
 def load(self):
     if not self.exists():
         return {}
     with self.repo.tree.open(self.path) as fd:
         data = parse_yaml(fd.read(), self.path)
     try:
         self.validate(data, fname=self.relpath)
     except StageFileFormatError:
         raise LockfileCorruptedError(
             f"Lockfile '{self.relpath}' is corrupted.")
     return data
Exemple #2
0
    def _load(self):
        # it raises the proper exceptions by priority:
        # 1. when the file doesn't exists
        # 2. filename is not a DVC-file
        # 3. path doesn't represent a regular file
        if not self.exists():
            raise StageFileDoesNotExistError(self.path)
        check_dvc_filename(self.path)
        if not self.repo.tree.isfile(self.path):
            raise StageFileIsNotDvcFileError(self.path)

        with self.repo.tree.open(self.path) as fd:
            stage_text = fd.read()
        d = parse_yaml(stage_text, self.path)
        self.validate(d, self.relpath)
        return d, stage_text
Exemple #3
0
def test_cyclic_graph_error(tmp_dir, dvc, run_copy):
    tmp_dir.gen("foo", "foo")
    run_copy("foo", "bar", name="copy-foo-bar")
    run_copy("bar", "baz", name="copy-bar-baz")
    run_copy("baz", "foobar", name="copy-baz-foobar")

    with open(PIPELINE_FILE) as f:
        data = parse_yaml(f.read(), PIPELINE_FILE)
        data["stages"]["copy-baz-foo"] = {
            "cmd": "echo baz > foo",
            "deps": ["baz"],
            "outs": ["foo"],
        }
    dump_yaml(PIPELINE_FILE, data)
    with pytest.raises(CyclicGraphError):
        dvc.reproduce(":copy-baz-foo")