From a6fb08c0e2717d59af65ecb9552df58eb45f2090 Mon Sep 17 00:00:00 2001 From: ggankhuy Date: Wed, 12 Aug 2026 10:59:51 -0700 Subject: [PATCH 1/2] added guard code during copy from script dir to model dir, if same file found in dest., force exit. --- src/madengine/execution/container_runner.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/madengine/execution/container_runner.py b/src/madengine/execution/container_runner.py index eab4af7d..c1e8491d 100644 --- a/src/madengine/execution/container_runner.py +++ b/src/madengine/execution/container_runner.py @@ -1546,6 +1546,20 @@ def run_container( print("MODEL REPO COMMIT: ", commit) print("======================================================") + # Refuse to copy over files already present in the + # model directory: the cloned repo tracks some of these + # paths, and overwriting them leaves the clone dirty. + conflicts = model_docker.sh( + f"cd {dir_path} && find . -type f -printf '%P\\n' | " + 'while IFS= read -r entry; do ' + f'if [ -e "{model_dir}/$entry" ]; then echo "$entry"; fi; ' + 'done' + ) + if conflicts: + raise RuntimeError( + f"Scripts in {dir_path} would overwrite existing files in {model_dir}: {conflicts}" + ) + # Copy scripts to model directory model_docker.sh( f"cp -vLR --preserve=all {dir_path}/. {model_dir}/" From 0bf8be852928bfa91df9502fc75721cfb69313f3 Mon Sep 17 00:00:00 2001 From: ggankhuy Date: Wed, 12 Aug 2026 15:19:51 -0700 Subject: [PATCH 2/2] corrected guardcode for copying dir_path to model_dir --- src/madengine/execution/container_runner.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/madengine/execution/container_runner.py b/src/madengine/execution/container_runner.py index c1e8491d..9e056bc1 100644 --- a/src/madengine/execution/container_runner.py +++ b/src/madengine/execution/container_runner.py @@ -1546,19 +1546,12 @@ def run_container( print("MODEL REPO COMMIT: ", commit) print("======================================================") - # Refuse to copy over files already present in the - # model directory: the cloned repo tracks some of these - # paths, and overwriting them leaves the clone dirty. - conflicts = model_docker.sh( - f"cd {dir_path} && find . -type f -printf '%P\\n' | " - 'while IFS= read -r entry; do ' - f'if [ -e "{model_dir}/$entry" ]; then echo "$entry"; fi; ' + model_docker.sh( + f'for f in {dir_path}/*; do ' + f'if [ -e "{model_dir}/$(basename $f)" ]; then ' + f'echo "ERROR: $f already exists in {model_dir}"; exit 1; fi; ' 'done' ) - if conflicts: - raise RuntimeError( - f"Scripts in {dir_path} would overwrite existing files in {model_dir}: {conflicts}" - ) # Copy scripts to model directory model_docker.sh(