Honor YOLO preflight environment config
This commit is contained in:
@@ -19,7 +19,7 @@ def main() -> int:
|
||||
parser.add_argument("--model-path", help="Existing local YOLO model path.")
|
||||
parser.add_argument("--tile-manifest-path", help="Existing raster tile manifest path.")
|
||||
parser.add_argument("--enabled", action="store_true", help="Treat YOLO as enabled for this preflight.")
|
||||
parser.add_argument("--max-tiles", type=int, default=100, help="Maximum tile count allowed by preflight.")
|
||||
parser.add_argument("--max-tiles", type=int, help="Maximum tile count allowed by preflight.")
|
||||
parser.add_argument(
|
||||
"--assume-dependencies",
|
||||
action="store_true",
|
||||
@@ -35,11 +35,16 @@ def main() -> int:
|
||||
if args.check_model_load and args.assume_dependencies:
|
||||
parser.error("--check-model-load cannot be combined with --assume-dependencies")
|
||||
|
||||
settings = Settings(
|
||||
yolo_enabled=args.enabled or bool(args.model_path),
|
||||
yolo_model_path=args.model_path,
|
||||
yolo_max_tiles=args.max_tiles,
|
||||
)
|
||||
settings = Settings()
|
||||
settings_updates = {}
|
||||
if args.enabled or args.model_path:
|
||||
settings_updates["yolo_enabled"] = True
|
||||
if args.model_path:
|
||||
settings_updates["yolo_model_path"] = args.model_path
|
||||
if args.max_tiles is not None:
|
||||
settings_updates["yolo_max_tiles"] = args.max_tiles
|
||||
if settings_updates:
|
||||
settings = settings.model_copy(update=settings_updates)
|
||||
payload = YoloPreflightService.run(
|
||||
settings=settings,
|
||||
tile_manifest_path=args.tile_manifest_path,
|
||||
|
||||
@@ -197,6 +197,36 @@ def test_yolo_preflight_script_outputs_json(tmp_path: Path) -> None:
|
||||
assert payload["tile_manifest_path"] == str(manifest_path)
|
||||
|
||||
|
||||
def test_yolo_preflight_script_uses_environment_configuration(tmp_path: Path, monkeypatch) -> None:
|
||||
model_path = tmp_path / "model.pt"
|
||||
model_path.write_bytes(b"weights")
|
||||
manifest_path = _manifest(tmp_path)
|
||||
monkeypatch.setenv("YOLO_ENABLED", "true")
|
||||
monkeypatch.setenv("YOLO_MODEL_PATH", str(model_path))
|
||||
monkeypatch.setenv("YOLO_MAX_TILES", "4")
|
||||
|
||||
result = subprocess.run(
|
||||
[
|
||||
sys.executable,
|
||||
str(ROOT / "scripts" / "yolo_preflight.py"),
|
||||
"--tile-manifest-path",
|
||||
str(manifest_path),
|
||||
"--assume-dependencies",
|
||||
"--json",
|
||||
],
|
||||
cwd=ROOT,
|
||||
check=True,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
payload = json.loads(result.stdout)
|
||||
|
||||
assert payload["status"] == "ready"
|
||||
assert payload["checks"]["enabled"] is True
|
||||
assert payload["model_path"] == str(model_path)
|
||||
assert payload["max_tiles"] == 4
|
||||
|
||||
|
||||
def test_yolo_preflight_script_rejects_assumed_dependencies_for_model_load(tmp_path: Path) -> None:
|
||||
result = subprocess.run(
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user