File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed
Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ import unittest
2+ import os
3+ from pyiron_workflow import Workflow , to_function_node
4+ from python_workflow_definition .pyiron_workflow import load_workflow_json , write_workflow_json
5+
6+
7+ def get_prod_and_div (x , y ):
8+ return {"prod" : x * y , "div" : x / y }
9+
10+
11+ def get_sum (x , y ):
12+ return x + y
13+
14+
15+ def get_square (x ):
16+ return x ** 2
17+
18+
19+ class TestPyironWorkflow (unittest .TestCase ):
20+ def test_pyiron_workflow (self ):
21+ workflow_json_filename = "pyiron_workflow_arithmetic.json"
22+ get_prod_and_div_node = to_function_node ("get_prod_and_div" , get_prod_and_div , "get_prod_and_div" )
23+ get_sum_node = to_function_node ("get_sum" , get_sum , "get_sum" )
24+ get_square_node = to_function_node ("get_square" , get_square , "get_square" )
25+ wf = Workflow ("my_workflow" )
26+ wf .x = 1
27+ wf .y = 2
28+ wf .prod_and_div = get_prod_and_div_node (x = wf .x , y = wf .y )
29+ wf .tmp_sum = get_sum_node (x = wf .prod_and_div ["prod" ], y = wf .prod_and_div ["div" ])
30+ wf .square_result = get_square_node (x = wf .tmp_sum )
31+ write_workflow_json (graph_as_dict = wf .graph_as_dict , file_name = workflow_json_filename )
32+ wf = load_workflow_json (file_name = workflow_json_filename )
33+ wf .run ()
34+
35+ self .assertTrue (os .path .exists (workflow_json_filename ))
You can’t perform that action at this time.
0 commit comments