From 7746703125c3108c246901a1ee4e7ab185d1578a Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 2 Aug 2024 16:22:27 +0200 Subject: [PATCH] Fix resume_paused_jobs if no session provided No session means no history. Fixes https://github.com/galaxyproject/galaxy/issues/18639: ``` AttributeError: 'NoneType' object has no attribute 'resume_paused_jobs' (1 additional frame(s) were not displayed) ... File "galaxy/web/framework/middleware/error.py", line 167, in __call__ app_iter = self.application(environ, sr_checker) File "galaxy/web/framework/middleware/statsd.py", line 29, in __call__ req = self.application(environ, start_response) File "galaxy/web/framework/base.py", line 174, in __call__ return self.handle_request(request_id, path_info, environ, start_response) File "galaxy/web/framework/base.py", line 268, in handle_request body = method(trans, **kwargs) File "galaxy/webapps/galaxy/controllers/history.py", line 249, in resume_paused_jobs history.resume_paused_jobs() Uncaught Exception ``` --- .../webapps/galaxy/controllers/history.py | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/lib/galaxy/webapps/galaxy/controllers/history.py b/lib/galaxy/webapps/galaxy/controllers/history.py index 2acdce39a1e5..2fa7e4130e81 100644 --- a/lib/galaxy/webapps/galaxy/controllers/history.py +++ b/lib/galaxy/webapps/galaxy/controllers/history.py @@ -237,21 +237,17 @@ def purge_deleted_datasets(self, trans): ) return trans.show_error_message("Cannot purge deleted datasets from this session.") - @web.expose + @web.expose_api_anonymous def resume_paused_jobs(self, trans, current=False, ids=None, **kwargs): - """Resume paused jobs the active history -- this does not require a logged in user.""" + """Resume paused jobs for the active history -- this does not require a logged in user.""" if not ids and string_as_bool(current): - histories = [trans.get_history()] - refresh_frames = ["history"] - else: - raise NotImplementedError("You can currently only resume all the datasets of the current history.") - for history in histories: - history.resume_paused_jobs() - trans.sa_session.add(history) - with transaction(trans.sa_session): - trans.sa_session.commit() - return trans.show_ok_message("Your jobs have been resumed.", refresh_frames=refresh_frames) - # TODO: used in index.mako + history = trans.get_history() + if history: + history.resume_paused_jobs() + return trans.show_ok_message("Your jobs have been resumed.") + raise exceptions.RequestParameterInvalidException( + "You can currently only resume all the datasets of the current history." + ) @web.expose_api @web.require_login("rename histories")