mirror of
https://github.com/NousResearch/atropos.git
synced 2026-04-19 12:57:58 +00:00
feat: dump evaluate subcommand config to YAML in env save dir
Automatically save the final merged evaluate configuration to evaluate_config.yaml in the data_dir_to_save_evals directory. This includes env config, OpenAI/server configs, and server manager settings, enabling reproducibility and easier debugging of evaluation runs. The config is saved after all merging (CLI args > YAML > defaults) to capture the exact configuration used for the evaluation.
This commit is contained in:
parent
b4080a4f37
commit
39d5fb4452
1 changed files with 42 additions and 0 deletions
|
|
@ -1974,6 +1974,48 @@ class BaseEnv(ABC):
|
|||
rprint(env_config)
|
||||
rprint(final_openai_configs)
|
||||
|
||||
# --- Dump config to YAML in env save dir ---
|
||||
if env_config.data_dir_to_save_evals is not None:
|
||||
os.makedirs(env_config.data_dir_to_save_evals, exist_ok=True)
|
||||
|
||||
# Build config dictionary in the same format as YAML config files
|
||||
# Use mode='json' to properly serialize enums and other complex types
|
||||
config_dict = {
|
||||
ENV_NAMESPACE: env_config.model_dump(mode="json"),
|
||||
}
|
||||
|
||||
# Handle OpenAI configs - can be a list or single dict
|
||||
if isinstance(final_openai_configs, list):
|
||||
config_dict[OPENAI_NAMESPACE] = [
|
||||
(
|
||||
cfg.model_dump(mode="json")
|
||||
if hasattr(cfg, "model_dump")
|
||||
else cfg
|
||||
)
|
||||
for cfg in final_openai_configs
|
||||
]
|
||||
elif isinstance(final_openai_configs, APIServerConfig):
|
||||
config_dict[OPENAI_NAMESPACE] = final_openai_configs.model_dump(
|
||||
mode="json"
|
||||
)
|
||||
else:
|
||||
# ServerBaseline or other - convert to dict representation
|
||||
config_dict[OPENAI_NAMESPACE] = {}
|
||||
|
||||
# Add server manager config
|
||||
config_dict["slurm"] = server_manager_config.slurm
|
||||
config_dict["testing"] = server_manager_config.testing
|
||||
|
||||
# Write to YAML file
|
||||
config_filepath = os.path.join(
|
||||
env_config.data_dir_to_save_evals, "evaluate_config.yaml"
|
||||
)
|
||||
with open(config_filepath, "w") as f:
|
||||
yaml.dump(
|
||||
config_dict, f, default_flow_style=False, sort_keys=False
|
||||
)
|
||||
print(f"Dumped evaluate config to {config_filepath}")
|
||||
|
||||
# --- Create and Run Environment ---
|
||||
# Create the environment instance
|
||||
env = cls(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue