Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Open sidebar
datadrivendiscovery
tests-data
Commits
df0fe1cf
Commit
df0fe1cf
authored
Dec 27, 2017
by
Mitar
Browse files
Make sure lists are pickable, too.
parent
341c276e
Pipeline
#15524235
passed with stage
in 2 minutes and 46 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
5 deletions
+11
-5
primitives/test_primitives/sum.py
primitives/test_primitives/sum.py
+11
-5
No files found.
primitives/test_primitives/sum.py
View file @
df0fe1cf
...
...
@@ -94,14 +94,20 @@ class SumPrimitive(base.SingletonOutputMixin[Inputs, Outputs, None, Hyperparams]
if
DOCKER_KEY
not
in
self
.
docker_containers
:
raise
ValueError
(
"Docker key '{docker_key}' missing among provided Docker containers."
.
format
(
docker_key
=
DOCKER_KEY
))
def
_convert_value
(
self
,
value
:
typing
.
Any
)
->
typing
.
Union
[
numpy
.
ndarray
,
typing
.
List
,
typing
.
Any
]:
# Server does not know about container types, just standard numpy arrays and lists.
if
isinstance
(
value
,
container
.
ndarray
):
return
value
.
view
(
numpy
.
ndarray
)
elif
isinstance
(
value
,
container
.
List
):
return
[
self
.
_convert_value
(
v
)
for
v
in
value
]
else
:
return
value
def
produce
(
self
,
*
,
inputs
:
Inputs
,
timeout
:
float
=
None
,
iterations
:
int
=
None
)
->
base
.
CallResult
[
Outputs
]:
# In the future, we should store here data in Arrow format into
# Plasma store and just pass an ObjectId of data over HTTP.
if
isinstance
(
inputs
,
container
.
ndarray
):
value
=
inputs
.
view
(
numpy
.
ndarray
)
data
=
pickle
.
dumps
(
value
)
else
:
data
=
pickle
.
dumps
(
inputs
)
value
=
self
.
_convert_value
(
inputs
)
data
=
pickle
.
dumps
(
value
)
# TODO: Retry if connection fails.
# This connection can sometimes fail because the service inside a Docker container
...
...
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