1 new commit in galaxy-central:
https://bitbucket.org/galaxy/galaxy-central/changeset/50bf77aa34c3/ changeset: 50bf77aa34c3 user: dannon date: 2012-02-02 16:51:13 summary: History export - now works for a guest user. affected #: 1 file
diff -r 62c2a2f9142c11d1ae279ce3af395bd4fb0d4c52 -r 50bf77aa34c3689a122187d7ba9b55deb348df92 lib/galaxy/tools/actions/history_imp_exp.py --- a/lib/galaxy/tools/actions/history_imp_exp.py +++ b/lib/galaxy/tools/actions/history_imp_exp.py @@ -9,7 +9,7 @@ class ImportHistoryToolAction( ToolAction ): """Tool action used for importing a history to an archive. """
- def execute( self, tool, trans, incoming = {}, set_output_hid = False, overwrite = True, history=None ): + def execute( self, tool, trans, incoming = {}, set_output_hid = False, overwrite = True, history=None ): # # Create job. # @@ -20,43 +20,43 @@ job.user_id = trans.user.id start_job_state = job.state #should be job.states.NEW job.state = job.states.WAITING #we need to set job state to something other than NEW, or else when tracking jobs in db it will be picked up before we have added input / output parameters - trans.sa_session.add( job ) + trans.sa_session.add( job ) trans.sa_session.flush() #ensure job.id are available - + # # Setup job and job wrapper. # - + # Add association for keeping track of job, history relationship. - - # Use abspath because mkdtemp() does not, contrary to the documentation, + + # Use abspath because mkdtemp() does not, contrary to the documentation, # always return an absolute path. archive_dir = os.path.abspath( tempfile.mkdtemp() ) jiha = trans.app.model.JobImportHistoryArchive( job=job, archive_dir=archive_dir ) trans.sa_session.add( jiha ) job_wrapper = JobImportHistoryArchiveWrapper( job ) - + # # Add parameters to job_parameter table. # - + # Set additional parameters. incoming[ '__DEST_DIR__' ] = jiha.archive_dir for name, value in tool.params_to_strings( incoming, trans.app ).iteritems(): job.add_parameter( name, value ) - + job.state = start_job_state #job inputs have been configured, restore initial job state trans.sa_session.flush()
# Queue the job for execution trans.app.job_queue.put( job.id, tool ) trans.log_event( "Added import history job to the job queue, id: %s" % str(job.id), tool_id=job.tool_id ) - + return job, odict()
class ExportHistoryToolAction( ToolAction ): """Tool action used for exporting a history to an archive. """ - + def execute( self, tool, trans, incoming = {}, set_output_hid = False, overwrite = True, history=None ): # # Get history to export. @@ -68,10 +68,10 @@ history = value del incoming[ history_param_name ] break - + if not history: raise Exception( 'There is no history to export.' ) - + # # Create the job and output dataset objects # @@ -79,22 +79,24 @@ job.session_id = trans.get_galaxy_session().id job.history_id = trans.history.id job.tool_id = tool.id - job.user_id = trans.user.id + if trans.user: + # If this is an actual user, run the job as that individual. Otherwise we're running as guest. + job.user_id = trans.user.id start_job_state = job.state #should be job.states.NEW job.state = job.states.WAITING #we need to set job state to something other than NEW, or else when tracking jobs in db it will be picked up before we have added input / output parameters trans.sa_session.add( job ) - + # Create dataset that will serve as archive. archive_dataset = trans.app.model.Dataset() trans.sa_session.add( archive_dataset ) - + trans.sa_session.flush() #ensure job.id and archive_dataset.id are available trans.app.object_store.create( archive_dataset ) # set the object store id, create dataset (if applicable) - + # # Setup job and job wrapper. # - + # Add association for keeping track of job, history, archive relationship. jeha = trans.app.model.JobExportHistoryArchive( job=job, history=history, \ dataset=archive_dataset, \ @@ -104,23 +106,23 @@ job_wrapper = JobExportHistoryArchiveWrapper( job ) cmd_line = job_wrapper.setup_job( trans, jeha, include_hidden=incoming[ 'include_hidden' ], \ include_deleted=incoming[ 'include_deleted' ] ) - + # # Add parameters to job_parameter table. # - + # Set additional parameters. incoming[ '__HISTORY_TO_EXPORT__' ] = history.id 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 ) - + job.state = start_job_state #job inputs have been configured, restore initial job state trans.sa_session.flush() - - + + # Queue the job for execution trans.app.job_queue.put( job.id, tool ) trans.log_event( "Added export history job to the job queue, id: %s" % str(job.id), tool_id=job.tool_id ) - + return job, odict()
Repository URL: https://bitbucket.org/galaxy/galaxy-central/
--
This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
galaxy-commits@lists.galaxyproject.org