コード例 #1
0
ファイル: test_cache.py プロジェクト: ybayle/dvc
    def test(self):
        fname = 'not-json'
        self.create(fname, '<clearly>not,json')
        self._do_test(Output.load_dir_cache(fname))

        fname = 'not-list'
        self.create(fname, '{"a": "b"}')
        self._do_test(Output.load_dir_cache(fname))
コード例 #2
0
def test_str_workdir_inside_repo(dvc):
    stage = Stage(dvc)
    output = Output(stage, "path", cache=False)

    assert "path" == str(output)

    stage = Stage(dvc, wdir="some_folder")
    output = Output(stage, "path", cache=False)

    assert os.path.join("some_folder", "path") == str(output)
コード例 #3
0
def test_str_on_external_absolute_path(dvc):
    stage = Stage(dvc)

    rel_path = os.path.join("..", "path", "to", "file")
    abs_path = os.path.abspath(rel_path)
    output = Output(stage, abs_path, cache=False)

    assert output.def_path == abs_path
    assert output.path_info.fspath == abs_path
    assert str(output) == abs_path
コード例 #4
0
ファイル: test_output.py プロジェクト: pmrowla/dvc
def test_get_used_objs(exists, expected_message, mocker, caplog):
    stage = mocker.MagicMock()
    mocker.patch.object(stage, "__str__", return_value="stage: 'stage.dvc'")
    mocker.patch.object(stage, "addressing", "stage.dvc")
    mocker.patch.object(stage, "wdir", os.getcwd())
    mocker.patch.object(stage.repo, "root_dir", os.getcwd())
    mocker.patch.object(stage.repo.dvcignore, "is_ignored", return_value=False)
    mocker.patch.object(stage.repo.dvcignore,
                        "check_ignore",
                        return_value=_no_match("path"))

    output = Output(stage, "path")

    mocker.patch.object(output, "use_cache", True)
    mocker.patch.object(stage, "is_repo_import", False)
    mocker.patch.object(Output, "exists",
                        new_callable=mocker.PropertyMock).return_value = exists

    with caplog.at_level(logging.WARNING, logger="dvc"):
        assert {} == output.get_used_objs()
    assert first(caplog.messages) == expected_message
コード例 #5
0
    def loads(project=None,
              cmd=None,
              deps=[],
              outs=[],
              outs_no_cache=[],
              fname=None,
              cwd=os.curdir):
        cwd = os.path.abspath(cwd)
        path = os.path.join(cwd, fname)
        outputs = Output.loads_from(project, outs, use_cache=True, cwd=cwd)
        outputs += Output.loads_from(project,
                                     outs_no_cache,
                                     use_cache=False,
                                     cwd=cwd)
        dependencies = Dependency.loads_from(project, deps, cwd=cwd)

        return Stage(project=project,
                     path=path,
                     cmd=cmd,
                     cwd=cwd,
                     outs=outputs,
                     deps=dependencies)
コード例 #6
0
    def loadd(project, d, path):
        path = os.path.abspath(path)
        cwd = os.path.dirname(path)
        cmd = d[Stage.PARAM_CMD]
        deps = Dependency.loadd_from(project, d[Stage.PARAM_DEPS], cwd=cwd)
        outs = Output.loadd_from(project, d[Stage.PARAM_OUTS], cwd=cwd)

        return Stage(project=project,
                     path=path,
                     cmd=cmd,
                     cwd=cwd,
                     deps=deps,
                     outs=outs)
コード例 #7
0
    def loadd(project, d, path):
        Stage.validate(d)

        path = os.path.abspath(path)
        cwd = os.path.dirname(path)
        cmd = d.get(Stage.PARAM_CMD, None)
        deps = Dependency.loadd_from(project,
                                     d.get(Stage.PARAM_DEPS, []),
                                     cwd=cwd)
        outs = Output.loadd_from(project, d.get(Stage.PARAM_OUTS, []), cwd=cwd)

        return Stage(project=project,
                     path=path,
                     cmd=cmd,
                     cwd=cwd,
                     deps=deps,
                     outs=outs)
コード例 #8
0
 def _get_output(self):
     stage = Stage(self.dvc)
     return Output(stage, "path")
コード例 #9
0
def test_str_workdir_outside_repo(tmp_dir, erepo_dir):
    stage = Stage(erepo_dir.dvc)
    output = Output(stage, "path", cache=False)

    assert relpath("path", erepo_dir.dvc.root_dir) == str(output)
コード例 #10
0
def test_save_missing(dvc, mocker):
    stage = Stage(dvc)
    out = Output(stage, "path", cache=False)
    with mocker.patch.object(out.fs, "exists", return_value=False):
        with pytest.raises(out.DoesNotExistError):
            out.save()