Repository navigation
fix(ml-inference): handle corrupt-image partial-failure predictions - #536
Merged
Merged
Conversation
SpeciesNet silently emits prediction records with a `failures` field and no `prediction` when an image can't be loaded, which the Zod validator rejected and the catch block then propagated to every other job in the same batch. - Normalize partial-failure predictions to the standard `prediction: "error"` shape inside `VideoCapableLitAPI.predict_with_video_support` so all ML servers emit validator-compatible output. - Skip insertPrediction on failed predictions in InferenceConsumer; the media row stays observation-less and surfaces in the blank section. - Add `model_version: "unknown"` to the existing exception handler so DeepFaune/Manas error paths also pass validation.
✅ Deploy Preview for lucent-yeot-0cb408 canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
failuresfield and nopredictionwhen an image can't be loaded (e.g. corrupt JPEG). The Zod validator rejected those,insertModelOutputthrew, and the catch block cascaded the failure to every other job in the same batch — fanning a single corrupt file into up tobatchSizepermanent failures and leaving the progress bar stuck at <100% with no way to resume.VideoCapableLitAPI._normalize_failed_predictionsinutils.pyto rewrite partial-failure records into the standardprediction: "error"format used by the existing exception handler. Also backfilledmodel_version: "unknown"in that handler so DeepFaune/Manas error paths (which already raised on bad images) now pass validation too.InferenceConsumer.processBatchthat detectsprediction === 'error'or afailuresfield, marks the job complete (corrupt files aren't retriable), and skips observation creation. Media rows stay observation-less and surface naturally in the blank section via the existingnotExists(realObservations)query.Test plan
tests/test_utils.pyfor_normalize_failed_predictions(7 cases: partial-failure, success passthrough, fallback filepath/model_version, mixed batch, empty, missing key)make lint+make formatclean inpython-environments/common/queue-consumer,model-outputvalidator — 45 total)md-test-imagesstudy: 48/48 jobs completed on first attempt, bothcorrupt-images/JPEGs end up with 0 observations and surface in the blank section, no batch errors in logs.