Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
f5d1714a
Commit
f5d1714a
authored
Jan 08, 2019
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Finally, default to msgpack
parent
7965f28c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
29 deletions
+23
-29
tensorpack/utils/serialize.py
tensorpack/utils/serialize.py
+23
-29
No files found.
tensorpack/utils/serialize.py
View file @
f5d1714a
...
@@ -4,11 +4,18 @@
...
@@ -4,11 +4,18 @@
import
os
import
os
import
sys
import
sys
import
msgpack
import
msgpack_numpy
from
.
import
logger
from
.
import
logger
from
.develop
import
create_dummy_func
from
.develop
import
create_dummy_func
msgpack_numpy
.
patch
()
assert
msgpack
.
version
>=
(
0
,
5
,
2
)
__all__
=
[
'loads'
,
'dumps'
]
__all__
=
[
'loads'
,
'dumps'
]
MAX_MSGPACK_LEN
=
1000000000
MAX_MSGPACK_LEN
=
1000000000
...
@@ -55,35 +62,22 @@ def loads_pyarrow(buf):
...
@@ -55,35 +62,22 @@ def loads_pyarrow(buf):
return
pa
.
deserialize
(
buf
)
return
pa
.
deserialize
(
buf
)
try
:
# import pyarrow has a lot of side effect:
# import pyarrow has a lot of side effect: https://github.com/apache/arrow/pull/2329
# https://github.com/apache/arrow/pull/2329
# So we need an option to disable it.
# https://groups.google.com/a/tensorflow.org/forum/#!topic/developers/TMqRaT-H2bI
if
os
.
environ
.
get
(
'TENSORPACK_SERIALIZE'
,
'pyarrow'
)
==
'pyarrow'
:
# So we use msgpack as default.
if
os
.
environ
.
get
(
'TENSORPACK_SERIALIZE'
,
'msgpack'
)
==
'pyarrow'
:
try
:
import
pyarrow
as
pa
import
pyarrow
as
pa
if
'horovod'
in
sys
.
modules
:
except
ImportError
:
logger
.
warn
(
"Horovod and pyarrow may conflict due to pyarrow bugs. "
loads_pyarrow
=
create_dummy_func
(
'loads_pyarrow'
,
[
'pyarrow'
])
# noqa
"Uninstall pyarrow and use msgpack instead."
)
dumps_pyarrow
=
create_dummy_func
(
'dumps_pyarrow'
,
[
'pyarrow'
])
# noqa
else
:
pa
=
None
if
'horovod'
in
sys
.
modules
:
except
ImportError
:
logger
.
warn
(
"Horovod and pyarrow may have symbol conflicts. "
pa
=
None
"Uninstall pyarrow and use msgpack instead."
)
dumps_pyarrow
=
create_dummy_func
(
'dumps_pyarrow'
,
[
'pyarrow'
])
# noqa
loads_pyarrow
=
create_dummy_func
(
'loads_pyarrow'
,
[
'pyarrow'
])
# noqa
try
:
import
msgpack
import
msgpack_numpy
msgpack_numpy
.
patch
()
assert
msgpack
.
version
>=
(
0
,
5
,
2
)
except
ImportError
:
loads_msgpack
=
create_dummy_func
(
# noqa
'loads_msgpack'
,
[
'msgpack'
,
'msgpack_numpy'
])
dumps_msgpack
=
create_dummy_func
(
# noqa
'dumps_msgpack'
,
[
'msgpack'
,
'msgpack_numpy'
])
if
pa
is
None
or
os
.
environ
.
get
(
'TENSORPACK_SERIALIZE'
,
None
)
==
'msgpack'
:
loads
=
loads_msgpack
dumps
=
dumps_msgpack
else
:
loads
=
loads_pyarrow
loads
=
loads_pyarrow
dumps
=
dumps_pyarrow
dumps
=
dumps_pyarrow
else
:
loads
=
loads_msgpack
dumps
=
dumps_msgpack
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