mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-25 23:09:49 +01:00
42 lines
1.1 KiB
Python
42 lines
1.1 KiB
Python
import logging
|
|
import os
|
|
import threading
|
|
|
|
from funcy import cached_property, wrap_prop
|
|
|
|
from dvc.path_info import CloudURLInfo
|
|
from dvc.scheme import Schemes
|
|
|
|
from .fsspec_wrapper import CallbackMixin, ObjectFSWrapper
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
# pylint:disable=abstract-method
|
|
class OSSFileSystem(CallbackMixin, ObjectFSWrapper):
|
|
scheme = Schemes.OSS
|
|
PATH_CLS = CloudURLInfo
|
|
REQUIRES = {"ossfs": "ossfs"}
|
|
PARAM_CHECKSUM = "etag"
|
|
COPY_POLL_SECONDS = 5
|
|
LIST_OBJECT_PAGE_SIZE = 100
|
|
DETAIL_FIELDS = frozenset(("etag", "size"))
|
|
|
|
def _prepare_credentials(self, **config):
|
|
login_info = {}
|
|
login_info["key"] = config.get("oss_key_id") or os.getenv(
|
|
"OSS_ACCESS_KEY_ID"
|
|
)
|
|
login_info["secret"] = config.get("oss_key_secret") or os.getenv(
|
|
"OSS_ACCESS_KEY_SECRET"
|
|
)
|
|
login_info["endpoint"] = config.get("oss_endpoint")
|
|
return login_info
|
|
|
|
@wrap_prop(threading.Lock())
|
|
@cached_property
|
|
def fs(self):
|
|
from ossfs import OSSFileSystem as _OSSFileSystem
|
|
|
|
return _OSSFileSystem(**self.fs_args)
|