"tests/nn/git@developer.sourcefind.cn:OpenDAS/fairscale.git" did not exist on "81c20f72d9699e172df234455e0e8acf4e18611a"
Unverified Commit 5a98f7e4 authored by Jintao Lin's avatar Jintao Lin Committed by GitHub
Browse files

enalbe memcached support in PetrelBackend (#341)

parent 5f611bbb
...@@ -60,16 +60,17 @@ class PetrelBackend(BaseStorageBackend): ...@@ -60,16 +60,17 @@ class PetrelBackend(BaseStorageBackend):
path_mapping (dict|None): path mapping dict from local path to Petrel path_mapping (dict|None): path mapping dict from local path to Petrel
path. When `path_mapping={'src': 'dst'}`, `src` in `filepath` will path. When `path_mapping={'src': 'dst'}`, `src` in `filepath` will
be replaced by `dst`. Default: None. be replaced by `dst`. Default: None.
enable_mc (bool): whether to enable memcached support. Default: True.
""" """
def __init__(self, path_mapping=None): def __init__(self, path_mapping=None, enable_mc=True):
try: try:
from petrel_client import client from petrel_client import client
except ImportError: except ImportError:
raise ImportError('Please install petrel_client to enable ' raise ImportError('Please install petrel_client to enable '
'PetrelBackend.') 'PetrelBackend.')
self._client = client.Client() self._client = client.Client(enable_mc=enable_mc)
assert isinstance(path_mapping, dict) or path_mapping is None assert isinstance(path_mapping, dict) or path_mapping is None
self.path_mapping = path_mapping self.path_mapping = path_mapping
......
...@@ -15,6 +15,9 @@ sys.modules['mc'] = MagicMock() ...@@ -15,6 +15,9 @@ sys.modules['mc'] = MagicMock()
class MockS3Client(object): class MockS3Client(object):
def __init__(self, enable_mc=True):
self.enable_mc = enable_mc
def Get(self, filepath): def Get(self, filepath):
with open(filepath, 'rb') as f: with open(filepath, 'rb') as f:
content = f.read() content = f.read()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment