Files
geointel/backend/tests/test_sprint129_operator_yolo_training_dataset.py
T
Jens 36aa3177e7
GeoIntel release gates / Compile, test, contracts and builds (push) Canceled after 0s
GeoIntel release gates / Python and npm vulnerability policy (push) Canceled after 0s
GeoIntel release gates / GIS image, SBOM and container scan (push) Canceled after 0s
feat: harden governed PyTorch training programme
2026-07-26 17:18:42 +02:00

80 lines
2.9 KiB
Python

from pathlib import Path
import subprocess
import sys
ROOT = Path(__file__).resolve().parents[2]
def test_operator_yolo_dataset_export_script_contract() -> None:
script_path = ROOT / "scripts" / "export_operator_yolo_dataset.py"
readiness = (ROOT / "scripts" / "run_readiness_check.sh").read_text(encoding="utf-8")
assert script_path.exists()
script = script_path.read_text(encoding="utf-8")
assert "py_compile scripts/export_operator_yolo_dataset.py" in readiness
assert "operator_samples_manifest.json" in script
assert "dataset.yaml" in script
assert "images/train" in script
assert "labels/train" in script
assert "images/val" in script
assert "labels/val" in script
assert "building" in script
assert "reference_feature_count" in script
assert "source_name" in script
assert "reference_layer_name" in script
assert "rasterio" in script
assert "Transformer" in script
assert "demo/workflow" not in script
assert "fixture_mode" not in script
assert "will_download_models" not in script
def test_operator_yolo_dataset_export_help_does_not_require_gis_dependencies() -> None:
script_path = ROOT / "scripts" / "export_operator_yolo_dataset.py"
result = subprocess.run(
[sys.executable, str(script_path), "--help"],
check=False,
capture_output=True,
text=True,
)
assert result.returncode == 0
assert "Export operator real-data samples to a YOLO detection dataset" in result.stdout
assert "--manifest-path" in result.stdout
assert "--val-samples" in result.stdout
def test_operator_yolo_train_smoke_script_contract() -> None:
script_path = ROOT / "scripts" / "train_operator_yolo_detector.sh"
readiness = (ROOT / "scripts" / "run_readiness_check.sh").read_text(encoding="utf-8")
assert script_path.exists()
script = script_path.read_text(encoding="utf-8")
assert "bash -n scripts/train_operator_yolo_detector.sh" in readiness
assert "TRAIN_REQUIRE_CUDA" in script_path.read_text(encoding="utf-8")
assert "OPERATOR_YOLO_DATASET_DIR" in script
assert "YOLO_BASE_MODEL_PATH" in script
assert "TRAIN_MODEL_OUTPUT_PATH" in script
assert "TRAIN_EPOCHS" in script
assert "TRAIN_IMGSZ" in script
assert "/opt/geointel/venv/bin/python" in script
assert "PYTHON_BIN=\"python3\"" in script
assert "dataset.yaml" in script
assert "from ultralytics import YOLO" in script
assert "model.train" in script
assert "plots=False" in script
assert "seed_ultralytics_font" in script
assert "DejaVuSans.ttf" in script
assert "Arial.ttf" in script
assert "training_summary.json" in script
assert '"dataset_yaml_sha256"' in script
assert '"dataset_summary_sha256"' in script
assert '"base_model_sha256"' in script
assert '"trained_model_sha256"' in script
assert "download" not in script.lower()
assert "fixture_mode" not in script