Exemplo n.º 1
0
    def get_remote_odb(
        self,
        name: Optional[str] = None,
        command: str = "<command>",
    ) -> "ObjectDB":
        from dvc.config import NoRemoteError

        if not name:
            name = self.repo.config["core"].get("remote")

        if name:
            return self._init_odb(name)

        if bool(self.repo.config["remote"]):
            error_msg = (
                "no remote specified. Setup default remote with\n"
                "    dvc remote default <remote name>\n"
                "or use:\n"
                "    dvc {} -r <remote name>".format(command)
            )
        else:
            error_msg = (
                "no remote specified. Create a default remote with\n"
                "    dvc remote add -d <remote name> <remote url>"
            )

        raise NoRemoteError(error_msg)
Exemplo n.º 2
0
    def get_remote(self, remote=None, command="<command>"):
        if not remote:
            remote = self._core.get(Config.SECTION_CORE_REMOTE)

        if remote:
            return self._init_remote(remote)

        raise NoRemoteError(command)
Exemplo n.º 3
0
def test_import_cached_file(erepo_dir, tmp_dir, dvc, scm, monkeypatch):
    src = "some_file"
    dst = "some_file_imported"

    with erepo_dir.chdir():
        erepo_dir.dvc_gen({src: "hello"}, commit="add a regular file")

    tmp_dir.dvc_gen({dst: "hello"})
    (tmp_dir / dst).unlink()

    remote_exception = NoRemoteError("dvc import")
    with patch.object(cloud.DataCloud, "pull", side_effect=remote_exception):
        tmp_dir.dvc.imp(os.fspath(erepo_dir), src, dst)

    assert (tmp_dir / dst).is_file()
    assert filecmp.cmp(erepo_dir / src, tmp_dir / dst, shallow=False)
Exemplo n.º 4
0
    def get_remote(self, name=None, command="<command>"):
        if not name:
            name = self.repo.config["core"].get("remote")

        if name:
            return self._init_remote(name)

        if bool(self.repo.config["remote"]):
            error_msg = ("no remote specified. Setup default remote with\n"
                         "    dvc remote default <remote name>\n"
                         "or use:\n"
                         "    dvc {} -r <remote name>".format(command))
        else:
            error_msg = ("no remote specified. Create a default remote with\n"
                         "    dvc remote add -d <remote name> <remote url>")

        raise NoRemoteError(error_msg)
Exemplo n.º 5
0
    def get_remote(self, remote=None, command="<command>"):
        if not remote:
            remote = self._core.get(Config.SECTION_CORE_REMOTE)

        if remote:
            return self._init_remote(remote)

        has_non_default_remote = bool(
            self.repo.config.list_options(Config.SECTION_REMOTE_REGEX,
                                          Config.SECTION_REMOTE_URL))

        if has_non_default_remote:
            error_msg = ("no remote specified. Setup default remote with\n"
                         "    dvc remote default <remote name>\n"
                         "or use:\n"
                         "    dvc {} -r <remote name>".format(command))
        else:
            error_msg = ("no remote specified. Create a default remote with\n"
                         "    dvc remote add -d <remote name> <remote url>")

        raise NoRemoteError(error_msg)