Skip to content

feat: ingest motion-corrected micrograph image paths (#309)#311

Open
vredchenko wants to merge 1 commit into
mainfrom
feat/309-micrograph-image-ingest
Open

feat: ingest motion-corrected micrograph image paths (#309)#311
vredchenko wants to merge 1 commit into
mainfrom
feat/309-micrograph-image-ingest

Conversation

@vredchenko

Copy link
Copy Markdown
Collaborator

Closes #309. Implements the ingestion half of ADR 0021 (smartem-devtools PR #232): persist the motion-corrected micrograph image paths so the leaf image can be served. The serving endpoint is #308 (gated behind this); the cryoem-services adapter that supplies the paths is #310 (external).

What

The scientifically meaningful micrograph image is the motion-corrected artefact cryoem-services already produces (a 2D .mrc and a downscaled .jpeg snapshot) — not the stored high_res_path (raw multi-GB movie stack; 3D-array encode failure + OOM). Those paths arrive through SmartEM's existing POST /micrographs/{uuid}/motion_correction/completed contract, which this PR extends additively.

  • Migration d5e6f7a8b9c0 — adds two nullable columns to micrograph: motion_corrected_image_path, motion_corrected_snapshot_path. No backfill; existing/dump rows stay null.
  • ContractsMotionCorrectionCompletedRequest (HTTP) and MotionCorrectionCompleteBody (RabbitMQ body) each gain both fields as optional (nullable, default None). Callers that omit them are unaffected — backward-compatible.
  • Wiringpublish_motion_correction_completed threads the two paths into the event; the endpoint forwards them from the payload; handle_motion_correction_complete persists whichever paths are present onto the micrograph row (previously it touched only statistics and updated_at).

Verification

  • Full Alembic chain applies from an empty DB; both columns present and nullable; downgrade -1 drops them; re-upgrade + --autogenerate reports no drift (model matches migration).
  • test_processing_feedback_endpoints.py + test_consumer_async_handlers.py pass (2 new cases: paths forwarded through the endpoint, paths persisted by the consumer).
  • ruff check/format clean; pyright introduces no new errors.

Notes

Persist the motion-corrected image artefacts cryoem-services produces so
the micrograph leaf can be served (ADR 0021). This is the ingestion half;
the serving endpoint is #308.

- add nullable micrograph.motion_corrected_image_path and
  motion_corrected_snapshot_path columns (Alembic migration, no backfill)
- extend MotionCorrectionCompletedRequest and MotionCorrectionCompleteBody
  additively with both optional paths (backward-compatible)
- thread the paths through publish_motion_correction_completed and persist
  whichever are present in handle_motion_correction_complete

The two paths arrive via the existing motion_correction/completed contract;
callers that omit them are unaffected.
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.

feat: ingest motion-corrected micrograph image paths (ADR 0021, gates #308)

1 participant