Add additional tests

This commit is contained in:
davidmezzetti
2022-02-02 22:13:38 -05:00
parent 52f6cb1657
commit cbba20adb4
4 changed files with 40 additions and 1 deletions
+22
View File
@@ -7,6 +7,7 @@ import glob
import io
import os
import tempfile
import sys
import unittest
import numpy as np
@@ -410,6 +411,27 @@ class TestWorkflow(unittest.TestCase):
results = np.array([x.numpy() for x in workflow(torch.tensor([2, 4, 6]))])
self.assertTrue(np.array_equal(np.array(results), np.array([[4, 16, 36], [8, 64, 216]])))
def testYamlFunctionWorkflow(self):
"""
Tests YAML workflow with a function action
"""
# Create function and add to module
def action(elements):
return [x * 2 for x in elements]
sys.modules[__name__].action = action
workflow = """
workflow:
run:
tasks:
- testworkflow.action
"""
app = API(workflow)
self.assertEqual(list(app.workflow("run", [1, 2])), [2, 4])
def testYamlIndexWorkflow(self):
"""
Tests reading a YAML index workflow in Python.