feat(post-processing): admin scaffolding precursor (pydantic schema, form base, parameterized template)#1289
feat(post-processing): admin scaffolding precursor (pydantic schema, form base, parameterized template)#1289mihow wants to merge 3 commits into
Conversation
Context: PRs #999 (class masking) and #1272 (tracking) each grew their own admin-trigger plumbing (registry registration, intermediate confirmation page with form, freeform dict config). This precursor extracts the shared pattern using SmallSizeFilterTask as the migration consumer — proves the abstraction without carving up another contributor's open PR. Spec covers: pydantic config_schema contract on BasePostProcessingTask, BasePostProcessingActionForm class, parameterized confirmation template + partial, SmallSizeFilterTask migration (exposes existing size_threshold knob via admin), test plan, rebase impact for #999 + #1272. Co-Authored-By: Claude <noreply@anthropic.com>
✅ Deploy Preview for antenna-preview canceled.
|
✅ Deploy Preview for antenna-ssec canceled.
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Adds the shared infrastructure that PRs #999 (class masking) and #1272 (tracking) each grew independently. Uses SmallSizeFilterTask as the migration consumer to prove the pattern without carving up another open PR. Changes: - BasePostProcessingTask gains required pydantic config_schema class attr; validates Job.params['config'] at task __init__ via self.config_schema(**config). self.config is now a BaseModel instance (was: freeform dict). - SmallSizeFilterTask: adds SmallSizeFilterConfig schema (size_threshold + source_image_collection_id, validators for 0<x<1, extra=forbid). Existing default 0.0008 preserved. - New admin form base BasePostProcessingActionForm with to_config() contract, plus SmallSizeFilterActionForm exposing size_threshold knob (currently unreachable — admin trigger hardcoded empty config). - Parameterized confirmation template at admin/post_processing/confirmation.html with overridable {% block intro %} and a _form_fieldset.html partial. - run_small_size_filter admin action rewrites onto new pattern: intermediate confirmation page on first POST, validate + enqueue on confirm. Per-collection Job creation preserved (each Job gets correct project FK). - 17 tests covering schema contract, form validation, intermediate page render, multi-collection partitioning by project FK. Pydantic v1 syntax throughout (repo pins pydantic<2.0). Memory note: container is v1, .dict() / .__fields__ are correct here. Out of scope (explicitly deferred): - Project-partitioning helper (defer to whichever multi-scope adopter lands first, likely #1272's tracking which partitions events across projects) - REST API trigger surface (eventual primary; admin not future-primary) - Rank rollup, class masking, tracking tasks themselves — stay in their PRs Design doc: docs/claude/planning/2026-05-01-post-processing-admin-scaffolding-design.md Co-Authored-By: Claude <noreply@anthropic.com>
Confirmation page (intermediate page rendering with size_threshold form field) and success message (after submitting form, Job 1571 enqueued with typed config payload). Co-Authored-By: Claude <noreply@anthropic.com>
| jobs.append(job.pk) | ||
|
|
||
| self.message_user(request, f"Queued Small Size Filter for {queryset.count()} capture set(s). Jobs: {jobs}") | ||
| def run_small_size_filter( |
There was a problem hiding this comment.
If we add 2 to 3 more post processing methods, this function may start to look repetitive. Is it worth trying to abstract run_... and _render ? I already see some repeated strings in this single implementation.
Summary
Precursor PR for post-processing admin work. Extracts the shared admin-trigger pattern that PRs #999 (class masking) and #1272 (tracking) each grew independently, using
SmallSizeFilterTaskas the migration consumer.No new domain logic. Pure scaffolding + a refactor of the existing small-size-filter trigger to expose its already-coded
size_thresholdknob via the admin (currently unreachable — admin trigger hardcodes empty config).What lands
config_schemacontract onBasePostProcessingTask— pydantic v1 model required as a class attribute, validated at task__init__BasePostProcessingActionForm— django form base withto_config()→ dict contract for buildingJob.params['config']admin/post_processing/confirmation.html+_form_fieldset.htmlpartialSmallSizeFilterTask:SmallSizeFilterConfig(size_threshold: float = 0.0008, source_image_collection_id: int)schemaSmallSizeFilterActionFormwithsize_thresholdfield (0 < x < 1validation)0.0008default)ami/ml/post_processing/tests/Out of scope (deferred to follow-ups)
Rebase impact for downstream PRs
admin_forms.py→admin/tracking_form.py. Form gainsto_config(). AddsTrackingConfigschema. Per-project partition loop stays.<select>becomesClassMaskingActionForm(BasePostProcessingActionForm)withModelChoiceFields. AddsClassMaskingConfig+RankRollupConfigschemas. Will message author once this lands.Smoke test (manual, against live stack)
End-to-end validated against project 18 capture set 175 (10 images):
admin/post_processing/confirmation.htmlrendered) ✓size_thresholdfield with default0.0008and help text ✓Job.paramspayload validated typed:{'task': 'small_size_filter', 'config': {'size_threshold': 0.0008, 'source_image_collection_id': 175}}✓Test plan
test_base_schema.py— subclass without schema raises, bad config raises ValidationError, valid config buildsBaseModelinstance, unknown keys rejected (extra="forbid")test_admin_form.py—to_config()round-trip,size_thresholdrange validationtest_small_size_filter_admin.py— POST withoutconfirmrenders intermediate page (no Job created), POST with validconfirm=yescreates one Job per collection with threshold in config, invalid threshold re-renders form with error, multi-collection POST creates per-collection jobs with correct project FKsDesign doc
docs/claude/planning/2026-05-01-post-processing-admin-scaffolding-design.md(committed in this branch).Notes
pydantic<2.0).__fields__andvalidatoras deprecated in some envs — these come from local v2 stubs; container is v1 and the syntax is correct.