Skip to content

Official Codebase of 3DCodeVerse

Python

budget: --max-minutes inf is refused — the session deadline cannot be computed from an infinite clock

gaoypengeb9406604f15
diff --git a/harness/codeverse3d/cli/_common.py b/harness/codeverse3d/cli/_common.py
index 642959e6..57bb1569 100644
--- a/harness/codeverse3d/cli/_common.py
+++ b/harness/codeverse3d/cli/_common.py
@@ -233,9 +233,12 @@ def parse_kv_floats(items: list[str], flag: str) -> dict[str, float]:
def check_minutes(max_minutes: float | None) -> None:
"""``--max-minutes`` must leave the run some time: 0 planned (paid), then stopped at the
- first clock check with no round — a ``budget`` run with nothing in it."""
+ first clock check with no round — a ``budget`` run with nothing in it. ``inf``/``nan`` is no clock at
+ all: the session deadline cannot be computed from it."""
if max_minutes is not None and max_minutes <= 0:
raise CliError(f"--max-minutes must be above 0 (got {max_minutes:g}): a run with no time builds nothing", code=2)
+ if max_minutes is not None and not math.isfinite(max_minutes):
+ raise CliError(f"--max-minutes must be a finite number of minutes (got {max_minutes:g})", code=2)
def check_backends(backends: Any) -> None:
diff --git a/harness/codeverse3d/contracts/common.py b/harness/codeverse3d/contracts/common.py
index 2d25ef4a..bbbebf20 100644
--- a/harness/codeverse3d/contracts/common.py
+++ b/harness/codeverse3d/contracts/common.py
@@ -165,7 +165,7 @@ class Budget(BaseModel):
model_config = ConfigDict(extra="forbid")
max_rounds: int = Field(default=4, ge=0)
- max_minutes: float = Field(default=60.0, ge=0)
+ max_minutes: float = Field(default=60.0, ge=0, allow_inf_nan=False)
max_repair_attempts: int = Field(default=3, ge=0) # per build failure before escalating
diff --git a/harness/tests/flywheel_cli/test_cli.py b/harness/tests/flywheel_cli/test_cli.py
index fae892a8..dd776c93 100644
--- a/harness/tests/flywheel_cli/test_cli.py
+++ b/harness/tests/flywheel_cli/test_cli.py
@@ -537,6 +537,8 @@ def test_a_zero_minute_budget_is_refused(made_run, tmp_path: Path):
runs, run_dir = made_run()
r = runner.invoke(app, ["resume", run_dir.name, "--runs-dir", str(runs), "--max-minutes", "0"])
assert r.exit_code == 2 and "--max-minutes" in r.output
+ r = runner.invoke(app, ["make", "a cup", "--max-minutes", "inf", "--no-run", "--runs-dir", str(tmp_path / "i"), "--slug", "i"])
+ assert r.exit_code == 2 and "finite" in r.output and not (tmp_path / "i" / "i").exists()
def test_a_reference_that_is_not_an_image_is_refused_before_the_run_exists(tmp_path: Path):