Skip to content

fix: reconcile NWB export handler to deployed schema#90

Draft
tabedzki wants to merge 1 commit into
nwb-export-backendfrom
fix/nwb-export-handler-schema
Draft

fix: reconcile NWB export handler to deployed schema#90
tabedzki wants to merge 1 commit into
nwb-export-backendfrom
fix/nwb-export-handler-schema

Conversation

@tabedzki

Copy link
Copy Markdown
Contributor

Summary

The NWB export handler and helpers referenced columns and tables that do not exist in the deployed nwb_production schema (u19_pipeline/nwb_production.py, the authoritative source). This PR reconciles the handler and helpers to that real schema. State-machine behavior is otherwise unchanged.

Stacked on the nwb-export-backend PR (#89). Review/merge that first; this PR's base is nwb-export-backend, not master.

Changes

  • status_nwb_id -> status_id: The active-jobs query and per-job status read in pipeline_handler_main, plus the update1 in update_status_pipeline, now use the real NwbExportJob.status_id (FK to NwbExportStatus).
  • Part-tables -> NwbExportModality: process_data_validation (handler) and estimate_total_size (nwb_production_utils) no longer query the nonexistent NwbExportJob.BehaviorExport / .EphysExport / .ImagingExport part-tables. They now query NwbExportModality & {"nwb_job_id": ...} and branch on modality_name ('behavior'/'ephys'/'imaging'), parsing probe_numbers/fov_numbers (stored as JSON-array strings) and deriving the session/recording/scan keys from the NwbExportJob record.
  • Log column names: The NwbExportLogStatus insert now uses status_old / status_new / status_timestamp (was status_nwb_id_old / status_nwb_id_new).
  • Non-unique id fetch: submit_nwb_export_job no longer does fetch1("nwb_job_id") filtered by session_key alone (a session can have multiple jobs). It now fetches by {**session_key, "job_name": job_name} ordered by nwb_job_id DESC, taking the most recent.

Testing

tests/nwb_export no-db suite passes (193 passed); the with_db tests require a live DataJoint database not available in this environment, but they mock at module boundaries and already use the correct schema columns, so they are consistent with these fixes.

Closes BrainCOGS/tech_calendar_streamlit#70

🤖 Generated with Claude Code

The NWB export handler and helpers referenced columns and tables that do
not exist in the deployed nwb_production schema. This reconciles them to
the authoritative schema (u19_pipeline/nwb_production.py).

Changes:
- status_nwb_id -> status_id: the active-jobs query and per-job status read
  in pipeline_handler_main, and the update1 in update_status_pipeline, now use
  the real NwbExportJob.status_id (FK to NwbExportStatus).
- Part-tables -> NwbExportModality: process_data_validation (handler) and
  estimate_total_size (nwb_production_utils) no longer query the nonexistent
  NwbExportJob.BehaviorExport/.EphysExport/.ImagingExport part-tables. They now
  query NwbExportModality & {"nwb_job_id": ...} and branch on modality_name
  ('behavior'/'ephys'/'imaging'), parsing probe_numbers/fov_numbers (JSON-array
  strings) and deriving session/recording/scan keys from the NwbExportJob record.
- Log column names: NwbExportLogStatus insert now uses status_old/status_new/
  status_timestamp (was status_nwb_id_old/status_nwb_id_new).
- Non-unique id fetch: submit_nwb_export_job no longer fetch1("nwb_job_id") by
  session_key alone (a session can have multiple jobs). It now fetches by
  {**session_key, "job_name": job_name} ordered by nwb_job_id DESC.

State-machine behavior is otherwise unchanged.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant