예제 #1
0
파일: imp_url.py 프로젝트: shizacat/dvc
def imp_url(self, url, out=None, fname=None, erepo=None, locked=True):
    from dvc.dvcfile import Dvcfile
    from dvc.stage import Stage

    out = resolve_output(url, out)
    path, wdir, out = resolve_paths(self, out)

    # NOTE: when user is importing something from within his own repository
    if os.path.exists(url) and path_isin(os.path.abspath(url), self.root_dir):
        url = relpath(url, wdir)

    stage = Stage.create(
        self,
        fname or path,
        wdir=wdir,
        deps=[url],
        outs=[out],
        erepo=erepo,
    )

    if stage is None:
        return None

    dvcfile = Dvcfile(self, stage.path)
    dvcfile.overwrite_with_prompt(force=True)

    self.check_modified_graph([stage])

    stage.run()

    stage.locked = locked

    dvcfile.dump(stage)

    return stage
예제 #2
0
파일: run.py 프로젝트: shizacat/dvc
def run(self, fname=None, no_exec=False, **kwargs):
    from dvc.stage import Stage
    from dvc.dvcfile import Dvcfile, DVC_FILE_SUFFIX, DVC_FILE

    outs = (
        kwargs.get("outs", [])
        + kwargs.get("outs_no_cache", [])
        + kwargs.get("metrics", [])
        + kwargs.get("metrics_no_cache", [])
        + kwargs.get("outs_persist", [])
        + kwargs.get("outs_persist_no_cache", [])
    )

    if outs:
        base = os.path.basename(os.path.normpath(outs[0]))
        path = base + DVC_FILE_SUFFIX
    else:
        path = DVC_FILE

    stage = Stage.create(self, fname or path, **kwargs)
    if stage is None:
        return None

    dvcfile = Dvcfile(self, stage.path)
    dvcfile.overwrite_with_prompt(force=kwargs.get("overwrite", True))

    self.check_modified_graph([stage])

    if not no_exec:
        stage.run(no_commit=kwargs.get("no_commit", False))

    dvcfile.dump(stage)

    return stage