Skip to content

Commit b997b3e

Browse files
authored
Merge pull request #840 from jmchilton/uri_testing_workflows
Allow URIs for workflow testing w/tests.
2 parents 92a79de + a75ec1c commit b997b3e

8 files changed

Lines changed: 64 additions & 5 deletions

File tree

planemo/galaxy/activity.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
invocation_to_output,
1818
output_properties,
1919
output_to_cwl_json,
20+
path_or_uri_to_uri,
2021
tool_response_to_output,
2122
)
2223
from galaxy.tools.parser import get_tool_source
@@ -179,12 +180,14 @@ def stage_in(ctx, runnable, config, user_gi, history_id, job_path, **kwds):
179180
def upload_func(upload_target):
180181

181182
def _attach_file(upload_payload, uri, index=0):
182-
is_path = not uri.startswith("http://") and not uri.startswith("https://") and not uri.startswith("ftp://")
183-
if config.use_path_paste and is_path:
184-
upload_payload["inputs"]["files_%d|url_paste" % index] = "file://%s" % os.path.abspath(uri)
183+
uri = path_or_uri_to_uri(uri)
184+
is_path = uri.startswith("file://")
185+
if not is_path or config.use_path_paste:
186+
upload_payload["inputs"]["files_%d|url_paste" % index] = uri
185187
else:
186188
files_attached[0] = True
187-
upload_payload["files_%d|file_data" % index] = attach_file(uri)
189+
path = uri[len("file://"):]
190+
upload_payload["files_%d|file_data" % index] = attach_file(path)
188191

189192
if isinstance(upload_target, FileUploadTarget):
190193
file_path = upload_target.path

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ virtualenv
1313
lxml
1414
gxformat2>=0.2.0
1515
ephemeris>=0.8
16-
galaxy-lib>=18.5.11
16+
galaxy-lib>=18.5.12
1717
html5lib>=0.9999999,!=0.99999999,!=0.999999999,!=1.0b10,!=1.0b09
1818
cwltool==1.0.20180508202931

tests/data/cat_tool_url.cwl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env cwl-runner
2+
class: CommandLineTool
3+
cwlVersion: 'v1.0'
4+
doc: "Print the contents of a file to stdout using 'cat' running in a docker container."
5+
hints:
6+
- class: DockerRequirement
7+
dockerPull: debian:wheezy
8+
inputs:
9+
file1:
10+
type: File
11+
label: Input File
12+
doc: "The file that will be copied using 'cat'"
13+
inputBinding: {position: 1}
14+
outputs:
15+
output_file:
16+
type: File
17+
outputBinding: {glob: output.txt}
18+
baseCommand:
19+
- cat
20+
stdout: output.txt

tests/data/cat_tool_url_job.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"file1": {
3+
"class": "File",
4+
"path": "https://raw.githubusercontent.com/galaxyproject/planemo/master/tests/data/hello.txt"
5+
}
6+
}

tests/data/cat_tool_url_test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- doc: Simple test
2+
job: cat_tool_url_job.json
3+
outputs:
4+
output_file:
5+
checksum: sha1$2ef7bde608ce5404e97d5f042f95f89f1c232871
6+

tests/data/wf1.gxwf-job-url.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"input1": {
3+
"class": "File",
4+
"location": "https://raw.githubusercontent.com/galaxyproject/planemo/master/tests/data/hello.txt"
5+
},
6+
}

tests/data/wf1.gxwf-test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@
33
outputs:
44
wf_output_1:
55
checksum: "sha1$a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b"
6+
- doc: concat workflow test with URL
7+
job: wf1.gxwf-job-url.yml
8+
outputs:
9+
wf_output_1:
10+
checksum: "sha1$a0b65939670bc2c010f4d5d6a0b3e4e4590fb92b"

tests/test_cmd_test.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,19 @@ def test_cwltool_tool_test(self):
9494
self._check_exit_code(test_command, exit_code=0)
9595
assert_exists(os.path.join(f, "tool_test_output.json"))
9696

97+
@skip_if_environ("PLANEMO_SKIP_CWLTOOL_TESTS")
98+
def test_cwltool_tool_url_inputs_test(self):
99+
"""Test testing a CWL tool with cwltool."""
100+
with self._isolate() as f:
101+
test_artifact = os.path.join(TEST_DATA_DIR, "cat_tool_url.cwl")
102+
test_command = [
103+
"test",
104+
"--no-container",
105+
test_artifact,
106+
]
107+
self._check_exit_code(test_command, exit_code=0)
108+
assert_exists(os.path.join(f, "tool_test_output.json"))
109+
97110
@skip_if_environ("PLANEMO_SKIP_CWLTOOL_TESTS")
98111
@skip_unless_module("toil")
99112
def test_toil_tool_test(self):

0 commit comments

Comments
 (0)