Skip to content

Split storage from models.py into models_future - #1476

Merged
kra merged 1 commit into
mainfrom
kra/model-split-tests-storage
Oct 9, 2026
Merged

kra merged 1 commit into
mainfrom
kra/model-split-tests-storage

Conversation

@kra

@kra kra commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator
  • Background work to enable models reorganization
  • Move classes S3StorageSource, SourceImageUpload, and related methods from main.models to models_future.storage.

Summary

Move classes S3StorageSource, SourceImageUpload, and related methods from main.models to models_future.storage.

List of Changes

This is based off of the branch in #1470.

Moves code from ami.main.models to ami.main.models_future, with minor edits, and adds tests to models_future.

Related Issues

Relates to #260.

Detailed Description

Move classes S3StorageSource, SourceImageUpload, and related methods from main.models to models_future.storage.

Use strings to references classes in (django.db.models.)ForeignKey calls to avoid circuar references, since main.models needs to import this module.

main.models re-exports models moved to models_future under their same models.* names for compatibilty with existing migrations. I'd rather update the migrations, but that's a much broader change and I didn't want to think about what implications I might be missing.

I didn't update any references to ami.main.models.S3StorageSource to use ami.main.models_future.storage. I feel like that's the right thing to do, but the name "models_future" makes that questionable? We probably should just do that to make our embarrasment more obvious? Maybe when we've moved enough to name main.models to main.models_legacy, at which point we'll need to deal with existing migrations?

How to Test the Changes

docker compose -f docker-compose.ci.yml run --rm django python manage.py makemigrations --check --dry-run

Summary by CodeRabbit

  • New Features
    • Added project-level S3 storage configuration, with tools to test connections and view indexed file counts, sizes, and captures.
    • Added paginated storage file listings and deployment-scoped image uploads, including optional links to source images and users.
    • Changing a storage source’s public base URL now queues URL updates for its deployments.

@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 130ffa1b-f2d3-476c-b312-898859435876

📥 Commits

Reviewing files that changed from the base of the PR and between 11aae91 and 55f218f.


📒 Files selected for processing (5)
  • ami/main/models.py
  • ami/main/models_future/__init__.py
  • ami/main/models_future/storage.py
  • ami/main/models_future/tests/__init__.py
  • ami/main/models_future/tests/test_storage.py

💤 Files with no reviewable changes (1)
  • ami/main/models_future/tests/init.py

🚧 Files skipped from review as they are similar to previous changes (1)
  • ami/main/models_future/init.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

The pull request moves S3 storage and manual-upload models into ami.main.models_future.storage and re-exports them from ami.main.models. It adds storage operations and tests, updates model-module documentation, and reformats filter-builder examples.

Changes

Storage models

Layer / File(s) Summary
S3 storage configuration and operations
ami/main/models_future/storage.py, ami/tests/test_storage.py, ami/main/models_future/tests/test_storage.py
S3StorageSource provides S3 configuration, file and capture statistics, URI helpers, connection tests, and queued public-URL updates. Tests cover these operations, consumer behavior, API responses, and access checks.
Upload lifecycle and model exports
ami/main/models_future/storage.py, ami/main/models.py, ami/main/models_future/__init__.py, ami/main/models_future/filters.py
SourceImageUpload saves its deployment and removes an associated SourceImage when deleted. ami.main.models re-exports the storage names. Module documentation changes the planned model layout, and filter examples lose doctest prompts.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Refactor

Suggested reviewers: mihow


Merge Risk

Merge Risk: ⚪ Minimal · up to 55f21

No concrete merge-blocking issue is established. Run the stated migration check and normal CI checks before merging.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to ccac9

The reorganization preserves existing access controls, storage operations, and upload behavior. No material security risk introduced or worsened by this change was identified.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The relocation does not expand the inspected API callers or storage authority. Sensitive operations continue using existing storage credentials and endpoint configuration. Their maximum external reach depends on credential privileges and server network policy, which were not established by the supplied evidence.

