Commits

John Chilton committed c14bdcb

Allow discovered datasets to use input data format in 'ext' definition.

  • Participants
  • Parent commits 21b53eb
  • Branches stable

Comments (0)

Files changed (4)

File lib/galaxy/jobs/__init__.py

         out_data = dict( [ ( da.name, da.dataset ) for da in job.output_datasets ] )
         inp_data.update( [ ( da.name, da.dataset ) for da in job.input_library_datasets ] )
         out_data.update( [ ( da.name, da.dataset ) for da in job.output_library_datasets ] )
+        input_ext = 'data'
+        for _, data in inp_data.items():
+            # For loop odd, but sort simulating behavior in galaxy.tools.actions
+            if not data:
+                continue
+            input_ext = data.ext
+
         param_dict = dict( [ ( p.name, p.value ) for p in job.parameters ] )  # why not re-use self.param_dict here? ##dunno...probably should, this causes tools.parameters.basic.UnvalidatedValue to be used in following methods instead of validated and transformed values during i.e. running workflows
         param_dict = self.tool.params_from_strings( param_dict, self.app )
         # Check for and move associated_files
         # Create generated output children and primary datasets and add to param_dict
         collected_datasets = {
             'children': self.tool.collect_child_datasets(out_data, self.working_directory),
-            'primary': self.tool.collect_primary_datasets(out_data, self.working_directory)
+            'primary': self.tool.collect_primary_datasets(out_data, self.working_directory, input_ext)
         }
         param_dict.update({'__collected_datasets__': collected_datasets})
         # Certain tools require tasks to be completed after job execution

File lib/galaxy/tools/__init__.py

                     self.sa_session.flush()
         return children
 
-    def collect_primary_datasets( self, output, job_working_directory ):
+    def collect_primary_datasets( self, output, job_working_directory, input_ext ):
         """
         Find any additional datasets generated by a tool and attach (for
         cases where number of outputs is not known in advance).
         """
-        return output_collect.collect_primary_datasets( self, output, job_working_directory )
+        return output_collect.collect_primary_datasets( self, output, job_working_directory, input_ext )
 
     def to_dict( self, trans, link_details=False, io_details=False ):
         """ Returns dict of tool. """

File lib/galaxy/tools/parameters/output_collect.py

 DEFAULT_EXTRA_FILENAME_PATTERN = r"primary_DATASET_ID_(?P<designation>[^_]+)_(?P<visible>[^_]+)_(?P<ext>[^_]+)(_(?P<dbkey>[^_]+))?"
 
 
-def collect_primary_datasets( tool, output, job_working_directory ):
+def collect_primary_datasets( tool, output, job_working_directory, input_ext ):
     app = tool.app
     sa_session = tool.sa_session
     new_primary_datasets = {}
             designation = fields_match.designation
             visible = fields_match.visible
             ext = fields_match.ext
+            if ext == "input":
+                ext = input_ext
             dbkey = fields_match.dbkey
             # Create new primary dataset
             primary_data = app.model.HistoryDatasetAssociation( extension=ext,

File test/functional/tools/multi_output_configured.xml

     echo "1" > subdir2/CUSTOM_1.txt;
     echo "2" > subdir2/CUSTOM_2.tabular;
     echo "3" > subdir2/CUSTOM_3.txt;
+    mkdir subdir3;
+    echo "Foo" > subdir3/Foo;
   </command>
   <inputs>
-    <param name="input" type="integer" value="7" />
+    <param name="num_param" type="integer" value="7" />
+    <param name="input" type="data" />
   </inputs>
   <outputs>
     <data format="txt" name="report">
       <discover_datasets pattern="__designation_and_ext__" directory="subdir1" />
       <discover_datasets pattern="CUSTOM_(?P&lt;designation&gt;.+)\.(?P&lt;ext&gt;.+)" directory="subdir2" />
+      <discover_datasets pattern="__designation__" directory="subdir3" ext="input" />
     </data>
   </outputs>
   <tests>
     <test>
-      <param name="input" value="7" />
+      <param name="num_param" value="7" />
+      <param name="input" ftype="txt" value="simple_line.txt"/>
       <output name="report">
         <assert_contents>
           <has_line line="Hello" />
         <discovered_dataset designation="2" ftype="tabular">
           <assert_contents><has_line line="2" /></assert_contents>
         </discovered_dataset>
+        <discovered_dataset designation="Foo" ftype="txt">
+          <assert_contents><has_line line="Foo" /></assert_contents>
+        </discovered_dataset>
       </output>
     </test>
   </tests>