diff --git a/tests/src/test/scala/runtime/actionContainers/Python3AiActionContainerTests.scala b/tests/src/test/scala/runtime/actionContainers/Python3AiActionContainerTests.scala index 09a1e4309fb3c8a9fa9a6a8fda1572264c576563..42cdec6814e8d809851b50c3945c620fd81c1e1f 100644 --- a/tests/src/test/scala/runtime/actionContainers/Python3AiActionContainerTests.scala +++ b/tests/src/test/scala/runtime/actionContainers/Python3AiActionContainerTests.scala @@ -20,6 +20,7 @@ package runtime.actionContainers import org.junit.runner.RunWith import org.scalatest.junit.JUnitRunner import common.WskActorSystem +import spray.json._ //import actionContainers.{ActionContainer} //import actionContainers.ActionContainer.withContainer @@ -29,6 +30,33 @@ class Python3AiActionContainerTests extends PythonActionContainerTests with WskA override lazy val imageName = "python3aiaction" - /** indicates if strings in python are unicode by default */ - override lazy val pythonStringAsUnicode = true + it should "run tensorflow" in { + val (out, err) = withActionContainer() { c => + val code = """ + |import tensorflow as tf + |def main(args): + | # Initialize two constants + | x1 = tf.constant([1,2,3,4]) + | x2 = tf.constant([5,6,7,8]) + | + | # Multiply + | result = tf.multiply(x1, x2) + | + | # Initialize Session and run `result` + | with tf.Session() as sess: + | output = sess.run(result) + | print(output) + | return { "response": output.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" -> JsArray(Vector(JsNumber(5),JsNumber(12),JsNumber(21),JsNumber(32)))))) + } + } }