Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
5a98f7e4
"tests/nn/git@developer.sourcefind.cn:OpenDAS/fairscale.git" did not exist on "81c20f72d9699e172df234455e0e8acf4e18611a"
Unverified
Commit
5a98f7e4
authored
Jun 13, 2020
by
Jintao Lin
Committed by
GitHub
Jun 13, 2020
Browse files
enalbe memcached support in PetrelBackend (#341)
parent
5f611bbb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
2 deletions
+6
-2
mmcv/fileio/file_client.py
mmcv/fileio/file_client.py
+3
-2
tests/test_fileclient.py
tests/test_fileclient.py
+3
-0
No files found.
mmcv/fileio/file_client.py
View file @
5a98f7e4
...
@@ -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
...
...
tests/test_fileclient.py
View file @
5a98f7e4
...
@@ -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
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment