From 8fc6c5d8b39b5c843431ac2f59aa82059d898f9a Mon Sep 17 00:00:00 2001 From: Silke Schomann Date: Fri, 10 Jan 2025 08:37:07 +0000 Subject: [PATCH] Improve deletion of workspaces in ADS --- .../models/workspacemanager/workspace_provider.py | 5 ++++- src/mslice/util/mantid/algorithm_wrapper.py | 13 ++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/mslice/models/workspacemanager/workspace_provider.py b/src/mslice/models/workspacemanager/workspace_provider.py index 9a55f2a7..f584c493 100644 --- a/src/mslice/models/workspacemanager/workspace_provider.py +++ b/src/mslice/models/workspacemanager/workspace_provider.py @@ -46,7 +46,10 @@ def get_workspace_name(workspace): def delete_workspace(workspace): - workspace = get_workspace_handle(workspace) + try: + workspace = get_workspace_handle(workspace) + except KeyError: + return None remove_workspace(workspace) del workspace diff --git a/src/mslice/util/mantid/algorithm_wrapper.py b/src/mslice/util/mantid/algorithm_wrapper.py index 690ee2d5..cedc172a 100644 --- a/src/mslice/util/mantid/algorithm_wrapper.py +++ b/src/mslice/util/mantid/algorithm_wrapper.py @@ -98,6 +98,13 @@ def remove_from_ads(workspacename): if AnalysisDataService.Instance().doesExist(workspacename): AnalysisDataService.Instance().remove(workspacename) # Remove hidden workspaces from ADS - workspacename = '__MSL' + workspacename - if AnalysisDataService.Instance().doesExist(workspacename): - AnalysisDataService.Instance().remove(workspacename) + hiddenworkspace = '__MSL' + workspacename + if AnalysisDataService.Instance().doesExist(hiddenworkspace): + AnalysisDataService.Instance().remove(hiddenworkspace) + hiddenworkspace = '__MSL__mat' + workspacename + if AnalysisDataService.Instance().doesExist(hiddenworkspace): + AnalysisDataService.Instance().remove(hiddenworkspace) + hiddenworkspace = '__MSL' + workspacename + '_HIDDEN' + print(AnalysisDataService.Instance().getObjectNames()) + if AnalysisDataService.Instance().doesExist(hiddenworkspace): + AnalysisDataService.Instance().remove(hiddenworkspace)