feat(post-processing): admin scaffolding precursor (pydantic schema, form base, parameterized template)#1289
Draft
feat(post-processing): admin scaffolding precursor (pydantic schema, form base, parameterized template)#1289
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.
|
Contributor
|
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>
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
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.