Skip to content

Add photo station backend - #135

Draft
noobydp wants to merge 1 commit into
tracefinity:mainfrom
noobydp:codex/photo-stations-backend
Draft

Add photo station backend#135
noobydp wants to merge 1 commit into
tracefinity:mainfrom
noobydp:codex/photo-stations-backend

Conversation

@noobydp

@noobydp noobydp commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

This adds the backend foundation for reusable photo stations. A photo station stores a known camera/paper setup so later captures from the same setup can reuse or compare against saved paper corners instead of starting from scratch each time.

The PR includes:

  • photo station request/response schemas
  • a JSON-backed photo station store
  • endpoints for listing, creating, updating, deleting, and reusing stations
  • station suggestions for an uploaded session
  • corner redetection support
  • saving a station directly while confirming corners
  • focused backend tests for the new station behavior

Implementation Notes

The station store follows the existing local JSON-store pattern used elsewhere in the backend. Station records include paper size, image dimensions, source image path, saved corners, and timestamps.

The corner confirmation endpoint can now optionally receive save_station_name. When present, the backend creates a station from the confirmed session image and corners as part of the same workflow.

This also addresses review feedback from the original larger PR:

  • Uses timezone-aware UTC timestamps instead of datetime.utcnow().
  • Centralizes station creation logic in a helper instead of duplicating it between routes.
  • Copies the original uploaded image into station storage before unlinking the upload source.
  • Adds backend coverage for station creation, suggestion behavior, invalid input, corrupt store handling, and the copy-before-unlink path.

Tests

  • python -m pytest backend/tests/test_photo_stations.py

Code and PR drafted with Codex

@jasonmadigan

Copy link
Copy Markdown
Collaborator

@noobydp I will get to this and your other related PRs at some stage over the next few days

@noobydp

noobydp commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

No problem, whenever you have time.
Thanks

@jasonmadigan jasonmadigan left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks noobydp

Comment thread backend/app/api/routes.py
Comment thread backend/app/api/routes.py
Comment thread backend/app/models/schemas.py Outdated
Comment thread backend/tests/test_photo_stations.py
Comment thread backend/app/services/photo_station_store.py
Comment thread backend/app/services/photo_station_store.py Outdated
Comment thread backend/app/api/routes.py Outdated
Comment thread backend/app/api/routes.py Outdated
Comment thread backend/app/api/routes.py
@noobydp
noobydp force-pushed the codex/photo-stations-backend branch from 0145d3a to 63a9c78 Compare August 2, 2026 08:46
@noobydp

noobydp commented Aug 2, 2026

Copy link
Copy Markdown
Contributor Author

Updated this branch after review and rebased it onto current main.

Changes made in this update:

  • Added the PHOTO_STATIONS feature flag and kept station endpoints dark unless enabled.
  • Moved station upload dimension validation before writing the upload file, so rejected station uploads no longer leave orphaned files.
  • Changed capture crop handling so cropping happens inside ingestion before the max-size downscale, preserving more source resolution.
  • Made legacy sessions without stored image dimensions degrade to no station suggestions instead of returning 400.
  • Dropped the unused station_image_path session field and the unreachable station-image reference cleanup path.
  • Added finite-number validation for Point and CaptureCrop values so NaN cannot persist into station data.
  • Simplified the station-image migration and now renames corrupt photo-stations.json aside before continuing with an empty store.
  • Added tests for the above, including copy-failure source preservation, y-axis scaling, stale dimension rejection, feature flag behavior, and corrupt station storage handling.

Local validation:

  • python -m ruff check backend
  • python -m pytest tests/test_photo_stations.py
  • python -m pytest -k "not TestPermissionError" on Windows: 318 passed, 8 deselected. The deselected cases are the existing Windows-only temp-file permission fixture issue; the full suite otherwise passed.

Code and PR drafted with Codex

@noobydp
noobydp requested a review from jasonmadigan August 2, 2026 08:55
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