transforms¶
This example is used by yggdrasil to test the support transformations in each of the supported languages and should not be used outside of the tests.
R Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
C Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
C++ Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
Dummy Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
Fortran Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
Julia Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
Matlab Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
OpenSimRoot Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
Python Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
PyTorch Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
SBML Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}
Timesync Version¶
Model Code:
1from yggdrasil.tools import pprint_encoded
2from yggdrasil.examples.transforms import get_test_data
3
4
5def src():
6 test_data = get_test_data()
7 print('SENDING')
8 pprint_encoded(test_data)
9 return test_data
1import os
2from yggdrasil.examples.transforms import check_received_data
3
4
5def dst(received_data):
6 transform = os.environ['TEST_TRANSFORM']
7 check_received_data(transform, received_data)
8 print('CONFIRMED')
9 return
Model YAML:
1models:
2 - name: source
3 language: python
4 args: ./src/src.py
5 function: src
6
7 - name: {{TEST_LANGUAGE}}_model
8 language: {{TEST_LANGUAGE}}
9 args: ./src/model{{TEST_LANGUAGE_EXT}}
10 function: model
11 {{{TEST_MODEL_IO}}}
12
13 - name: destination
14 language: python
15 args: ./src/dst.py
16 function: dst
17
18connections:
19 - input: source:output
20 output:
21 name: {{TEST_LANGUAGE}}_model:input
22 transform: {{TEST_TRANSFORM}}
23 - input:
24 name: {{TEST_LANGUAGE}}_model:output
25 transform: {{TEST_TRANSFORM}}
26 output:
27 name: destination:input
28 transform: {{TEST_TRANSFORM}}