Skip to content

Commit 0e0e872

Browse files
committed
feat: add custom output directory support to vf-eval
Allow users to specify a custom output path via the -s/--save-results flag. When a path is provided, results are saved there instead of the default ./outputs or environment-local outputs directory. Usage: vf-eval gsm8k -s # default location vf-eval gsm8k -s /custom/path # custom location
1 parent f23bbe7 commit 0e0e872

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

verifiers/scripts/eval.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,11 @@ def main():
192192
parser.add_argument(
193193
"--save-results",
194194
"-s",
195+
nargs="?",
196+
const=True,
195197
default=False,
196-
action="store_true",
197-
help="Save results to disk",
198+
metavar="PATH",
199+
help="Save results to disk. Optionally specify custom output path.",
198200
)
199201
# save every n rollouts
200202
parser.add_argument(
@@ -317,8 +319,9 @@ def main():
317319
print_results=True,
318320
verbose=args.verbose,
319321
# saving
322+
output_dir=args.save_results if isinstance(args.save_results, str) else None,
320323
state_columns=args.state_columns,
321-
save_results=args.save_results,
324+
save_results=bool(args.save_results),
322325
save_every=args.save_every,
323326
save_to_hf_hub=args.save_to_hf_hub,
324327
hf_hub_dataset_name=args.hf_hub_dataset_name,

verifiers/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ class EvalConfig(BaseModel):
237237
print_results: bool = False
238238
verbose: bool = False
239239
# saving
240+
output_dir: str | None = None
240241
state_columns: list[str] | None = None
241242
save_results: bool = False
242243
save_every: int = -1

verifiers/utils/path_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,17 @@ def get_results_path(
1515

1616

1717
def get_eval_results_path(config: EvalConfig) -> Path:
18+
# Use custom output_dir if provided
19+
if config.output_dir is not None:
20+
base_path = Path(config.output_dir)
21+
return get_results_path(config.env_id, config.model, base_path)
22+
23+
# Fall back to default behavior
1824
module_name = config.env_id.replace("-", "_")
1925
local_env_dir = Path(config.env_dir_path) / module_name
2026

2127
if local_env_dir.exists():
2228
base_path = local_env_dir / "outputs"
23-
results_path = get_results_path(config.env_id, config.model, base_path)
2429
else:
2530
base_path = Path("./outputs")
26-
results_path = get_results_path(config.env_id, config.model, base_path)
27-
return results_path
31+
return get_results_path(config.env_id, config.model, base_path)

0 commit comments

Comments
 (0)