feat: add POLYGON_CRITERIA_STATS job handler - #14
Merged
Conversation
Adds a new job type that computes histogram bins and summary statistics (min/max/mean/median/p5/p95/nodata_count) for the requested criteria columns within a user-drawn polygon. The handler loads regional data, then narrows the slope table with a two-pass spatial filter: a cheap vectorised bbox range check first, then the expensive point-in-polygon test only on the reduced candidate set. Also mark jobs FAILED when an unhandled exception occurs after the job was claimed (e.g. OOM kill), so they don't sit in IN_PROGRESS forever. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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
Adds a new
POLYGON_CRITERIA_STATSjob type that computes histogram bins and summary statistics for criteria values inside a user-drawn polygon. This is the compute half of the polygon criteria distribution feature; the UI and infra half lives inAIMS/reefguide(branchfeat/consolidated-map-ui).Changes
src/job_worker/handlers.jl):PolygonCriteriaStatsHandlertakes a GeoJSON polygon, a region ID and a list of criteria IDs, and returns per-criteria{ bins, min, max, mean, median, p5, p95, nodata_count }. Payload structs mirror the TypeScriptPolygonCriteriaStatsInput/PolygonCriteriaStatsOutputschemas.src/job_worker/worker.jl): if an unhandled exception occurs after a job has been claimed (e.g. an OOM kill), the job is now marked FAILED instead of sitting inIN_PROGRESSindefinitely.__init__, adds it to.env.distJOB_TYPES, and adds theStatisticsdependency.Deployment note
PublishDockerImage.ymlonly runs onrelease: publishedor manualworkflow_dispatch, and thelatesttag is only applied onmain. Merging this alone will not update the:latestimage that dev/prod consume — a release or manual dispatch frommainis needed before the deployed workers will accept the new job type.Test plan
POLYGON_CRITERIA_STATSjob against a known region and polygon; confirm bins and summary stats are returned🤖 Generated with Claude Code