Skip to content

Commit ebf2dc3

Browse files
author
Anton Khodak
committed
Add tests for MultithreadedJobExecutor
1 parent 6e99ebf commit ebf2dc3

File tree

4 files changed

+77
-1
lines changed

4 files changed

+77
-1
lines changed

tests/test_parallel.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import json
2+
import unittest
3+
4+
import cwltool
5+
import cwltool.factory
6+
from cwltool.executors import MultithreadedJobExecutor
7+
from tests.util import get_data
8+
9+
10+
class TestParallel(unittest.TestCase):
11+
def test_sequential_workflow(self):
12+
test_file = "tests/wf/count-lines1-wf.cwl"
13+
f = cwltool.factory.Factory(executor=MultithreadedJobExecutor())
14+
echo = f.make(get_data(test_file))
15+
self.assertEqual(echo(file1= {
16+
"class": "File",
17+
"location": "tests/wf/whale.txt"
18+
}),
19+
{"count_output": 16})
20+
21+
def test_scattered_workflow(self):
22+
test_file = "tests/wf/scatter-wf4.cwl"
23+
job_file = "tests/wf/scatter-job2.json"
24+
f = cwltool.factory.Factory(executor=MultithreadedJobExecutor())
25+
echo = f.make(get_data(test_file))
26+
with open(get_data(job_file)) as job:
27+
self.assertEqual(echo(**json.load(job)), {'out': ['foo one three', 'foo two four']})

tests/wf/count-lines1-wf.cwl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env cwl-runner
21
class: Workflow
32
cwlVersion: v1.0
43

tests/wf/scatter-job2.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"inp1": ["one", "two"],
3+
"inp2": ["three", "four"]
4+
}

tests/wf/scatter-wf4.cwl

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env cwl-runner
2+
cwlVersion: v1.0
3+
$graph:
4+
- id: echo
5+
class: CommandLineTool
6+
inputs:
7+
echo_in1:
8+
type: string
9+
inputBinding: {}
10+
echo_in2:
11+
type: string
12+
inputBinding: {}
13+
outputs:
14+
echo_out:
15+
type: string
16+
outputBinding:
17+
glob: "step1_out"
18+
loadContents: true
19+
outputEval: $(self[0].contents)
20+
baseCommand: "echo"
21+
arguments: ["-n", "foo"]
22+
stdout: step1_out
23+
24+
- id: main
25+
class: Workflow
26+
inputs:
27+
inp1: string[]
28+
inp2: string[]
29+
requirements:
30+
- class: ScatterFeatureRequirement
31+
steps:
32+
step1:
33+
scatter: [echo_in1, echo_in2]
34+
scatterMethod: dotproduct
35+
in:
36+
echo_in1: inp1
37+
echo_in2: inp2
38+
out: [echo_out]
39+
run: "#echo"
40+
41+
outputs:
42+
- id: out
43+
outputSource: step1/echo_out
44+
type:
45+
type: array
46+
items: string

0 commit comments

Comments
 (0)