From c2bf7bcaa97998051e740bb12fd65fd8dcfc9201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Rivi=C3=A8re?= Date: Thu, 13 Jun 2024 15:27:12 +0200 Subject: [PATCH] change_soma_workflow_directory() also isolates the WF controller WF controller may be isolated globally using a class variable, for when we don't have hands on the way it is constructed. --- python/soma_workflow/client.py | 11 +++++++++-- python/soma_workflow/configuration.py | 5 +++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/python/soma_workflow/client.py b/python/soma_workflow/client.py index 4eb976d4..5acb84d1 100644 --- a/python/soma_workflow/client.py +++ b/python/soma_workflow/client.py @@ -89,6 +89,8 @@ class WorkflowController(object): scheduler_config = None + isolated_light_mode = None + def __init__(self, resource_id=None, login=None, @@ -130,16 +132,21 @@ def __init__(self, transfers, temporary files...). If the isolated_light_mode parameter value is True, then generate a temporary directory for that. Otherwise the parameter should be a directory name which will - be used instead of the default one. + be used instead of the default one. If None, a class-wide variable + WorkflowController.isolated_light_mode is used instread, so you can + set it on the class to allow isolated mode globally. ''' + if isolated_light_mode is None: + isolated_light_mode = WorkflowController.isolated_light_mode if isolated_light_mode is not None: if isolated_light_mode is True: isolated_dir = tempfile.mkdtemp(prefix='soma_workflow_') else: isolated_dir = isolated_light_mode resource_id = 'localhost' - os.environ['SOMA_WORKFLOW_CONFIG'] = osp.join(isolated_dir, 'soma_workflow.cfg') + os.environ['SOMA_WORKFLOW_CONFIG'] = osp.join(isolated_dir, + 'soma_workflow.cfg') db_file = osp.join(isolated_dir, 'soma-workflow.db') trans_dir = osp.join(isolated_dir, 'transfered_files') config = configuration.Configuration( diff --git a/python/soma_workflow/configuration.py b/python/soma_workflow/configuration.py index 3d768206..ba32674d 100644 --- a/python/soma_workflow/configuration.py +++ b/python/soma_workflow/configuration.py @@ -1553,6 +1553,9 @@ def change_soma_workflow_directory(directory, config_name=None): = Configuration.search_config_path Configuration.search_config_path \ = staticmethod(lambda: six.StringIO(swf_conf)) + from .client import WorkflowController + WorkflowController.isolated_light_mode = directory + def restore_soma_workflow_directory(): ''' @@ -1566,3 +1569,5 @@ def restore_soma_workflow_directory(): else: Configuration.search_config_path \ = staticmethod(Configuration._old_search_config_path) + from .client import WorkflowController + WorkflowController.isolated_light_mode = None