From 5cace5896d8c9ca6300d161d1cabb01b308215cc Mon Sep 17 00:00:00 2001 From: Stephen Shao Date: Fri, 12 Sep 2025 20:40:01 -0400 Subject: [PATCH] Multiple models running on the same container now share the same environment file. Eliminates duplicate system environment data collection. Environment data is now correctly associated with containers rather than individual models. --- src/madengine/tools/run_models.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/madengine/tools/run_models.py b/src/madengine/tools/run_models.py index 90741744..e3fcffe9 100644 --- a/src/madengine/tools/run_models.py +++ b/src/madengine/tools/run_models.py @@ -315,13 +315,13 @@ def apply_tools( def gather_system_env_details( self, pre_encapsulate_post_scripts: typing.Dict, - model_name: str + container_identifier: str ) -> None: """Gather system environment details. Args: pre_encapsulate_post_scripts: The pre, encapsulate and post scripts. - model_name: The model name. + container_identifier: The container name or image identifier (replaces model_name for container-specific env files). Returns: None @@ -331,11 +331,13 @@ def gather_system_env_details( Note: This function is used to gather system environment details. + Uses container_identifier instead of model_name to ensure multiple models + running on the same container share the same environment file. """ # initialize pre_env_details pre_env_details = {} pre_env_details["path"] = "scripts/common/pre_scripts/run_rocenv_tool.sh" - pre_env_details["args"] = model_name.replace("/", "_") + "_env" + pre_env_details["args"] = container_identifier + "_env" pre_encapsulate_post_scripts["pre_scripts"].append(pre_env_details) print(f"pre encap post scripts: {pre_encapsulate_post_scripts}") @@ -780,7 +782,7 @@ def run_model_impl( # add system environment collection script to pre_scripts if self.args.generate_sys_env_details or self.context.ctx.get("gen_sys_env_details"): - self.gather_system_env_details(pre_encapsulate_post_scripts, info['name']) + self.gather_system_env_details(pre_encapsulate_post_scripts, container_name) # run pre_scripts if pre_encapsulate_post_scripts["pre_scripts"]: self.run_pre_post_script(model_docker, model_dir, pre_encapsulate_post_scripts["pre_scripts"])