mirror of https://github.com/open-mmlab/mmcv.git
[Enhance] Add conf_path in PetrelBackend (#2459)
* feat: add conf_path in PetrelBackend * fix: add conf_path in MockPetrelClient * fix: adjust parameters ordermlu-dev
parent
ece11bc134
commit
c1712ee290
|
@ -97,6 +97,8 @@ class PetrelBackend(BaseStorageBackend):
|
|||
``filepath`` will be replaced by ``dst``. Default: None.
|
||||
enable_mc (bool, optional): Whether to enable memcached support.
|
||||
Default: True.
|
||||
conf_path (str, optional): Config path of Petrel client. Default: None.
|
||||
`New in version 1.7.1`.
|
||||
|
||||
Examples:
|
||||
>>> filepath1 = 's3://path/of/file'
|
||||
|
@ -108,14 +110,15 @@ class PetrelBackend(BaseStorageBackend):
|
|||
|
||||
def __init__(self,
|
||||
path_mapping: Optional[dict] = None,
|
||||
enable_mc: bool = True):
|
||||
enable_mc: bool = True,
|
||||
conf_path: str = None):
|
||||
try:
|
||||
from petrel_client import client
|
||||
except ImportError:
|
||||
raise ImportError('Please install petrel_client to enable '
|
||||
'PetrelBackend.')
|
||||
|
||||
self._client = client.Client(enable_mc=enable_mc)
|
||||
self._client = client.Client(conf_path=conf_path, enable_mc=enable_mc)
|
||||
assert isinstance(path_mapping, dict) or path_mapping is None
|
||||
self.path_mapping = path_mapping
|
||||
|
||||
|
|
|
@ -78,9 +78,13 @@ class MockS3Client:
|
|||
|
||||
class MockPetrelClient:
|
||||
|
||||
def __init__(self, enable_mc=True, enable_multi_cluster=False):
|
||||
def __init__(self,
|
||||
enable_mc=True,
|
||||
enable_multi_cluster=False,
|
||||
conf_path=None):
|
||||
self.enable_mc = enable_mc
|
||||
self.enable_multi_cluster = enable_multi_cluster
|
||||
self.conf_path = conf_path
|
||||
|
||||
def Get(self, filepath):
|
||||
with open(filepath, 'rb') as f:
|
||||
|
|
Loading…
Reference in New Issue