示例#1
0
def _read_params(
    repo,
    params,
    params_fs_paths,
    deps=False,
    onerror: Optional[Callable] = None,
):
    res: Dict[str, Dict] = defaultdict(dict)
    fs_paths = copy(params_fs_paths)

    if deps:
        for param in params:
            params_dict = error_handler(param.read_params)(onerror=onerror,
                                                           flatten=False)
            if params_dict:
                name = os.sep.join(repo.fs.path.relparts(param.fs_path))
                res[name] = params_dict
    else:
        fs_paths += [param.fs_path for param in params]

    for fs_path in fs_paths:
        from_path = _read_fs_path(repo.fs, fs_path, onerror=onerror)
        if from_path:
            name = os.sep.join(repo.fs.path.relparts(fs_path))
            res[name] = from_path

    return res
示例#2
0
def show(repo, revs=None, targets=None, deps=False, onerror: Callable = None):
    if onerror is None:
        onerror = onerror_collect
    res = {}

    for branch in repo.brancher(revs=revs):
        params = error_handler(_gather_params)(repo=repo,
                                               rev=branch,
                                               targets=targets,
                                               deps=deps,
                                               onerror=onerror)

        if params:
            res[branch] = params

    # Hide workspace params if they are the same as in the active branch
    try:
        active_branch = repo.scm.active_branch()
    except (SCMError, NoSCMError):
        # SCMError - detached head
        # NoSCMError - no repo case
        pass
    else:
        if res.get("workspace") == res.get(active_branch):
            res.pop("workspace", None)

    errored = errored_revisions(res)
    if errored:
        ui.error_write(
            "DVC failed to load some parameters for following revisions:"
            f" '{', '.join(errored)}'.")

    return res
示例#3
0
def _read_params(
    repo,
    params,
    params_fs_paths,
    deps=False,
    onerror: Optional[Callable] = None,
):
    res: Dict[str, Dict] = defaultdict(dict)
    fs_paths = copy(params_fs_paths)

    if deps:
        for param in params:
            params_dict = error_handler(param.read_params_d)(onerror=onerror)
            if params_dict:
                res[repo.fs.path.relpath(param.fs_path,
                                         os.getcwd())] = params_dict
    else:
        fs_paths += [param.fs_path for param in params]

    for fs_path in fs_paths:
        from_path = _read_fs_path(repo.fs, fs_path, onerror=onerror)
        if from_path:
            res[repo.fs.path.relpath(fs_path, os.getcwd())] = from_path

    return res
示例#4
0
文件: show.py 项目: pmrowla/dvc
def show(
    repo,
    targets=None,
    all_branches=False,
    all_tags=False,
    recursive=False,
    revs=None,
    all_commits=False,
    onerror=None,
):
    if onerror is None:
        onerror = onerror_collect

    res = {}
    for rev in repo.brancher(
            revs=revs,
            all_branches=all_branches,
            all_tags=all_tags,
            all_commits=all_commits,
    ):
        res[rev] = error_handler(_gather_metrics)(repo,
                                                  targets,
                                                  rev,
                                                  recursive,
                                                  onerror=onerror)

    # Hide workspace metrics if they are the same as in the active branch
    try:
        active_branch = repo.scm.active_branch()
    except (SCMError, NoSCMError):
        # SCMError - detached head
        # NoSCMError - no repo case
        pass
    else:
        if res.get("workspace") == res.get(active_branch):
            res.pop("workspace", None)

    errored = errored_revisions(res)
    if errored:
        from dvc.ui import ui

        ui.error_write(
            "DVC failed to load some metrics for following revisions:"
            f" '{', '.join(errored)}'.")

    return res
示例#5
0
def _read_params(
    repo,
    params,
    params_path_infos,
    deps=False,
    onerror: Optional[Callable] = None,
):
    res: Dict[str, Dict] = defaultdict(dict)
    path_infos = copy(params_path_infos)

    if deps:
        for param in params:
            params_dict = error_handler(param.read_params_d)(onerror=onerror)
            if params_dict:
                res[str(param.path_info)] = params_dict
    else:
        path_infos += [param.path_info for param in params]

    for path_info in path_infos:
        from_path = _read_path_info(repo.fs, path_info, onerror=onerror)
        if from_path:
            res[str(path_info)] = from_path

    return res