feat(scope): make Belgium and North Sea operational default
This commit is contained in:
@@ -130,18 +130,23 @@ class DetectionService:
|
||||
)
|
||||
|
||||
if model.model_id == "manual-fixture-detector":
|
||||
detections = DetectionService._persist_fixture_detections(
|
||||
db=db,
|
||||
project_id=project_id,
|
||||
dataset_id=dataset_id,
|
||||
analysis_run=analysis_run,
|
||||
job=job,
|
||||
model_name=model.model_id,
|
||||
model_version=model.version,
|
||||
raw_detections=parameters.get("fixture_detections"),
|
||||
confidence_threshold=confidence_threshold,
|
||||
class_filter=class_filter or [],
|
||||
)
|
||||
try:
|
||||
detections = DetectionService._persist_fixture_detections(
|
||||
db=db,
|
||||
project_id=project_id,
|
||||
dataset_id=dataset_id,
|
||||
analysis_run=analysis_run,
|
||||
job=job,
|
||||
model_name=model.model_id,
|
||||
model_version=model.version,
|
||||
raw_detections=parameters.get("fixture_detections"),
|
||||
confidence_threshold=confidence_threshold,
|
||||
class_filter=class_filter or [],
|
||||
)
|
||||
except Exception as exc:
|
||||
# A rejected fixture payload must never leave the run stuck in "running".
|
||||
DetectionService._fail_run_after_exception(db, analysis_run, job, exc, fallback_code="DETECTION_INTERNAL_ERROR")
|
||||
raise
|
||||
DetectionService._mark_success(db, analysis_run, job, detection_count=len(detections))
|
||||
return DetectionRunResponse(
|
||||
analysis_run_id=analysis_run.id,
|
||||
@@ -183,6 +188,10 @@ class DetectionService:
|
||||
error_code=exc.code,
|
||||
message=exc.message,
|
||||
)
|
||||
except Exception as exc:
|
||||
# An unexpected inference error must never leave the run stuck in "running".
|
||||
DetectionService._fail_run_after_exception(db, analysis_run, job, exc, fallback_code="DETECTION_INTERNAL_ERROR")
|
||||
raise
|
||||
DetectionService._mark_success(db, analysis_run, job, detection_count=len(detections), extra_result=postprocess_summary)
|
||||
return DetectionRunResponse(
|
||||
analysis_run_id=analysis_run.id,
|
||||
@@ -195,8 +204,28 @@ class DetectionService:
|
||||
message="YOLO detections persisted.",
|
||||
)
|
||||
|
||||
DetectionService._mark_failed(
|
||||
db,
|
||||
analysis_run,
|
||||
job,
|
||||
code="DETECTION_MODEL_UNAVAILABLE",
|
||||
message="Detection model is unavailable",
|
||||
)
|
||||
raise AppError(code="DETECTION_MODEL_UNAVAILABLE", message="Detection model is unavailable", status_code=503)
|
||||
|
||||
@staticmethod
|
||||
def _fail_run_after_exception(db, analysis_run: AnalysisRun, job: Job, exc: Exception, fallback_code: str) -> None:
|
||||
try:
|
||||
db.rollback()
|
||||
except Exception:
|
||||
pass
|
||||
code = getattr(exc, "code", None) or fallback_code
|
||||
message = getattr(exc, "message", None) or "Unexpected internal error during analysis run"
|
||||
try:
|
||||
DetectionService._mark_failed(db, analysis_run, job, code=str(code), message=str(message))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@staticmethod
|
||||
def get_run(db, analysis_run_id: uuid.UUID) -> DetectionRunRead:
|
||||
run = db.get(AnalysisRun, analysis_run_id)
|
||||
|
||||
Reference in New Issue
Block a user