mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-26 15:28:28 +01:00
* fs: don't use repo for jobs/hash_jobs * fs: local: exists: use fsspec's LocalFileSystem * fs: make constructor comply with fsspec
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
import base64
|
|
import threading
|
|
|
|
from funcy import cached_property, wrap_prop
|
|
|
|
from dvc.path_info import CloudURLInfo
|
|
from dvc.scheme import Schemes
|
|
|
|
from .fsspec_wrapper import FSSpecWrapper
|
|
|
|
|
|
class GSFileSystem(FSSpecWrapper): # pylint:disable=abstract-method
|
|
scheme = Schemes.GS
|
|
PATH_CLS = CloudURLInfo
|
|
REQUIRES = {"gcsfs": "gcsfs"}
|
|
PARAM_CHECKSUM = "etag"
|
|
DETAIL_FIELDS = frozenset(("etag", "size"))
|
|
|
|
def __init__(self, **config):
|
|
super().__init__(**config)
|
|
|
|
url = config.get("url", "gs://")
|
|
self.path_info = self.PATH_CLS(url)
|
|
|
|
def _prepare_credentials(self, **config):
|
|
login_info = {"consistency": None}
|
|
login_info["project"] = config.get("projectname")
|
|
login_info["token"] = config.get("credentialpath")
|
|
return login_info
|
|
|
|
def _entry_hook(self, entry):
|
|
if "etag" in entry:
|
|
entry["etag"] = base64.b64decode(entry["etag"]).hex()
|
|
return entry
|
|
|
|
@wrap_prop(threading.Lock())
|
|
@cached_property
|
|
def fs(self):
|
|
from gcsfs import GCSFileSystem
|
|
|
|
return GCSFileSystem(**self.fs_args)
|