diff --git a/lib/galaxy/actions/library.py b/lib/galaxy/actions/library.py index 9f4fc345b20..b32f8f57cd9 100644 --- a/lib/galaxy/actions/library.py +++ b/lib/galaxy/actions/library.py @@ -128,8 +128,7 @@ class LibraryActions: job_params['link_data_only'] = json.dumps(kwd.get('link_data_only', 'copy_files')) job_params['uuid'] = json.dumps(kwd.get('uuid', None)) job, output = upload_common.create_job(trans, tool_params, tool, json_file_path, data_list, folder=library_bunch.folder, job_params=job_params) - trans.sa_session.add(job) - trans.sa_session.flush() + trans.app.job_manager.enqueue(job, tool=tool) return output def _get_server_dir_uploaded_datasets(self, trans, params, full_dir, import_dir_desc, library_bunch, response_code, message): diff --git a/lib/galaxy/datatypes/data.py b/lib/galaxy/datatypes/data.py index c98e0ab34f3..ae2c9c89b7c 100644 --- a/lib/galaxy/datatypes/data.py +++ b/lib/galaxy/datatypes/data.py @@ -650,14 +650,15 @@ class Data(metaclass=DataMeta): # Make the target datatype available to the converter params['__target_datatype__'] = target_type # Run converter, job is dispatched through Queue - converted_dataset = converter.execute(trans, incoming=params, set_output_hid=visible, history=history)[1] + job, converted_datasets, *_ = converter.execute(trans, incoming=params, set_output_hid=visible, history=history) + trans.app.job_manager.enqueue(job, tool=converter) if len(params) > 0: trans.log_event(f"Converter params: {str(params)}", tool_id=converter.id) if not visible: - for value in converted_dataset.values(): + for value in converted_datasets.values(): value.visible = False if return_output: - return converted_dataset + return converted_datasets return f"The file conversion of {converter.name} on data {original_dataset.hid} has been added to the Queue." # We need to clear associated files before we set metadata diff --git a/lib/galaxy/managers/datasets.py b/lib/galaxy/managers/datasets.py index 84f08e1f5af..3cdd04e0f95 100644 --- a/lib/galaxy/managers/datasets.py +++ b/lib/galaxy/managers/datasets.py @@ -374,9 +374,10 @@ class DatasetAssociationManager(base.ModelManager, if spec.get('default'): setattr(data.metadata, name, spec.unwrap(spec.get('default'))) - self.app.datatypes_registry.set_external_metadata_tool.tool_action.execute( + job, *_ = self.app.datatypes_registry.set_external_metadata_tool.tool_action.execute( self.app.datatypes_registry.set_external_metadata_tool, trans, incoming={'input1': data, 'validate': validate}, overwrite=overwrite) + self.app.job_manager.enqueue(job, tool=self.app.datatypes_registry.set_external_metadata_tool) def update_permissions(self, trans, dataset_assoc, **kwd): action = kwd.get('action', 'set_permissions') @@ -691,7 +692,8 @@ class DatasetAssociationDeserializer(base.ModelDeserializer, deletable.PurgableD sa_session = self.app.model.context sa_session.flush() trans = context.get("trans") - self.app.datatypes_registry.set_external_metadata_tool.tool_action.execute(self.app.datatypes_registry.set_external_metadata_tool, trans, incoming={'input1': item}, overwrite=False) # overwrite is False as per existing behavior + job, *_ = self.app.datatypes_registry.set_external_metadata_tool.tool_action.execute(self.app.datatypes_registry.set_external_metadata_tool, trans, incoming={'input1': item}, overwrite=False) # overwrite is False as per existing behavior + trans.app.job_manager.enqueue(job, tool=trans.app.datatypes_registry.set_external_metadata_tool) return item.datatype diff --git a/lib/galaxy/managers/histories.py b/lib/galaxy/managers/histories.py index d69fcfbb454..0efee02f285 100644 --- a/lib/galaxy/managers/histories.py +++ b/lib/galaxy/managers/histories.py @@ -245,7 +245,8 @@ class HistoryManager(sharable.SharableModelManager, deletable.PurgableManagerMix # Run job to do import. history_imp_tool = trans.app.toolbox.get_tool('__IMPORT_HISTORY__') incoming = {'__ARCHIVE_SOURCE__': archive_source, '__ARCHIVE_TYPE__': archive_type} - job, _ = history_imp_tool.execute(trans, incoming=incoming) + job, *_ = history_imp_tool.execute(trans, incoming=incoming) + trans.app.job_manager.enqueue(job, tool=history_imp_tool) return job def serve_ready_history_export(self, trans, jeha): @@ -284,7 +285,8 @@ class HistoryManager(sharable.SharableModelManager, deletable.PurgableManagerMix # Run job to do export. history_exp_tool = trans.app.toolbox.get_tool(export_tool_id) - job, _ = history_exp_tool.execute(trans, incoming=params, history=history, set_output_hid=True) + job, *_ = history_exp_tool.execute(trans, incoming=params, history=history, set_output_hid=True) + trans.app.job_manager.enqueue(job, tool=history_exp_tool) return job def get_sharing_extra_information( diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index e953bc2311e..12ff0f0b65c 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -2694,10 +2694,11 @@ class SetMetadataTool(Tool): def regenerate_imported_metadata_if_needed(self, hda, history, job): if len(hda.metadata_file_types) > 0: - self.tool_action.execute_via_app( + job, *_ = self.tool_action.execute_via_app( self, self.app, job.session_id, history.id, job.user, incoming={'input1': hda}, overwrite=False ) + self.app.job_manager.enqueue(job=job, tool=self) def exec_after_process(self, app, inp_data, out_data, param_dict, job=None, **kwds): working_directory = app.object_store.get_filename( diff --git a/lib/galaxy/tools/actions/__init__.py b/lib/galaxy/tools/actions/__init__.py index 8882daae283..1b10fb20481 100644 --- a/lib/galaxy/tools/actions/__init__.py +++ b/lib/galaxy/tools/actions/__init__.py @@ -603,9 +603,6 @@ class DefaultToolAction: trans.sa_session.flush() log.info(f"Flushed transaction for job {job.log_str()} {job_flush_timer}") - # Dispatch to a job handler. enqueue() is responsible for flushing the job - app.job_manager.enqueue(job, tool=tool) - trans.log_event(f"Added job to the job queue, id: {str(job.id)}", tool_id=job.tool_id) return job, out_data, history def _remap_job_on_rerun(self, trans, galaxy_session, rerun_remap_job_id, current_job, out_data): diff --git a/lib/galaxy/tools/actions/history_imp_exp.py b/lib/galaxy/tools/actions/history_imp_exp.py index d6f31f07756..c0a7afd11fd 100644 --- a/lib/galaxy/tools/actions/history_imp_exp.py +++ b/lib/galaxy/tools/actions/history_imp_exp.py @@ -67,11 +67,6 @@ class ImportHistoryToolAction(ToolAction): job.add_parameter(name, value) job.state = start_job_state # job inputs have been configured, restore initial job state - - # Queue the job for execution - trans.app.job_manager.enqueue(job, tool=tool) - trans.log_event(f"Added import history job to the job queue, id: {str(job.id)}", tool_id=job.tool_id) - return job, {} diff --git a/lib/galaxy/tools/actions/metadata.py b/lib/galaxy/tools/actions/metadata.py index 28cb79de8f1..15fb56ac7be 100644 --- a/lib/galaxy/tools/actions/metadata.py +++ b/lib/galaxy/tools/actions/metadata.py @@ -120,11 +120,6 @@ class SetMetadataToolAction(ToolAction): job.state = start_job_state # job inputs have been configured, restore initial job state sa_session.flush() - # Queue the job for execution - app.job_manager.enqueue(job, tool=tool) - # FIXME: need to add event logging to app and log events there rather than trans. - # trans.log_event( "Added set external metadata job to the job queue, id: %s" % str(job.id), tool_id=job.tool_id ) - # clear e.g. converted files dataset.datatype.before_setting_metadata(dataset) diff --git a/lib/galaxy/tools/actions/upload_common.py b/lib/galaxy/tools/actions/upload_common.py index 834cfec7f79..08401661eb4 100644 --- a/lib/galaxy/tools/actions/upload_common.py +++ b/lib/galaxy/tools/actions/upload_common.py @@ -395,6 +395,7 @@ def create_job(trans, params, tool, json_file_path, outputs, folder=None, histor Create the upload job. """ job = trans.app.model.Job() + trans.sa_session.add(job) job.galaxy_version = trans.app.config.version_major galaxy_session = trans.get_galaxy_session() if type(galaxy_session) == trans.model.GalaxySession: @@ -410,16 +411,10 @@ def create_job(trans, params, tool, json_file_path, outputs, folder=None, histor job.tool_id = tool.id job.tool_version = tool.version job.dynamic_tool = tool.dynamic_tool - job.set_state(job.states.UPLOAD) - trans.sa_session.add(job) - trans.sa_session.flush() - log.info('tool %s created job id %d' % (tool.id, job.id)) - trans.log_event('created job id %d' % job.id, tool_id=tool.id) for name, value in tool.params_to_strings(params, trans.app).items(): job.add_parameter(name, value) job.add_parameter('paramfile', dumps(json_file_path)) - object_store_id = None for i, output_object in enumerate(outputs): output_name = "output%i" % i if hasattr(output_object, "collection"): @@ -432,18 +427,11 @@ def create_job(trans, params, tool, json_file_path, outputs, folder=None, histor else: job.add_output_dataset(output_name, dataset) - trans.sa_session.add(output_object) - - job.object_store_id = object_store_id job.set_state(job.states.NEW) if job_params: for name, value in job_params.items(): job.add_parameter(name, value) - trans.sa_session.add(job) - # Queue the job for execution - trans.app.job_manager.enqueue(job, tool=tool) - trans.log_event(f"Added job to the job queue, id: {str(job.id)}", tool_id=job.tool_id) output = {} for i, v in enumerate(outputs): if not hasattr(output_object, "collection_type"): diff --git a/lib/galaxy/webapps/galaxy/api/library_datasets.py b/lib/galaxy/webapps/galaxy/api/library_datasets.py index 108a28dbbec..9d95c6be710 100644 --- a/lib/galaxy/webapps/galaxy/api/library_datasets.py +++ b/lib/galaxy/webapps/galaxy/api/library_datasets.py @@ -519,8 +519,7 @@ class LibraryDatasetsController(BaseGalaxyAPIController, UsesVisualizationMixin, job_params['link_data_only'] = dumps(kwd.get('link_data_only', 'copy_files')) job_params['uuid'] = dumps(kwd.get('uuid', None)) job, output = upload_common.create_job(trans, tool_params, tool, json_file_path, data_list, folder=folder, job_params=job_params) - trans.sa_session.add(job) - trans.sa_session.flush() + trans.app.job_manager.enqueue(job, tool=tool) job_dict = job.to_dict() job_dict['id'] = trans.security.encode_id(job_dict['id']) return job_dict diff --git a/lib/galaxy/webapps/galaxy/controllers/async.py b/lib/galaxy/webapps/galaxy/controllers/async.py index 92b5bcf951c..3b9d23da0f1 100644 --- a/lib/galaxy/webapps/galaxy/controllers/async.py +++ b/lib/galaxy/webapps/galaxy/controllers/async.py @@ -89,7 +89,8 @@ class ASync(BaseUIController): raise Exception("Error: ToolOutput object not found") original_history = trans.sa_session.query(trans.app.model.History).get(data.history_id) - tool.execute(trans, incoming=params, history=original_history) + job, *_ = tool.execute(trans, incoming=params, history=original_history) + trans.app.job_manager.enqueue(job, tool=tool) else: log.debug(f'async error -> {STATUS}') trans.log_event(f'Async error -> {STATUS}') diff --git a/lib/galaxy/webapps/galaxy/controllers/dataset.py b/lib/galaxy/webapps/galaxy/controllers/dataset.py index fda350d4c34..9d43d140650 100644 --- a/lib/galaxy/webapps/galaxy/controllers/dataset.py +++ b/lib/galaxy/webapps/galaxy/controllers/dataset.py @@ -378,9 +378,10 @@ class DatasetInterface(BaseUIController, UsesAnnotations, UsesItemRatings, UsesE datatype = sniff.guess_ext(path, trans.app.datatypes_registry.sniff_order, is_binary=is_binary) trans.app.datatypes_registry.change_datatype(data, datatype) trans.sa_session.flush() - trans.app.datatypes_registry.set_external_metadata_tool.tool_action.execute( + job, *_ = trans.app.datatypes_registry.set_external_metadata_tool.tool_action.execute( trans.app.datatypes_registry.set_external_metadata_tool, trans, incoming={'input1': data}, overwrite=False) # overwrite is False as per existing behavior + trans.app.job_manager.enqueue(job, tool=trans.app.datatypes_registry.set_external_metadata_tool) message = f'Detection was finished and changed the datatype to {datatype}.' else: return self.message_exception(trans, f'Changing datatype "{data.extension}" is not allowed.') diff --git a/lib/galaxy/workflow/modules.py b/lib/galaxy/workflow/modules.py index 55c694ed28e..cfe291eeea2 100644 --- a/lib/galaxy/workflow/modules.py +++ b/lib/galaxy/workflow/modules.py @@ -953,10 +953,10 @@ class InputParameterModule(WorkflowModule): if restrictions_list is None: restrictions_list = [] restriction_values = self._parameter_option_def_to_tool_form_str(restrictions_list) - restrictions_source = dict(name="restrictions", label="Restriction Values", value=restriction_values, help="Comman-separated list of potential all values") + restrictions_source = dict(name="restrictions", label="Restricted Values", value=restriction_values, help="Comma-separated list of all permitted values") restrictions = TextToolParameter(None, restrictions_source) - suggestions_source = dict(name="suggestions", label="Suggestion Values", value=restriction_values, help="Comman-separated list of some potential values") + suggestions_source = dict(name="suggestions", label="Suggested Values", value=restriction_values, help="Comma-separated list of some potential values") suggestions = TextToolParameter(None, suggestions_source) when_restrict_static_restrictions.inputs["restrictions"] = restrictions