From 177575bb3d92e518b0524eefcdff6967e1e80628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Denis=20Rivi=C3=A8re?= Date: Mon, 27 Nov 2023 08:34:58 +0100 Subject: [PATCH] activate context modules only in run.py when the context is built from the database, really for execution (#338) --- capsul/engine/__init__.py | 6 ++++-- capsul/execution_context.py | 2 +- capsul/run.py | 2 ++ 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/capsul/engine/__init__.py b/capsul/engine/__init__.py index 3afa93cc..d8d21c90 100644 --- a/capsul/engine/__init__.py +++ b/capsul/engine/__init__.py @@ -84,8 +84,10 @@ def execution_context(engine_label, engine_config, executable): ) setattr(execution_context, module_name, valid_config) - # FIXME: should be done only in real execution (server) situation - execution_context.activate_modules_config() + # context activation should be done only in real execution (server) + # situation. This is done in database.execution_context(), not here + # because here we are on client-side API. + # execution_context.activate_modules_config() return execution_context diff --git a/capsul/execution_context.py b/capsul/execution_context.py index bb68fe47..cec18ca7 100644 --- a/capsul/execution_context.py +++ b/capsul/execution_context.py @@ -25,7 +25,7 @@ class ExecutionContext(Controller): config_modules: list[str] = field(type=list[str], default_factory=list) dataset: OpenKeyDictController[Dataset] - def __init__(self, config=None, executable=None, activate_modules=True): + def __init__(self, config=None, executable=None, activate_modules=False): super().__init__() if config: python_modules = config.get("python_modules", []) diff --git a/capsul/run.py b/capsul/run.py index 372e7e27..8bf00c5c 100644 --- a/capsul/run.py +++ b/capsul/run.py @@ -54,10 +54,12 @@ def run_job( def execute_job(database, engine_id, execution_id, job_uuid, debug=False): + # TODO: the context should be specific to the job, not only the execution execution_context = database.execution_context(engine_id, execution_id) execution_context.dataset.tmp = { "path": database.tmp(engine_id, execution_id), } + execution_context.activate_modules_config() job = database.job(engine_id, execution_id, job_uuid) if job is None: raise ValueError(f"No such job: {job_uuid}")