GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-workflow-definition/tests/test_cwl.py at main · pythonworkflow/python-workflow-definition

Expand file tree

/

test_cwl.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
55 lines (46 loc) · 1.84 KB
/

test_cwl.py

Copy path

File metadata and controls

55 lines (46 loc) · 1.84 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import unittest
import pickle
import subprocess
import tempfile
from pathlib import Path
from python_workflow_definition.cwl import write_workflow
function_str = """
def get_prod_and_div(x, y):
return {"prod": x * y, "div": x / y}
def get_sum(x, y):
return x + y
def get_square(x):
return x ** 2
"""
workflow_str = """
{
"version": "0.1.0",
"nodes": [
{"id": 0, "type": "function", "value": "workflow.get_prod_and_div"},
{"id": 1, "type": "function", "value": "workflow.get_sum"},
{"id": 2, "type": "function", "value": "workflow.get_square"},
{"id": 3, "type": "input", "value": 1, "name": "x"},
{"id": 4, "type": "input", "value": 2, "name": "y"},
{"id": 5, "type": "output", "name": "result"}
],
"edges": [
{"target": 0, "targetPort": "x", "source": 3, "sourcePort": null},
{"target": 0, "targetPort": "y", "source": 4, "sourcePort": null},
{"target": 1, "targetPort": "x", "source": 0, "sourcePort": "prod"},
{"target": 1, "targetPort": "y", "source": 0, "sourcePort": "div"},
{"target": 2, "targetPort": "x", "source": 1, "sourcePort": null},
{"target": 5, "targetPort": null, "source": 2, "sourcePort": null}
]
}"""
class TestCommonWorkflowLanguage(unittest.TestCase):
def test_common_workflow_language(self):
with tempfile.TemporaryDirectory() as tmpdir:
tmp_path = Path(tmpdir)
with open(tmp_path / "workflow.py", "w") as f:
f.write(function_str)
with open(tmp_path / "workflow.json", "w") as f:
f.write(workflow_str)
write_workflow(file_name=str(tmp_path / "workflow.json"), directory_path=tmpdir)
subprocess.check_output(["cwltool", "workflow.cwl", "workflow.yml"], cwd=tmpdir)
with open(tmp_path / "result.pickle", "rb") as f:
self.assertEqual(pickle.load(f), 6.25)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.