Trust Boundaries and Controls

  • observed — The unchanged storage viewset retains ObjectPermission, active-project queryset filtering, and object lookup before connection testing. The upload viewset retains ObjectPermission, a required project, current-user assignment, and user-scoped reads. Added storage tests assert credential non-disclosure and denial for insufficient permissions, another project's source, and anonymous callers; those tests were inspected, not executed.

Resilience and Maintainability Implications

  • observed — The inspected upload flow remains multi-step without a local transaction or explicit idempotency mechanism, and storage URL updates remain queued before the model save completes. Partial-failure and repetition limitations therefore predate this PR rather than constituting introduced architecture concerns. Crash, concurrency, and recovery behavior was assessed by source comparison, not runtime fault testing.



Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 34.92% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 63 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: moving storage models from models.py into models_future.
Description check Passed The description includes a summary, change list, related issue, detailed implementation notes, and test instructions. It does not include the checklist, deployment notes, or a reported test result, bu…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.


  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR


  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kra
kra marked this pull request as draft October 6, 2026 00:14
@netlify

netlify Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for antenna-preview canceled.

Name Link
🔨 Latest commit 55f218f
🔍 Latest deploy log https://app.netlify.com/projects/antenna-preview/deploys/6ac9564c5b5dbd000816ba11

@netlify

netlify Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for antenna-ssec canceled.

Name Link
🔨 Latest commit 55f218f
🔍 Latest deploy log https://app.netlify.com/projects/antenna-ssec/deploys/6ac9564c2ec4390008d3aacd

@kra

kra commented Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

Apparently github pull requests must be based on main - this is based on an intermediate branch with it's own pull request. Converting to a draft until this can be merged, until then, this also includes changes in #1470. This has now been rebased in the PR to match the branch.

@kra
kra changed the base branch from main to kra/model-split-tests October 6, 2026 22:16
@kra
kra marked this pull request as ready for review October 6, 2026 22:24
@kra
kra requested a review from mihow October 8, 2026 16:22
@mihow
mihow added this pull request to stack #1489 October 8, 2026 16:38
@kra
kra force-pushed the kra/model-split-tests-storage branch from ccac90d to a3aec65 Compare October 8, 2026 22:14
Base automatically changed from kra/model-split-tests to main October 8, 2026 22:58
@kra
kra force-pushed the kra/model-split-tests-storage branch from a3aec65 to 7e171c2 Compare October 8, 2026 22:58
@mihow

mihow commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

@kra great start! If this passed the CI tests then I think its safe to merge

…from main.models to models_future.storage.

Use strings to references classes in (django.db.models.)ForeignKey calls to avoid circuar references, since main.models needs to import this module.

main.models re-exports models moved to models_future under their same models.* names for compatibilty with existing migrations. I'd rather update the migrations, but that's a much broader change and I didn't want to think about what implications I might be missing.

I didn't update any references to ami.main.models.S3StorageSource to use ami.main.models_future.storage. I feel like that's the right thing to do, but the name "models_future" makes that questionable? We probably should just do that to make our embarrasment more obvious? Maybe when we've moved enough to name main.models to main.models_legacy, at which point we'll need to deal with existing migrations?

Tested with `docker compose -f docker-compose.ci.yml run --rm django python manage.py makemigrations --check --dry-run`
@kra
kra force-pushed the kra/model-split-tests-storage branch from 11aae91 to 55f218f Compare October 9, 2026 21:02
@kra
kra merged commit 5f5149e into main Oct 9, 2026
6 of 7 checks passed
@kra
kra deleted the kra/model-split-tests-storage branch October 9, 2026 21:27
mihow added a commit that referenced this pull request Oct 10, 2026
…was squash-merged

#1461 landed on main as one squash commit, so its files reached main with no history link to this
branch's earlier merges of the #1461 branch. Each add/add conflict was resolved by keeping this branch's
side, which is #1461's final version of the file plus #1469's changes: main's copy of every conflicting
file except ami/ml/results/tests.py equals the #1461 head this branch had merged. That test file takes
main's version, which adds the test for #1461's last commit (the read-only results admin). Main's other
changes (#1476, #1420, #1495) merged cleanly.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QT59KePky4u4nbCsTAggtc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants