Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openwhisk-runtime-python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Groundhog
openwhisk-runtime-python
Commits
dc8225ae
Commit
dc8225ae
authored
6 years ago
by
Dragos Dascalita Haut
Browse files
Options
Downloads
Patches
Plain Diff
added a test for pytorch and numpy
parent
c33553fe
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/test/scala/runtime/actionContainers/Python3AiActionContainerTests.scala
+33
-0
33 additions, 0 deletions
...time/actionContainers/Python3AiActionContainerTests.scala
with
33 additions
and
0 deletions
tests/src/test/scala/runtime/actionContainers/Python3AiActionContainerTests.scala
+
33
−
0
View file @
dc8225ae
...
...
@@ -58,4 +58,37 @@ class Python3AiActionContainerTests extends PythonActionContainerTests with WskA
runRes
should
be
(
Some
(
JsObject
(
"response"
->
List
(
5
,
12
,
21
,
32
).
toJson
)))
}
}
it
should
"run pytorch"
in
{
val
(
out
,
err
)
=
withActionContainer
()
{
c
=>
val
code
=
"""
|import torch
|import torchvision
|import torch.nn as nn
|import numpy as np
|import torchvision.transforms as transforms
|def main(args):
| # Create a numpy array.
| x = np.array([1,2,3,4])
|
| # Convert the numpy array to a torch tensor.
| y = torch.from_numpy(x)
|
| # Convert the torch tensor to a numpy array.
| z = y.numpy()
| return { "response": z.tolist()}
"""
.
stripMargin
val
(
initCode
,
res
)
=
c
.
init
(
initPayload
(
code
))
initCode
should
be
(
200
)
val
(
runCode
,
runRes
)
=
c
.
run
(
runPayload
(
JsObject
()))
runCode
should
be
(
200
)
runRes
shouldBe
defined
runRes
should
be
(
Some
(
JsObject
(
"response"
->
List
(
1
,
2
,
3
,
4
).
toJson
)))
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment