Skip to content

Commit 091a474

Browse files
committed
output result to a custom dir
1 parent 6939f66 commit 091a474

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

eval_protocol/pytest/handle_persist_flow.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
def handle_persist_flow(all_results: list[list[EvaluationRow]], test_func_name: str):
1717
try:
1818
# Default is to save and upload experiment JSONL files, unless explicitly disabled
19-
should_save = os.getenv("EP_NO_PERSIST_RESULTS_JSONL") != "1"
19+
custom_output_dir = os.getenv("EP_OUTPUT_DIR")
20+
should_save = os.getenv("EP_NO_UPLOAD") != "1" or custom_output_dir is not None
2021

2122
if should_save:
2223
current_run_rows = [item for sublist in all_results for item in sublist]
@@ -27,6 +28,8 @@ def handle_persist_flow(all_results: list[list[EvaluationRow]], test_func_name:
2728
experiments[row.execution_metadata.experiment_id].append(row)
2829

2930
eval_protocol_dir = find_eval_protocol_dir()
31+
if custom_output_dir:
32+
eval_protocol_dir = custom_output_dir
3033
exp_dir = pathlib.Path(eval_protocol_dir) / "experiment_results"
3134
exp_dir.mkdir(parents=True, exist_ok=True)
3235

eval_protocol/pytest/plugin.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,9 @@ def pytest_addoption(parser) -> None:
134134
help=("If set, use this base URL for remote rollout processing. Example: http://localhost:8000"),
135135
)
136136
group.addoption(
137-
"--ep-no-persist-results-jsonl",
138-
action="store_true",
139-
default=False,
140-
help=("Disable persisting results as jsonl files. Default: false (results are persisted by default)."),
137+
"--ep-output-dir",
138+
default=None,
139+
help=("If set, save evaluation results to this directory in jsonl format."),
141140
)
142141

143142

@@ -264,9 +263,9 @@ def pytest_configure(config) -> None:
264263
if threshold_env is not None:
265264
os.environ["EP_PASSED_THRESHOLD"] = threshold_env
266265

267-
if config.getoption("--ep-no-save-results-in-jsonl"):
268-
# flag to turn off persisting results as jsonl files
269-
os.environ["EP_NO_PERSIST_RESULTS_JSONL"] = "1"
266+
if config.getoption("--ep-output-dir"):
267+
# set this to save eval results to the target dir in jsonl format
268+
os.environ["EP_OUTPUT_DIR"] = config.getoption("--ep-output-dir")
270269

271270
if config.getoption("--ep-no-upload"):
272271
os.environ["EP_NO_UPLOAD"] = "1"

0 commit comments

Comments
 (0)