Example #1
0
def _get_remotes(config):
    schemes = (
        get_fs_cls(get_fs_config(None, config, name=remote)).scheme
        for remote in config["remote"]
    )

    return ", ".join(schemes) or "None"
Example #2
0
    def from_bytes(cls, data: bytes, fs_cache: Optional[dict] = None):
        from dvc.fs import get_fs_cls
        from dvc.fs.repo import RepoFileSystem

        try:
            dict_ = pickle.loads(data)
        except pickle.PickleError as exc:
            raise ObjectFormatError("ReferenceHashFile is corrupted") from exc

        try:
            fs_path = dict_[cls.PARAM_PATH]
            hash_info = dict_[cls.PARAM_HASH]
        except KeyError as exc:
            raise ObjectFormatError("ReferenceHashFile is corrupted") from exc

        scheme, config_pairs = dict_.get(cls.PARAM_FS_CONFIG)
        fs = fs_cache.get((scheme, config_pairs)) if fs_cache else None
        if not fs:
            config = dict(config_pairs)
            if RepoFileSystem.PARAM_REPO_URL in config:
                fs = RepoFileSystem(**config)
                fs_path = fs.path.join(fs.root_dir, fs_path)
            else:
                fs_cls = get_fs_cls(config, scheme=scheme)
                fs = fs_cls(**config)
        return ReferenceHashFile(
            fs_path,
            fs,
            hash_info,
            checksum=dict_.get(cls.PARAM_CHECKSUM),
        )
Example #3
0
def test_get_fs_cls(url, cls):
    assert get_fs_cls({"url": url}) == cls