Skip to content

Commit 9b1dc0a

Browse files
committed
support multi-source-inputs
1 parent 75f41a1 commit 9b1dc0a

File tree

4 files changed

+161
-20
lines changed

4 files changed

+161
-20
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
## v1.4.5 [unreleased]
55

66
Switch to snakeyaml-engine (YAML 1.2) from snakeyaml (YAML 1.1)
7+
Support workflows using `MultipleInputFeatureRequirement`
78

89
## v1.4.4 [2022-06-08]
910

src/main/java/org/commonwl/view/cwl/CWLService.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,14 @@ private Map<String, CWLElement> getStepInputsOutputs(Object inOut) {
758758
if (Map.class.isAssignableFrom(inOutNode.getClass())) {
759759
Map<String, Object> properties = (Map<String, Object>) inOutNode;
760760
if (properties.containsKey(SOURCE)) {
761-
inputOutput.addSourceID(stepIDFromSource((String) properties.get(SOURCE)));
761+
Object source = properties.get(SOURCE);
762+
if (List.class.isAssignableFrom(source.getClass())) {
763+
for (String sourceEntry : (List<String>) source) {
764+
inputOutput.addSourceID(stepIDFromSource(sourceEntry));
765+
}
766+
} else {
767+
inputOutput.addSourceID(stepIDFromSource((String) source));
768+
}
762769
} else {
763770
inputOutput.setDefaultVal(extractDefault(properties));
764771
}

src/test/java/org/commonwl/view/cwl/CWLServiceTest.java

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@
1919

2020
package org.commonwl.view.cwl;
2121

22+
import static org.apache.commons.io.FileUtils.readFileToString;
23+
import static org.junit.jupiter.api.Assertions.assertEquals;
24+
import static org.junit.jupiter.api.Assertions.assertNotNull;
25+
import static org.junit.jupiter.api.Assertions.assertNull;
26+
import static org.junit.jupiter.api.Assertions.assertTrue;
27+
import static org.mockito.ArgumentMatchers.any;
28+
import static org.mockito.Mockito.when;
29+
30+
import java.io.ByteArrayInputStream;
31+
import java.io.File;
32+
import java.io.IOException;
33+
import java.io.InputStream;
34+
import java.net.URI;
35+
import java.nio.file.Paths;
36+
import java.util.List;
37+
import java.util.Map;
38+
2239
import org.apache.jena.query.Dataset;
2340
import org.apache.jena.query.DatasetFactory;
2441
import org.apache.jena.query.Query;
@@ -39,25 +56,6 @@
3956
import org.mockito.invocation.InvocationOnMock;
4057
import org.mockito.stubbing.Answer;
4158

42-
import java.io.ByteArrayInputStream;
43-
import java.io.File;
44-
import java.io.IOException;
45-
import java.io.InputStream;
46-
import java.net.URI;
47-
import java.net.URL;
48-
import java.nio.file.Path;
49-
import java.nio.file.Paths;
50-
import java.util.List;
51-
import java.util.Map;
52-
53-
import static org.apache.commons.io.FileUtils.readFileToString;
54-
import static org.junit.jupiter.api.Assertions.assertEquals;
55-
import static org.junit.jupiter.api.Assertions.assertNotNull;
56-
import static org.junit.jupiter.api.Assertions.assertNull;
57-
import static org.junit.jupiter.api.Assertions.assertTrue;
58-
import static org.mockito.ArgumentMatchers.any;
59-
import static org.mockito.Mockito.when;
60-
6159
public class CWLServiceTest {
6260

6361
/**
@@ -156,6 +154,18 @@ public void parseWorkflowInlineOptionalTypesNative() throws Exception {
156154
assertEquals(wkflow.getInputs().get("rfam_models").getType(), "{type=array, items=[string, File]}");
157155

158156
}
157+
158+
/**
159+
* Test native loading parsing of MultipleInputFeatureRequirement using workflows
160+
*/
161+
@Test
162+
public void parseWorkflowMultiInboundLins() throws Exception {
163+
CWLService cwlService = new CWLService(rdfService, new CWLTool(), 5242880);
164+
Workflow wkflow = cwlService.parseWorkflowNative(Paths.get("src/test/resources/cwl/complex-workflow/complex-workflow-1.cwl"),
165+
null);
166+
assertEquals(wkflow.getSteps().get("re_tar_step").getSources().get("file_list").getSourceIDs().get(0), "touch_step");
167+
assertEquals(wkflow.getSteps().get("re_tar_step").getSources().get("file_list").getSourceIDs().get(1), "files");
168+
}
159169

160170
/**
161171
* Test native loading parsing of nested array types
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Source: https://github.com/heliumdatacommons/TOPMed_RNAseq_CWL/tree/578066ec5d6847892528f973b22531d4c8487280/workflows/complex-workflow
2+
3+
# BSD 3-Clause License
4+
#
5+
# Copyright (c) 2018, RTI International
6+
# All rights reserved.
7+
#
8+
# Redistribution and use in source and binary forms, with or without
9+
# modification, are permitted provided that the following conditions are met:
10+
#
11+
# * Redistributions of source code must retain the above copyright notice, this
12+
# list of conditions and the following disclaimer.
13+
#
14+
# * Redistributions in binary form must reproduce the above copyright notice,
15+
# this list of conditions and the following disclaimer in the documentation
16+
# and/or other materials provided with the distribution.
17+
#
18+
# * Neither the name of the copyright holder nor the names of its
19+
# contributors may be used to endorse or promote products derived from
20+
# this software without specific prior written permission.
21+
#
22+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25+
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26+
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27+
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28+
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29+
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30+
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32+
33+
cwlVersion: v1.0
34+
class: Workflow
35+
id: complex-workflow
36+
inputs:
37+
archive:
38+
type: string
39+
files:
40+
type:
41+
type: array
42+
items: File
43+
new_archive:
44+
type: string
45+
touch_files:
46+
type:
47+
type: array
48+
items: string
49+
echo_message:
50+
type: string
51+
echo_output_location:
52+
type: string
53+
54+
outputs:
55+
archive_out:
56+
type: File
57+
outputSource: tar_step/archive_out
58+
touch_out:
59+
type:
60+
type: array
61+
items: File
62+
outputSource: touch_step/file_out
63+
echo_out:
64+
type: File
65+
outputSource: echo_step/echo_output
66+
re_tar_out:
67+
type: File
68+
outputSource: re_tar_step/archive_out
69+
70+
steps:
71+
tar_step:
72+
run: tar.cwl
73+
in:
74+
archive_file:
75+
source: "#archive"
76+
file_list:
77+
source: "#files"
78+
out: [archive_out]
79+
80+
touch_step:
81+
run: touch.cwl
82+
scatter: filename
83+
scatterMethod: dotproduct
84+
in:
85+
waitfor:
86+
source: "#tar_step/archive_out"
87+
filename:
88+
source: "#touch_files"
89+
out: [file_out]
90+
91+
echo_step:
92+
run: echo.cwl
93+
in:
94+
message: "#echo_message"
95+
output_location: "#echo_output_location"
96+
out: [echo_output]
97+
98+
re_tar_step:
99+
run: tar.cwl
100+
in:
101+
archive_file:
102+
source: "#archive"
103+
file_list:
104+
source: ["#touch_step/file_out", "#files"]
105+
linkMerge: merge_flattened
106+
out: [archive_out]
107+
108+
# rm_step:
109+
# run: rm.cwl
110+
# scatter: filename
111+
# scatterMethod: dotproduct
112+
# in:
113+
# waitfor:
114+
# source: "#re_tar_step/archive_out"
115+
# filename:
116+
# source: ["#files", "#touch_step/file_out", "#echo_step/echo_output"]
117+
# linkMerge: merge_flattened
118+
# out: [standard_out]
119+
120+
requirements:
121+
- class: StepInputExpressionRequirement
122+
- class: ScatterFeatureRequirement
123+
- class: MultipleInputFeatureRequirement

0 commit comments

Comments
 (0)