From 49ee87a3f7663c8adba4420c913c8ce378709af3 Mon Sep 17 00:00:00 2001 From: Billy Okal Date: Tue, 17 Nov 2026 22:49:11 -0600 Subject: [PATCH 1/2] feat: report metrics from the data-generation benchmarks The datagen_perf tests record metric inputs, report every metric of their run with validate_dataset.py and assert which metrics compute. With AUTODATA_BENCHMARK_DIR set, each copies its generation result, attempt log and report into a subdirectory named after the benchmark, also when the test fails. The expected metric sets move to autodata_tests/utils/constants.py. Images built without .git record the commit from the AUTODATA_REVISION build argument, and include scripts/ so the tests run without a bind-mounted checkout. Signed-off-by: Billy Okal --- ...imicgen_g1_data_generation_success_rate.py | 19 +++-- ...micgen_gr1_data_generation_success_rate.py | 19 +++-- ...gen_franka_data_generation_success_rate.py | 19 +++-- .../e2e/test_mimicgen_data_generation.py | 18 +---- autodata_tests/utils/constants.py | 28 ++++++++ .../utils/test_generation_result.py | 9 ++- autodata_tests/utils/utils.py | 70 ++++++++++++++++--- autodata_utils/generation_result.py | 22 +++--- docker/Dockerfile.autodata | 4 ++ docs/pages/advanced/testing_and_ci.rst | 4 +- 10 files changed, 160 insertions(+), 52 deletions(-) diff --git a/autodata_tests/datagen_perf/test_dexmimicgen_g1_data_generation_success_rate.py b/autodata_tests/datagen_perf/test_dexmimicgen_g1_data_generation_success_rate.py index 6ef5caf..3824103 100644 --- a/autodata_tests/datagen_perf/test_dexmimicgen_g1_data_generation_success_rate.py +++ b/autodata_tests/datagen_perf/test_dexmimicgen_g1_data_generation_success_rate.py @@ -4,13 +4,18 @@ """Data-generation success-rate perf test for the G1 loco-manipulation pick-place (DexMimicGen) task.""" import os -import tempfile import pytest -from autodata_tests.utils.constants import TestPaths +from autodata_tests.utils.constants import BENCHMARK_OPTIONAL_METRICS, DEXMIMICGEN_METRICS, TestPaths from autodata_tests.utils.subprocess import run_subprocess -from autodata_tests.utils.utils import assert_valid_dataset, read_generation_result +from autodata_tests.utils.utils import ( + assert_computed_metrics, + assert_valid_dataset, + benchmark_temp_dir, + read_generation_result, + report_metrics, +) # --- Tunables (change these to adjust the perf test) --------------------------------------------- SUCCESS_RATE_THRESHOLD = 0.70 # minimum acceptable data-gen success rate @@ -24,8 +29,9 @@ @pytest.mark.with_subprocess def test_dexmimicgen_g1_data_generation_success_rate(): - """Generate NUM_TRIALS demos on NUM_ENVS envs and assert the success rate exceeds the threshold.""" - with tempfile.TemporaryDirectory() as temp_dir: + """Generate NUM_TRIALS demos on NUM_ENVS envs, report their metrics and assert the success rate exceeds the + threshold.""" + with benchmark_temp_dir("g1_pick_place_dexmimicgen") as temp_dir: output_file = os.path.join(temp_dir, "generated.hdf5") result_file = os.path.join(temp_dir, "generation_result.json") @@ -46,6 +52,7 @@ def test_dexmimicgen_g1_data_generation_success_rate(): output_file, "--result_file", result_file, + "--record_metric_inputs", "--generation_num_trials", str(NUM_TRIALS), "--num_envs", @@ -58,6 +65,7 @@ def test_dexmimicgen_g1_data_generation_success_rate(): run_subprocess(args, timeout_sec=TIMEOUT_SEC) assert_valid_dataset(output_file, min_num_demos=1) num_success, num_attempts = read_generation_result(result_file) + report = report_metrics(output_file, result_file) assert num_attempts > 0, "generation reported zero attempts" success_rate = num_success / num_attempts @@ -66,6 +74,7 @@ def test_dexmimicgen_g1_data_generation_success_rate(): f"data-gen success rate {success_rate:.1%} ({num_success}/{num_attempts}) is below the " f"required threshold of {SUCCESS_RATE_THRESHOLD:.0%}" ) + assert_computed_metrics(report, DEXMIMICGEN_METRICS, optional=BENCHMARK_OPTIONAL_METRICS) if __name__ == "__main__": diff --git a/autodata_tests/datagen_perf/test_dexmimicgen_gr1_data_generation_success_rate.py b/autodata_tests/datagen_perf/test_dexmimicgen_gr1_data_generation_success_rate.py index 306149f..e608e24 100644 --- a/autodata_tests/datagen_perf/test_dexmimicgen_gr1_data_generation_success_rate.py +++ b/autodata_tests/datagen_perf/test_dexmimicgen_gr1_data_generation_success_rate.py @@ -4,13 +4,18 @@ """Data-generation success-rate perf test for the GR1T2 pick-place (DexMimicGen) task.""" import os -import tempfile import pytest -from autodata_tests.utils.constants import TestPaths +from autodata_tests.utils.constants import BENCHMARK_OPTIONAL_METRICS, DEXMIMICGEN_METRICS, TestPaths from autodata_tests.utils.subprocess import run_subprocess -from autodata_tests.utils.utils import assert_valid_dataset, read_generation_result +from autodata_tests.utils.utils import ( + assert_computed_metrics, + assert_valid_dataset, + benchmark_temp_dir, + read_generation_result, + report_metrics, +) # --- Tunables (change these to adjust the perf test) --------------------------------------------- SUCCESS_RATE_THRESHOLD = 0.70 # minimum acceptable data-gen success rate @@ -24,8 +29,9 @@ @pytest.mark.with_subprocess def test_dexmimicgen_gr1_data_generation_success_rate(): - """Generate NUM_TRIALS demos on NUM_ENVS envs and assert the success rate exceeds the threshold.""" - with tempfile.TemporaryDirectory() as temp_dir: + """Generate NUM_TRIALS demos on NUM_ENVS envs, report their metrics and assert the success rate exceeds the + threshold.""" + with benchmark_temp_dir("gr1_pick_place_dexmimicgen") as temp_dir: output_file = os.path.join(temp_dir, "generated.hdf5") result_file = os.path.join(temp_dir, "generation_result.json") @@ -46,6 +52,7 @@ def test_dexmimicgen_gr1_data_generation_success_rate(): output_file, "--result_file", result_file, + "--record_metric_inputs", "--generation_num_trials", str(NUM_TRIALS), "--num_envs", @@ -58,6 +65,7 @@ def test_dexmimicgen_gr1_data_generation_success_rate(): run_subprocess(args, timeout_sec=TIMEOUT_SEC) assert_valid_dataset(output_file, min_num_demos=1) num_success, num_attempts = read_generation_result(result_file) + report = report_metrics(output_file, result_file) assert num_attempts > 0, "generation reported zero attempts" success_rate = num_success / num_attempts @@ -66,6 +74,7 @@ def test_dexmimicgen_gr1_data_generation_success_rate(): f"data-gen success rate {success_rate:.1%} ({num_success}/{num_attempts}) is below the " f"required threshold of {SUCCESS_RATE_THRESHOLD:.0%}" ) + assert_computed_metrics(report, DEXMIMICGEN_METRICS, optional=BENCHMARK_OPTIONAL_METRICS) if __name__ == "__main__": diff --git a/autodata_tests/datagen_perf/test_mimicgen_franka_data_generation_success_rate.py b/autodata_tests/datagen_perf/test_mimicgen_franka_data_generation_success_rate.py index c4e5fdc..84f88e8 100644 --- a/autodata_tests/datagen_perf/test_mimicgen_franka_data_generation_success_rate.py +++ b/autodata_tests/datagen_perf/test_mimicgen_franka_data_generation_success_rate.py @@ -4,13 +4,18 @@ """Data-generation success-rate perf test for the Franka cube-stack (MimicGen) task.""" import os -import tempfile import pytest -from autodata_tests.utils.constants import TestPaths +from autodata_tests.utils.constants import BENCHMARK_OPTIONAL_METRICS, MIMICGEN_FRANKA_METRICS, TestPaths from autodata_tests.utils.subprocess import run_subprocess -from autodata_tests.utils.utils import assert_valid_dataset, read_generation_result +from autodata_tests.utils.utils import ( + assert_computed_metrics, + assert_valid_dataset, + benchmark_temp_dir, + read_generation_result, + report_metrics, +) # --- Tunables (change these to adjust the perf test) --------------------------------------------- SUCCESS_RATE_THRESHOLD = 0.30 # minimum acceptable data-gen success rate @@ -24,8 +29,9 @@ @pytest.mark.with_subprocess def test_mimicgen_franka_data_generation_success_rate(): - """Generate NUM_TRIALS demos on NUM_ENVS envs and assert the success rate exceeds the threshold.""" - with tempfile.TemporaryDirectory() as temp_dir: + """Generate NUM_TRIALS demos on NUM_ENVS envs, report their metrics and assert the success rate exceeds the + threshold.""" + with benchmark_temp_dir("franka_cube_stack_mimicgen") as temp_dir: output_file = os.path.join(temp_dir, "generated.hdf5") result_file = os.path.join(temp_dir, "generation_result.json") @@ -46,6 +52,7 @@ def test_mimicgen_franka_data_generation_success_rate(): output_file, "--result_file", result_file, + "--record_metric_inputs", "--generation_num_trials", str(NUM_TRIALS), "--num_envs", @@ -58,6 +65,7 @@ def test_mimicgen_franka_data_generation_success_rate(): run_subprocess(args, timeout_sec=TIMEOUT_SEC) assert_valid_dataset(output_file, min_num_demos=1) num_success, num_attempts = read_generation_result(result_file) + report = report_metrics(output_file, result_file) assert num_attempts > 0, "generation reported zero attempts" success_rate = num_success / num_attempts @@ -66,6 +74,7 @@ def test_mimicgen_franka_data_generation_success_rate(): f"data-gen success rate {success_rate:.1%} ({num_success}/{num_attempts}) is below the " f"required threshold of {SUCCESS_RATE_THRESHOLD:.0%}" ) + assert_computed_metrics(report, MIMICGEN_FRANKA_METRICS, optional=BENCHMARK_OPTIONAL_METRICS) if __name__ == "__main__": diff --git a/autodata_tests/e2e/test_mimicgen_data_generation.py b/autodata_tests/e2e/test_mimicgen_data_generation.py index 33f1ace..3c57aaf 100644 --- a/autodata_tests/e2e/test_mimicgen_data_generation.py +++ b/autodata_tests/e2e/test_mimicgen_data_generation.py @@ -6,26 +6,12 @@ import pytest -from autodata_tests.utils.constants import TestPaths +from autodata_tests.utils.constants import MIMICGEN_FRANKA_METRICS, TestPaths from autodata_tests.utils.subprocess import run_subprocess from autodata_tests.utils.utils import assert_ok_metrics, assert_recorded_run, assert_valid_dataset HEADLESS = True GENERATION_NUM_TRIALS = 2 -# Metrics a MimicGen run recorded with --record_metric_inputs must compute; no camera, so no image checks. -METRICS = { - "generation_success_rate", - "demos_per_gpu_hour", - "time_to_dataset", - "correctness_pass_rate", - "final_success_rate", - "action_rotation_error", - "action_saturation", - "motion_smoothness", - "joint_limit_ratio", - "start_layout_spread", - "workspace_spread", -} def _run_franka_cube_stack_mimicgen(num_envs: int, device: str) -> None: @@ -66,7 +52,7 @@ def _run_franka_cube_stack_mimicgen(num_envs: int, device: str) -> None: assert_valid_dataset(output_file, min_num_demos=GENERATION_NUM_TRIALS) assert_recorded_run(output_file, result_file) - assert_ok_metrics(output_file, result_file, METRICS) + assert_ok_metrics(output_file, result_file, MIMICGEN_FRANKA_METRICS) @pytest.mark.with_subprocess diff --git a/autodata_tests/utils/constants.py b/autodata_tests/utils/constants.py index faee5b3..e015604 100644 --- a/autodata_tests/utils/constants.py +++ b/autodata_tests/utils/constants.py @@ -26,3 +26,31 @@ def __init__(self): TestPaths = _TestPaths() + +# Metrics a run recorded with --record_metric_inputs must compute, per workflow, besides start_layout_spread and +# workspace_spread, which need two valid episodes. No workflow here records a camera, so no image checks. +MIMICGEN_FRANKA_METRICS = { + "generation_success_rate", + "demos_per_gpu_hour", + "time_to_dataset", + "correctness_pass_rate", + "final_success_rate", + "action_rotation_error", + "action_saturation", + "motion_smoothness", + "joint_limit_ratio", +} +# Absolute pose actions are not clipped (no action_saturation) and the GR1 and G1 configs give no hardware_limits +# (no joint_limit_ratio). +DEXMIMICGEN_METRICS = { + "generation_success_rate", + "demos_per_gpu_hour", + "time_to_dataset", + "correctness_pass_rate", + "final_success_rate", + "action_rotation_error", + "tracking_error", + "motion_smoothness", +} +# One hand step of over 8 cm in any of a benchmark's hundreds of episodes makes workspace_spread not applicable. +BENCHMARK_OPTIONAL_METRICS = frozenset({"workspace_spread"}) diff --git a/autodata_tests/utils/test_generation_result.py b/autodata_tests/utils/test_generation_result.py index 37fe93b..d34b761 100644 --- a/autodata_tests/utils/test_generation_result.py +++ b/autodata_tests/utils/test_generation_result.py @@ -6,7 +6,7 @@ import json from pathlib import Path -from autodata_utils.generation_result import AttemptLog, attempts_file_for, write_generation_result +from autodata_utils.generation_result import AttemptLog, attempts_file_for, code_revision, write_generation_result def test_write_generation_result_writes_completed_stats_atomically(tmp_path): @@ -63,3 +63,10 @@ def test_rerun_with_the_same_result_file_keeps_the_earlier_attempt_log(tmp_path: earlier = Path(attempts_file_for(result_file, "run-a")).read_text().splitlines() assert [json.loads(line)["run_id"] for line in earlier] == ["run-a"] + + +def test_code_revision_without_git_is_the_image_revision(monkeypatch) -> None: + monkeypatch.setenv("PATH", "") + monkeypatch.setenv("AUTODATA_REVISION", "0123abcd") + + assert code_revision() == "0123abcd" diff --git a/autodata_tests/utils/utils.py b/autodata_tests/utils/utils.py index efc2419..6746c58 100644 --- a/autodata_tests/utils/utils.py +++ b/autodata_tests/utils/utils.py @@ -3,9 +3,13 @@ """Shared assertion helpers for the AutoData test suite.""" +import contextlib import h5py import json import os +import shutil +import tempfile +from collections.abc import Iterator from autodata_metrics.records import ATTEMPT, RESULT, parse, parse_env_args from autodata_tests.utils.constants import TestPaths @@ -92,13 +96,11 @@ def assert_recorded_run(dataset_file: str, result_file: str) -> list[dict]: return attempts -def assert_ok_metrics(dataset_file: str, result_file: str, expected_ok: set[str]) -> None: - """Report a generation run's metrics with ``validate_dataset.py``; assert every episode passes the checks and - exactly ``expected_ok`` computed a value, with ``start_layout_spread`` and ``workspace_spread`` too when the run - exported two episodes or more. +def report_metrics(dataset_file: str, result_file: str) -> dict: + """Report a generation run's metrics with ``validate_dataset.py`` into ``report.json`` beside the dataset. - A renamed recorded key or an adapter that stops recording a stream turns a metric not applicable, which - this catches. + Returns: + The report. """ report_file = os.path.join(os.path.dirname(dataset_file), "report.json") @@ -113,17 +115,67 @@ def assert_ok_metrics(dataset_file: str, result_file: str, expected_ok: set[str] report_file, ]) with open(report_file, encoding="utf-8") as report_handle: - report = json.load(report_handle) + return json.load(report_handle) + + +def assert_ok_metrics(dataset_file: str, result_file: str, expected_ok: set[str]) -> None: + """Report a generation run's metrics; assert every episode passes the checks and the metrics in ``expected_ok`` + computed a value, as :func:`assert_computed_metrics` describes.""" + + report = report_metrics(dataset_file, result_file) assert ( report["num_valid_episodes"] == report["num_episodes"] ), f"{report['num_episodes'] - report['num_valid_episodes']} episodes failed checks: {report['check_failures']}" + assert_computed_metrics(report, expected_ok) + + +def assert_computed_metrics(report: dict, expected_ok: set[str], optional: frozenset[str] = frozenset()) -> None: + """Assert exactly ``expected_ok`` computed a value, with ``start_layout_spread`` and ``workspace_spread`` too when + two episodes or more are valid; the metrics in ``optional`` may compute or not. + + A renamed recorded key or an adapter that stops recording a stream turns a metric not applicable, which + this catches. + """ + rows = report["metrics"] - ok = {name for name, row in rows.items() if row["status"] == "ok"} + ok = {name for name, row in rows.items() if row["status"] == "ok"} - optional spreads = {"start_layout_spread", "workspace_spread"} if report["num_valid_episodes"] >= 2 else set() - expected = expected_ok | spreads + expected = (expected_ok | spreads) - optional assert ok == expected, f"Computed {sorted(ok)}, expected {sorted(expected)}: {rows}" +@contextlib.contextmanager +def benchmark_temp_dir(name: str) -> Iterator[str]: + """Yield a temporary directory for the benchmark ``name``. On exit, also after a failure, copy its files other than + HDF5 datasets (the generation result, its attempt log and the metrics report) to ``$AUTODATA_BENCHMARK_DIR/`` + when that variable is set. A failed copy fails a passing benchmark, but does not replace a failing one's error. + """ + + with tempfile.TemporaryDirectory() as temp_dir: + try: + yield temp_dir + except BaseException: + with contextlib.suppress(OSError): + _export_benchmark_files(temp_dir, name) + raise + _export_benchmark_files(temp_dir, name) + + +def _export_benchmark_files(source_dir: str, name: str) -> None: + """Copy the files of ``source_dir`` other than HDF5 datasets to ``$AUTODATA_BENCHMARK_DIR/``, if set.""" + + if not os.environ.get("AUTODATA_BENCHMARK_DIR"): + return + export_dir = os.path.join(os.environ["AUTODATA_BENCHMARK_DIR"], name) + os.makedirs(export_dir, exist_ok=True) + for file_name in os.listdir(source_dir): + path = os.path.join(source_dir, file_name) + if os.path.isfile(path) and not file_name.endswith(".hdf5"): + # copyfile, not copy2: the result file is written private (0600), and the copy must be readable by + # whatever uploads it. + shutil.copyfile(path, os.path.join(export_dir, file_name)) + + def assert_no_metric_inputs(dataset_file: str) -> None: """Assert a dataset recorded without ``--record_metric_inputs`` has no metric inputs, as before they existed.""" diff --git a/autodata_utils/generation_result.py b/autodata_utils/generation_result.py index fc5bc4e..a79fe79 100644 --- a/autodata_utils/generation_result.py +++ b/autodata_utils/generation_result.py @@ -106,13 +106,15 @@ def input_record(path: str | None) -> dict[str, str] | None: def code_revision() -> str | None: - """Git commit of the AutoData checkout, or None without git or outside a checkout.""" - if shutil.which("git") is None: - return None - result = subprocess.run( - ["git", "-C", str(Path(__file__).resolve().parent), "rev-parse", "HEAD"], - capture_output=True, - text=True, - check=False, - ) - return result.stdout.strip() if result.returncode == 0 else None + """Git commit of the AutoData checkout; without git or outside a checkout, ``$AUTODATA_REVISION`` (the commit an + image was built from), else None.""" + if shutil.which("git") is not None: + result = subprocess.run( + ["git", "-C", str(Path(__file__).resolve().parent), "rev-parse", "HEAD"], + capture_output=True, + text=True, + check=False, + ) + if result.returncode == 0: + return result.stdout.strip() + return os.environ.get("AUTODATA_REVISION") or None diff --git a/docker/Dockerfile.autodata b/docker/Dockerfile.autodata index 17a96df..d036cbd 100644 --- a/docker/Dockerfile.autodata +++ b/docker/Dockerfile.autodata @@ -86,6 +86,7 @@ COPY autodata_retargeting ${WORKDIR}/autodata_retargeting COPY autodata_utils ${WORKDIR}/autodata_utils COPY autodata_examples ${WORKDIR}/autodata_examples COPY autodata_tests ${WORKDIR}/autodata_tests +COPY scripts ${WORKDIR}/scripts RUN --mount=type=cache,id=autodata-uv,target=/root/.cache/uv,sharing=locked \ set -e; if [ "$INSTALL_CUROBO" = "true" ]; then \ bash /opt/autodata/sync_dependencies.sh --group curobo; \ @@ -116,5 +117,8 @@ RUN chmod +x /entrypoint.sh ENV PYTHONPYCACHEPREFIX=/tmp/autodata-pycache # uv run must not install the native Sim wheels over the image's simulator. ENV UV_NO_SYNC=1 +# The image has no .git; generation results and metric reports record this commit instead. +ARG AUTODATA_REVISION= +ENV AUTODATA_REVISION=${AUTODATA_REVISION} ENTRYPOINT ["/entrypoint.sh"] HEALTHCHECK NONE diff --git a/docs/pages/advanced/testing_and_ci.rst b/docs/pages/advanced/testing_and_ci.rst index eae9862..fa654a7 100644 --- a/docs/pages/advanced/testing_and_ci.rst +++ b/docs/pages/advanced/testing_and_ci.rst @@ -27,7 +27,9 @@ The suite is organized in tiers of increasing cost: simulated SpaceMouse input; physical-device and XR interaction need manual testing. * - ``datagen_perf/`` - Success-rate benchmarks (hundreds of attempts per run) asserting generation quality - thresholds per task. Nightly-scale. + thresholds per task. Each also reports its run's :doc:`metrics <../references/metrics>`; with + ``AUTODATA_BENCHMARK_DIR`` set, each copies its generation result, attempt log and report + into a subdirectory of it named after the benchmark. Nightly-scale. * - ``test_data/`` - Pre-annotated source datasets (Git LFS) used by the tests — and handy as quickstart inputs. From 0f9b58d170ff2156ab7ef5705e4a08bb2b8c3ea4 Mon Sep 17 00:00:00 2001 From: Billy Okal Date: Wed, 18 Nov 2026 14:28:55 -0600 Subject: [PATCH 2/2] test: replace a benchmark's earlier artifacts on export Exporting a run now replaces the benchmark's subdirectory instead of adding to it, so a retry that fails early cannot leave an earlier run's report beside its own attempt log. Signed-off-by: Billy Okal --- autodata_tests/utils/utils.py | 17 +++++++++-------- docs/pages/advanced/testing_and_ci.rst | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/autodata_tests/utils/utils.py b/autodata_tests/utils/utils.py index 6746c58..49bf718 100644 --- a/autodata_tests/utils/utils.py +++ b/autodata_tests/utils/utils.py @@ -119,8 +119,8 @@ def report_metrics(dataset_file: str, result_file: str) -> dict: def assert_ok_metrics(dataset_file: str, result_file: str, expected_ok: set[str]) -> None: - """Report a generation run's metrics; assert every episode passes the checks and the metrics in ``expected_ok`` - computed a value, as :func:`assert_computed_metrics` describes.""" + """Report a generation run's metrics, assert every episode passes the checks, then + :func:`assert_computed_metrics`.""" report = report_metrics(dataset_file, result_file) assert ( @@ -146,9 +146,9 @@ def assert_computed_metrics(report: dict, expected_ok: set[str], optional: froze @contextlib.contextmanager def benchmark_temp_dir(name: str) -> Iterator[str]: - """Yield a temporary directory for the benchmark ``name``. On exit, also after a failure, copy its files other than + """Yield a temporary directory for the benchmark ``name``. On exit, also after a failure, export its files other than HDF5 datasets (the generation result, its attempt log and the metrics report) to ``$AUTODATA_BENCHMARK_DIR/`` - when that variable is set. A failed copy fails a passing benchmark, but does not replace a failing one's error. + when that variable is set. A failed export fails a passing benchmark, but does not replace a failing one's error. """ with tempfile.TemporaryDirectory() as temp_dir: @@ -162,17 +162,18 @@ def benchmark_temp_dir(name: str) -> Iterator[str]: def _export_benchmark_files(source_dir: str, name: str) -> None: - """Copy the files of ``source_dir`` other than HDF5 datasets to ``$AUTODATA_BENCHMARK_DIR/``, if set.""" + """Replace ``$AUTODATA_BENCHMARK_DIR/``, if that variable is set, with the files of ``source_dir`` other than + HDF5 datasets, so the directory never mixes two runs.""" if not os.environ.get("AUTODATA_BENCHMARK_DIR"): return export_dir = os.path.join(os.environ["AUTODATA_BENCHMARK_DIR"], name) - os.makedirs(export_dir, exist_ok=True) + shutil.rmtree(export_dir, ignore_errors=True) + os.makedirs(export_dir) for file_name in os.listdir(source_dir): path = os.path.join(source_dir, file_name) if os.path.isfile(path) and not file_name.endswith(".hdf5"): - # copyfile, not copy2: the result file is written private (0600), and the copy must be readable by - # whatever uploads it. + # copyfile, not copy2: the result file is written 0600, and another user may upload the copy. shutil.copyfile(path, os.path.join(export_dir, file_name)) diff --git a/docs/pages/advanced/testing_and_ci.rst b/docs/pages/advanced/testing_and_ci.rst index fa654a7..445e013 100644 --- a/docs/pages/advanced/testing_and_ci.rst +++ b/docs/pages/advanced/testing_and_ci.rst @@ -28,8 +28,8 @@ The suite is organized in tiers of increasing cost: * - ``datagen_perf/`` - Success-rate benchmarks (hundreds of attempts per run) asserting generation quality thresholds per task. Each also reports its run's :doc:`metrics <../references/metrics>`; with - ``AUTODATA_BENCHMARK_DIR`` set, each copies its generation result, attempt log and report - into a subdirectory of it named after the benchmark. Nightly-scale. + ``AUTODATA_BENCHMARK_DIR`` set, each writes its generation result, attempt log and report to a + subdirectory named after the benchmark, replacing an earlier run's. Nightly-scale. * - ``test_data/`` - Pre-annotated source datasets (Git LFS) used by the tests — and handy as quickstart inputs.