mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Merge pull request #3375 from jmchilton/fix_3268
[16.10] Fix implicit conversion for sessionless tool API calls.
This commit is contained in:
@@ -502,7 +502,7 @@ class Data( object ):
|
||||
"""Returns ( target_ext, existing converted dataset )"""
|
||||
return datatypes_registry.find_conversion_destination_for_dataset_by_extensions( dataset, accepted_formats, **kwd )
|
||||
|
||||
def convert_dataset(self, trans, original_dataset, target_type, return_output=False, visible=True, deps=None, target_context=None):
|
||||
def convert_dataset(self, trans, original_dataset, target_type, return_output=False, visible=True, deps=None, target_context=None, history=None):
|
||||
"""This function adds a job to the queue to convert a dataset to another type. Returns a message about success/failure."""
|
||||
converter = trans.app.datatypes_registry.get_converter_by_target_type( original_dataset.ext, target_type )
|
||||
|
||||
@@ -525,7 +525,7 @@ class Data( object ):
|
||||
params[input_name] = original_dataset
|
||||
|
||||
# Run converter, job is dispatched through Queue
|
||||
converted_dataset = converter.execute( trans, incoming=params, set_output_hid=visible )[1]
|
||||
converted_dataset = converter.execute( trans, incoming=params, set_output_hid=visible, history=history )[1]
|
||||
if len(params) > 0:
|
||||
trans.log_event( "Converter params: %s" % (str(params)), tool_id=converter.id )
|
||||
if not visible:
|
||||
|
||||
@@ -2041,7 +2041,7 @@ class DatasetInstance( object ):
|
||||
depends_list = []
|
||||
return dict([ (dep, self.get_converted_dataset(trans, dep)) for dep in depends_list ])
|
||||
|
||||
def get_converted_dataset(self, trans, target_ext, target_context=None):
|
||||
def get_converted_dataset(self, trans, target_ext, target_context=None, history=None):
|
||||
"""
|
||||
Return converted dataset(s) if they exist, along with a dict of dependencies.
|
||||
If not converted yet, do so and return None (the first time). If unconvertible, raise exception.
|
||||
@@ -2080,7 +2080,7 @@ class DatasetInstance( object ):
|
||||
raise NoConverterException("A dependency (%s) is missing a converter." % dependency)
|
||||
except KeyError:
|
||||
pass # No deps
|
||||
new_dataset = next(iter(self.datatype.convert_dataset( trans, self, target_ext, return_output=True, visible=False, deps=deps, target_context=target_context ).values()))
|
||||
new_dataset = next(iter(self.datatype.convert_dataset( trans, self, target_ext, return_output=True, visible=False, deps=deps, target_context=target_context, history=history ).values()))
|
||||
new_dataset.name = self.name
|
||||
self.copy_attributes( new_dataset )
|
||||
assoc = ImplicitlyConvertedDatasetAssociation( parent=self, file_type=target_ext, dataset=new_dataset, metadata_safe=False )
|
||||
|
||||
@@ -41,7 +41,7 @@ class ToolAction( object ):
|
||||
class DefaultToolAction( object ):
|
||||
"""Default tool action is to run an external command"""
|
||||
|
||||
def collect_input_datasets( self, tool, param_values, trans, current_user_roles=None ):
|
||||
def _collect_input_datasets( self, tool, param_values, trans, history, current_user_roles=None ):
|
||||
"""
|
||||
Collect any dataset inputs from incoming. Returns a mapping from
|
||||
parameter name to Dataset instance for each tool parameter that is
|
||||
@@ -66,7 +66,7 @@ class DefaultToolAction( object ):
|
||||
if converted_dataset:
|
||||
data = converted_dataset
|
||||
else:
|
||||
data = data.get_converted_dataset( trans, target_ext, target_context=parent )
|
||||
data = data.get_converted_dataset( trans, target_ext, target_context=parent, history=history )
|
||||
|
||||
if not trans.app.security_agent.can_access_dataset( current_user_roles, data.dataset ):
|
||||
raise Exception( "User does not have permission to use a dataset (%s) provided for input." % data.id )
|
||||
@@ -189,7 +189,7 @@ class DefaultToolAction( object ):
|
||||
# input datasets can process these normally.
|
||||
inp_dataset_collections = self.collect_input_dataset_collections( tool, incoming )
|
||||
# Collect any input datasets from the incoming parameters
|
||||
inp_data = self.collect_input_datasets( tool, incoming, trans, current_user_roles=current_user_roles )
|
||||
inp_data = self._collect_input_datasets( tool, incoming, trans, history=history, current_user_roles=current_user_roles )
|
||||
|
||||
return history, inp_data, inp_dataset_collections
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
<tool id="implicit_conversion" name="implicit_conversion">
|
||||
<command>
|
||||
cut -f 1 '$input1' > 'col_output'
|
||||
</command>
|
||||
<inputs>
|
||||
<param type="data" format="tabular" name="input1" label="Input 1" />
|
||||
</inputs>
|
||||
<outputs>
|
||||
<data name="output1" format="tabular" from_work_dir="col_output" />
|
||||
</outputs>
|
||||
<tests>
|
||||
<!-- Test implicit conversion. -->
|
||||
<test>
|
||||
<param name="input1" value="1.fasta" ftype="fasta" />
|
||||
<param name="col" value="1" />
|
||||
<output name="output1">
|
||||
<assert_contents>
|
||||
<has_line line="hg17" />
|
||||
</assert_contents>
|
||||
</output>
|
||||
</test>
|
||||
</tests>
|
||||
</tool>
|
||||
@@ -4,7 +4,9 @@
|
||||
<datatype extension="velvet" type="galaxy.datatypes.assembly:Velvet" display_in_upload="true"/>
|
||||
<datatype extension="txt" type="galaxy.datatypes.data:Text" display_in_upload="true"/>
|
||||
<datatype extension="tabular" type="galaxy.datatypes.tabular:Tabular" display_in_upload="true"/>
|
||||
<datatype extension="fasta" type="galaxy.datatypes.sequence:Fasta" display_in_upload="true" />
|
||||
<datatype extension="fasta" type="galaxy.datatypes.sequence:Fasta" display_in_upload="true">
|
||||
<converter file="fasta_to_tabular_converter.xml" target_datatype="tabular"/>
|
||||
</datatype>
|
||||
<datatype extension="fastq" type="galaxy.datatypes.sequence:Fastq" display_in_upload="true" />
|
||||
<datatype extension="fastqsanger" type="galaxy.datatypes.sequence:FastqSanger" display_in_upload="true" />
|
||||
<datatype extension="fastqsolexa" type="galaxy.datatypes.sequence:FastqSolexa" display_in_upload="true" />
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
<tool file="validation_repeat.xml" />
|
||||
<tool file="empty_output.xml" />
|
||||
<tool file="validation_empty_dataset.xml" />
|
||||
<tool file="implicit_conversion.xml" />
|
||||
<tool file="identifier_single.xml" />
|
||||
<tool file="identifier_multiple.xml" />
|
||||
<tool file="identifier_collection.xml" />
|
||||
|
||||
Reference in New Issue
Block a user