Skip to content

Commit

Permalink
Merge pull request #4722 from jmchilton/empty_datasets
Browse files Browse the repository at this point in the history
Fix to respect galaxy.json supplied metadata for empty outputs.
  • Loading branch information
martenson committed Oct 13, 2017
2 parents 73b4629 + d65a060 commit f4d4554
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/galaxy/jobs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
# that import Galaxy internals - but it shouldn't be used in Galaxy's code
# itself.
TOOL_PROVIDED_JOB_METADATA_FILE = 'galaxy.json'
TOOL_PROVIDED_JOB_METADATA_KEYS = ['name', 'info', 'dbkey']

# Override with config.default_job_shell.
DEFAULT_JOB_SHELL = '/bin/bash'
Expand Down Expand Up @@ -1320,14 +1321,17 @@ def path_rewriter(path):
dataset.set_peek(is_multi_byte=True)
else:
dataset.set_peek()
for context_key in ['name', 'info', 'dbkey']:
if context_key in context:
context_value = context[context_key]
setattr(dataset, context_key, context_value)
else:
# Handle an empty dataset.
dataset.blurb = "empty"
if dataset.ext == 'auto':
dataset.extension = 'txt'
dataset.extension = context.get('ext', 'txt')

for context_key in TOOL_PROVIDED_JOB_METADATA_KEYS:
if context_key in context:
context_value = context[context_key]
setattr(dataset, context_key, context_value)

self.sa_session.add(dataset)
if job.states.ERROR == final_job_state:
log.debug("(%s) setting dataset %s state to ERROR", job.id, dataset_assoc.dataset.dataset.id)
Expand Down
34 changes: 34 additions & 0 deletions test/functional/tools/empty_datasets.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<tool id="empty_datasets" name="empty_datasets" version="1.0.0" profile="17.09">
<command>
touch $output;
touch out;
touch out_meta;
cp $c1 galaxy.json
</command>
<configfiles>
<configfile name="c1">{"output_tool_supplied_metadata": {
"name": "my dynamic name",
"ext": "fasta",
"info": "my dynamic info"
}}
</configfile>
</configfiles>
<inputs>
<param name="input" type="integer" value="0" />
</inputs>
<outputs>
<data name="output" format="txt" />
<data name="output_workdir" from_work_dir="out" format="txt" />
<data name="output_tool_supplied_metadata" from_work_dir="out_meta" format="auto" />
</outputs>
<tests>
<test>
<param name="input" value="7" />
<output name="output" md5="d41d8cd98f00b204e9800998ecf8427e" />
<output name="output_workdir" md5="d41d8cd98f00b204e9800998ecf8427e" />
<output name="output_tool_supplied_metadata" md5="d41d8cd98f00b204e9800998ecf8427e" ftype="fasta">
<metadata name="name" value="my dynamic name" />
</output>
</test>
</tests>
</tool>
1 change: 1 addition & 0 deletions test/functional/tools/samples_tool_conf.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<tool file="tool_provided_metadata_7.xml" />
<tool file="tool_provided_metadata_8.xml" />
<tool file="tool_provided_metadata_9.xml" />
<tool file="empty_datasets.xml" />
<tool file="inputs_as_json.xml" />
<tool file="dbkey_filter_input.xml" />
<tool file="dbkey_filter_multi_input.xml" />
Expand Down

0 comments on commit f4d4554

Please sign in to comment.