From f4fa6cacd8fa1cdfd4e05a781173d252ad6de69e Mon Sep 17 00:00:00 2001 From: njzjz-bot Date: Mon, 24 Aug 2026 03:18:35 +0800 Subject: [PATCH 1/2] fix: apply CALYPSO run-step options Pass run_config to the sliced CALYPSO model-deviation step so its parallelism and continuation controls are honored. Closes #354 Coding-Agent: Codex Codex-Version: codex-cli 0.149.1 Model: gpt-5.6-sol Reasoning-Effort: xhigh --- dpgen2/superop/prep_run_calypso.py | 2 +- tests/test_prep_run_caly.py | 67 ++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 1 deletion(-) diff --git a/dpgen2/superop/prep_run_calypso.py b/dpgen2/superop/prep_run_calypso.py index daa48143..998adec8 100644 --- a/dpgen2/superop/prep_run_calypso.py +++ b/dpgen2/superop/prep_run_calypso.py @@ -290,7 +290,7 @@ def _prep_run_caly( key="%s--run-caly-model-devi-{{item}}" % (prep_run_caly_steps.inputs.parameters["block_id"],), executor=run_executor, - **prep_config, + **run_config, ) prep_run_caly_steps.add(run_caly_model_devi) diff --git a/tests/test_prep_run_caly.py b/tests/test_prep_run_caly.py index e949410d..4ed6581f 100644 --- a/tests/test_prep_run_caly.py +++ b/tests/test_prep_run_caly.py @@ -4,9 +4,15 @@ import shutil import time import unittest +from collections import ( + defaultdict, +) from pathlib import ( Path, ) +from types import ( + SimpleNamespace, +) from typing import ( List, Set, @@ -36,6 +42,10 @@ OPIOSign, PythonOPTemplate, ) +from mock import ( + Mock, + patch, +) from dpgen2.constants import ( calypso_check_opt_file, @@ -89,6 +99,7 @@ ) from dpgen2.superop.prep_run_calypso import ( PrepRunCaly, + _prep_run_caly, ) from dpgen2.utils.step_config import normalize as normalize_step_dict @@ -101,6 +112,62 @@ ) +class TestPrepRunCalyConfiguration(unittest.TestCase): + def test_model_deviation_step_uses_run_config(self): + """Apply run-step controls to the sliced model-deviation step.""" + step_calls = [] + + def make_mapping(): + return defaultdict(Mock) + + def make_step(name, *args, **kwargs): + step_calls.append((name, kwargs)) + return SimpleNamespace( + outputs=SimpleNamespace( + parameters=make_mapping(), + artifacts=make_mapping(), + ) + ) + + prep_run_steps = SimpleNamespace( + inputs=SimpleNamespace( + parameters=make_mapping(), + artifacts=make_mapping(), + ), + outputs=SimpleNamespace(artifacts=make_mapping()), + add=Mock(), + ) + prep_config = normalize_step_dict({"continue_on_success_ratio": 0.1}) + run_config = normalize_step_dict({"continue_on_success_ratio": 0.9}) + + with ( + patch( + "dpgen2.superop.prep_run_calypso.Step", + side_effect=make_step, + ), + patch("dpgen2.superop.prep_run_calypso.PythonOPTemplate"), + patch("dpgen2.superop.prep_run_calypso.Slices"), + patch("dpgen2.superop.prep_run_calypso.argo_range"), + patch( + "dpgen2.superop.prep_run_calypso.init_executor", + side_effect=lambda value: value, + ), + ): + _prep_run_caly( + prep_run_steps, + defaultdict(str), + Mock(), + Mock(), + Mock(), + Mock(), + prep_config=prep_config, + run_config=run_config, + ) + + run_step_kwargs = dict(step_calls)["run-caly-model-devi"] + self.assertEqual(run_step_kwargs["continue_on_success_ratio"], 0.9) + + def make_task_group_list(njobs): tgrp = BaseExplorationTaskGroup() for ii in range(njobs): From 02198b9c874f4825532d99c1586ec8e1bb52db7b Mon Sep 17 00:00:00 2001 From: "A bot of @njzjz" Date: Sat, 29 Aug 2026 19:00:10 +0800 Subject: [PATCH 2/2] test: cover CALYPSO step configuration routing Distinguish every step-level prep and run option and verify routing in both default and merge exploration modes. Coding-Agent: Codex Codex-Version: codex-cli 0.150.1 Model: gpt-5.6-sol Reasoning-Effort: xhigh --- tests/test_prep_run_caly.py | 127 +++++++++++++++++++++++------------- 1 file changed, 82 insertions(+), 45 deletions(-) diff --git a/tests/test_prep_run_caly.py b/tests/test_prep_run_caly.py index 4ed6581f..f303e0f5 100644 --- a/tests/test_prep_run_caly.py +++ b/tests/test_prep_run_caly.py @@ -114,58 +114,95 @@ class TestPrepRunCalyConfiguration(unittest.TestCase): def test_model_deviation_step_uses_run_config(self): - """Apply run-step controls to the sliced model-deviation step.""" - step_calls = [] + """Route every step-level control from the intended phase config.""" + step_config_keys = ( + "continue_on_failed", + "continue_on_num_success", + "continue_on_success_ratio", + "parallelism", + ) def make_mapping(): return defaultdict(Mock) - def make_step(name, *args, **kwargs): - step_calls.append((name, kwargs)) - return SimpleNamespace( - outputs=SimpleNamespace( - parameters=make_mapping(), - artifacts=make_mapping(), - ) - ) - - prep_run_steps = SimpleNamespace( - inputs=SimpleNamespace( - parameters=make_mapping(), - artifacts=make_mapping(), - ), - outputs=SimpleNamespace(artifacts=make_mapping()), - add=Mock(), + prep_config = normalize_step_dict( + { + "continue_on_failed": False, + "continue_on_num_success": 1, + "continue_on_success_ratio": 0.1, + "parallelism": 3, + } + ) + run_config = normalize_step_dict( + { + "continue_on_failed": True, + "continue_on_num_success": 9, + "continue_on_success_ratio": 0.9, + "parallelism": 7, + } ) - prep_config = normalize_step_dict({"continue_on_success_ratio": 0.1}) - run_config = normalize_step_dict({"continue_on_success_ratio": 0.9}) - with ( - patch( - "dpgen2.superop.prep_run_calypso.Step", - side_effect=make_step, - ), - patch("dpgen2.superop.prep_run_calypso.PythonOPTemplate"), - patch("dpgen2.superop.prep_run_calypso.Slices"), - patch("dpgen2.superop.prep_run_calypso.argo_range"), - patch( - "dpgen2.superop.prep_run_calypso.init_executor", - side_effect=lambda value: value, - ), - ): - _prep_run_caly( - prep_run_steps, - defaultdict(str), - Mock(), - Mock(), - Mock(), - Mock(), - prep_config=prep_config, - run_config=run_config, - ) + for expl_mode in ("default", "merge"): + with self.subTest(expl_mode=expl_mode): + step_calls = [] + + def make_step(name, *args, **kwargs): + step_calls.append((name, kwargs)) + return SimpleNamespace( + outputs=SimpleNamespace( + parameters=make_mapping(), + artifacts=make_mapping(), + ) + ) + + prep_run_steps = SimpleNamespace( + inputs=SimpleNamespace( + parameters=make_mapping(), + artifacts=make_mapping(), + ), + outputs=SimpleNamespace(artifacts=make_mapping()), + add=Mock(), + ) + + with ( + patch( + "dpgen2.superop.prep_run_calypso.Step", + side_effect=make_step, + ), + patch("dpgen2.superop.prep_run_calypso.PythonOPTemplate"), + patch("dpgen2.superop.prep_run_calypso.Slices"), + patch("dpgen2.superop.prep_run_calypso.argo_range"), + patch( + "dpgen2.superop.prep_run_calypso.init_executor", + side_effect=lambda value: value, + ), + ): + _prep_run_caly( + prep_run_steps, + defaultdict(str), + Mock(), + Mock(), + Mock(), + Mock(), + expl_mode=expl_mode, + prep_config=prep_config, + run_config=run_config, + ) - run_step_kwargs = dict(step_calls)["run-caly-model-devi"] - self.assertEqual(run_step_kwargs["continue_on_success_ratio"], 0.9) + calls_by_name = dict(step_calls) + expected_configs = { + "prep-caly-input": prep_config, + "caly-evo-step": ( + prep_config if expl_mode == "default" else run_config + ), + "run-caly-model-devi": run_config, + } + for step_name, expected_config in expected_configs.items(): + actual_kwargs = calls_by_name[step_name] + self.assertEqual( + {key: actual_kwargs[key] for key in step_config_keys}, + {key: expected_config[key] for key in step_config_keys}, + ) def make_task_group_list(njobs):