From 3ea14c05b84fc2c91b9e6f71d0e61908e77f1ae5 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 18 Jan 2021 17:32:23 +0100 Subject: [PATCH 1/2] Fix history import job done before import complete By moving history import from job wrapper cleanup to exec_after_process. That seems like a better location overall, and in particular runs the actual import before we set the final job state. --- lib/galaxy/jobs/__init__.py | 7 +++++-- lib/galaxy/tools/__init__.py | 7 +++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/galaxy/jobs/__init__.py b/lib/galaxy/jobs/__init__.py index fb46d84a86f..3ab20ea94e6 100644 --- a/lib/galaxy/jobs/__init__.py +++ b/lib/galaxy/jobs/__init__.py @@ -1731,7 +1731,11 @@ class JobWrapper(HasResourceParameters): # Certain tools require tasks to be completed after job execution # ( this used to be performed in the "exec_after_process" hook, but hooks are deprecated ). param_dict = self.get_param_dict(job) - self.tool.exec_after_process(self.app, inp_data, out_data, param_dict, job=job, final_job_state=final_job_state) + try: + self.tool.exec_after_process(self.app, inp_data, out_data, param_dict, job=job, final_job_state=final_job_state) + except Exception: + log.exception(f"exec_after_process hook failed for job {self.job_id}") + final_job_state = job.states.ERROR # Call 'exec_after_process' hook self.tool.call_hook('exec_after_process', self.app, inp_data=inp_data, out_data=out_data, param_dict=param_dict, @@ -1834,7 +1838,6 @@ class JobWrapper(HasResourceParameters): if e.errno != errno.ENOENT: raise self.external_output_metadata.cleanup_external_metadata(self.sa_session) - galaxy.tools.imp_exp.JobImportHistoryArchiveWrapper(self.app, self.job_id).cleanup_after_job() if delete_files: self.object_store.delete(self.get_job(), base_dir='job_work', entire_dir=True, dir_only=True, obj_dir=True) except Exception: diff --git a/lib/galaxy/tools/__init__.py b/lib/galaxy/tools/__init__.py index 928315fe700..dfaefdd8f90 100644 --- a/lib/galaxy/tools/__init__.py +++ b/lib/galaxy/tools/__init__.py @@ -55,6 +55,7 @@ from galaxy.tools.actions.data_manager import DataManagerToolAction from galaxy.tools.actions.data_source import DataSourceToolAction from galaxy.tools.actions.model_operations import ModelOperationToolAction from galaxy.tools.cache import ToolDocumentCache +from galaxy.tools.imp_exp import JobImportHistoryArchiveWrapper from galaxy.tools.parameters import ( check_param, params_from_strings, @@ -2649,6 +2650,12 @@ class ExportHistoryTool(Tool): class ImportHistoryTool(Tool): tool_type = 'import_history' + def exec_after_process(self, app, inp_data, out_data, param_dict, job, final_job_state=None, **kwds): + super().exec_after_process(app, inp_data, out_data, param_dict, job=job, **kwds) + if final_job_state != DETECTED_JOB_STATE.OK: + return + JobImportHistoryArchiveWrapper(self.app, job.id).cleanup_after_job() + class InteractiveTool(Tool): tool_type = 'interactive' From 2a1aea4523ce6acec6281ea4c3a7d203ad8cb190 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Mon, 18 Jan 2021 17:40:16 +0100 Subject: [PATCH 2/2] Drop workaround that shouldn't be needed with the previous commit. --- client/src/components/HistoryExport/ToLink.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/client/src/components/HistoryExport/ToLink.vue b/client/src/components/HistoryExport/ToLink.vue index b45587bac26..a6b6d2c807c 100644 --- a/client/src/components/HistoryExport/ToLink.vue +++ b/client/src/components/HistoryExport/ToLink.vue @@ -153,10 +153,7 @@ export default { waitOnJob(jobId) .then((jobResponse) => { this.waitingOnJob = false; - this.loadingExports = true; - // Race condition, for some reasons the job API returns - // ok before the JEHA... - setTimeout(this.loadExports, 2000); + this.loadExports(); }) .catch(this.handleError); },