galaxy-dist commit 8f2e21b07986: Enable export history jobs to work when application option 'outputs_to_working_directory' is set to true. This will enable export history jobs to work on galaxy main and, more generally, when galaxy datasets are mounted read-only.
# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User jeremy goecks <jeremy.goecks@emory.edu> # Date 1286208862 14400 # Node ID 8f2e21b079864cb02b2c4e5bfc3343cbf867e259 # Parent 06d6ce09e0f152d38c632dae7ccba9337f25bab5 Enable export history jobs to work when application option 'outputs_to_working_directory' is set to true. This will enable export history jobs to work on galaxy main and, more generally, when galaxy datasets are mounted read-only. --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -321,6 +321,20 @@ class JobWrapper( object ): inp_data = dict( [ ( da.name, da.dataset ) for da in job.input_datasets ] ) out_data = dict( [ ( da.name, da.dataset ) for da in job.output_datasets ] ) out_data.update( [ ( da.name, da.dataset ) for da in job.output_library_datasets ] ) + + # Set up output dataset association for export history jobs. Because job + # uses a Dataset rather than an HDA or LDA, it's necessary to set up a + # fake dataset association that provides the needed attributes for + # preparing a job. + class FakeDatasetAssociation ( object ): + def __init__( self, dataset=None ): + self.dataset = dataset + self.file_name = dataset.file_name + self.metadata = dict() + self.children = [] + jeha = self.sa_session.query( model.JobExportHistoryArchive ).filter_by( job=job ).first() + if jeha: + out_data[ "output_file" ] = FakeDatasetAssociation( dataset=jeha.dataset ) # These can be passed on the command line if wanted as $userId $userEmail if job.history and job.history.user: # check for anonymous user! userId = '%d' % job.history.user.id @@ -632,13 +646,21 @@ class JobWrapper( object ): return self.false_path job = self.sa_session.query( model.Job ).get( self.job_id ) + # Job output datasets are combination of output datasets, library datasets, and jeha datasets. + jeha = self.sa_session.query( model.JobExportHistoryArchive ).filter_by( job=job ).first() if self.app.config.outputs_to_working_directory: self.output_paths = [] for name, data in [ ( da.name, da.dataset.dataset ) for da in job.output_datasets + job.output_library_datasets ]: false_path = os.path.abspath( os.path.join( self.working_directory, "galaxy_dataset_%d.dat" % data.id ) ) self.output_paths.append( DatasetPath( data.id, data.file_name, false_path ) ) + if jeha: + false_path = os.path.abspath( os.path.join( self.working_directory, "galaxy_dataset_%d.dat" % jeha.dataset.id ) ) + self.output_paths.append( DatasetPath( jeha.dataset.id, jeha.dataset.file_name, false_path ) ) else: self.output_paths = [ DatasetPath( da.dataset.dataset.id, da.dataset.file_name ) for da in job.output_datasets + job.output_library_datasets ] + if jeha: + self.output_paths.append( DatasetPath( jeha.dataset.id, jeha.dataset.file_name ) ) + return self.output_paths def get_output_file_id( self, file ): --- a/lib/galaxy/tools/imp_exp/__init__.py +++ b/lib/galaxy/tools/imp_exp/__init__.py @@ -15,12 +15,15 @@ def load_history_imp_exp_tools( toolbox <tool id="__EXPORT_HISTORY__" name="Export History" version="0.1" tool_type="export_history"><type class="ExportHistoryTool" module="galaxy.tools"/><action module="galaxy.tools.actions.history_imp_exp" class="ExportHistoryToolAction"/> - <command>$__SET_EXPORT_HISTORY_COMMAND_LINE__</command> + <command>$__EXPORT_HISTORY_COMMAND_INPUTS_OPTIONS__ $output_file</command><inputs><param name="__HISTORY_TO_EXPORT__" type="hidden"/><param name="compress" type="boolean"/> - <param name="__SET_EXPORT_HISTORY_COMMAND_LINE__" type="hidden"/> + <param name="__EXPORT_HISTORY_COMMAND_INPUTS_OPTIONS__" type="hidden"/></inputs> + <outputs> + <data format="gzip" name="output_file"/> + </outputs></tool> """ tmp_name = tempfile.NamedTemporaryFile() @@ -40,7 +43,9 @@ class JobExportHistoryArchiveWrapper( ob # jeha = job_export_history_archive for the job. """ Perform setup for job to export a history into an archive. Method generates attribute files for export, sets the corresponding attributes in the jeha - object, and returns a command line for running the job. """ + object, and returns a command line for running the job. The command line + includes the command, inputs, and options; it does not include the output + file because it must be set at runtime. """ # # Helper methods/classes. @@ -199,10 +204,9 @@ class JobExportHistoryArchiveWrapper( ob options = "" if jeha.compressed: options = "-G" - return "python %s %s %s %s %s %s" % ( + return "python %s %s %s %s %s" % ( os.path.join( os.path.abspath( os.getcwd() ), "lib/galaxy/tools/imp_exp/export_history.py" ), \ - options, history_attrs_filename, datasets_attrs_filename, jobs_attrs_filename, \ - jeha.dataset.file_name ) + options, history_attrs_filename, datasets_attrs_filename, jobs_attrs_filename ) def cleanup_after_job( self, db_session ): """ Remove temporary directory and attribute files generated during setup for this job. """ --- a/lib/galaxy/tools/actions/history_imp_exp.py +++ b/lib/galaxy/tools/actions/history_imp_exp.py @@ -61,7 +61,7 @@ class ExportHistoryToolAction( ToolActio # Set additional parameters. incoming[ '__HISTORY_TO_EXPORT__' ] = history.id - incoming[ '__SET_EXPORT_HISTORY_COMMAND_LINE__' ] = cmd_line + incoming[ '__EXPORT_HISTORY_COMMAND_INPUTS_OPTIONS__' ] = cmd_line for name, value in tool.params_to_strings( incoming, trans.app ).iteritems(): job.add_parameter( name, value )
participants (1)
-
commits-noreply@bitbucket.org