Skip to content

Phase 2: backfill OpenNeuro import metadata + lift on* reindex block (#512) - #516

Merged
neuromechanist merged 3 commits into
feature/issue-514-epic-website-followupsfrom
feature/issue-512-phase2-openneuro-import
May 16, 2026
Merged

neuromechanist merged 3 commits into
feature/issue-514-epic-website-followupsfrom
feature/issue-512-phase2-openneuro-import

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Closes #512. Phase 2 of epic #514.

Summary

Three coordinated changes so on* datasets get the same right-rail / catalog data as nm* datasets:

  1. Backend (dataset-reindex.ts) — runDatasetSync no longer throws for on*; it skips only the nemar.org push (which still needs alternate_id mapping) and keeps refreshing D1 metadata columns + sync status. The result now carries nemar_sync_skipped: true and the admin /reindex route maps that to sync.status = "skipped" instead of "failed".
  2. Backend (buildReindexFilterQuery) — on* prefix removed from the exclusion list. --all, --missing-metadata, and --stale filters now sweep up OpenNeuro datasets. Sandbox xx* still excluded.
  3. CLI (import-openneuro.ts) — seedMetadata() writes a richer .nemar/metadata.json: bids_version from BIDSVersion, recording_modality + datatypes from a sub-*/datatype/ filesystem scan (mirrors the backend's detectModalitiesFromTree), funding_references from Funding array, acknowledgements when present. After publication-approve the orchestrator now calls reindexDataset() so D1 metadata columns + LLM enrichment populate for the new dataset (non-fatal — the operator gets a clear retry hint if it fails).

Why the import path was the bug

Tracing the actual flow:

  • LLM enrichment workflow (which writes D1 metadata columns) deploys AFTER the initial push (orchestrator step 8).
  • Subsequent pushes don't change README/dataset_description, so the trigger condition is never met.
  • runDatasetSync would normally populate columns, but it was throwing 400 "OpenNeuro datasets require alternate_id mapping..." for any on* dataset — blocking the metadata-columns block too, not just the nemar.org push.
  • Result: D1 columns stayed NULL forever for on* datasets, even though the data was sitting there in participants.tsv and the tree.

Test plan

  • bun test test/import-openneuro.test.ts test/dataset-reindex.test.ts → 44 pass / 0 fail
  • Backend tsc --noEmit passes
  • CLI tsc --noEmit passes
  • After deploy: nemar admin reindex on005262 returns sync.status = "skipped" (not "failed") and metadata_columns_written: true
  • After deploy: curl https://api.nemar.org/datasets/on005262 | jq '.dataset.modalities, .dataset.subject_count, .dataset.tasks' returns non-null
  • After deploy: nemar admin reindex --all includes on* datasets in the sweep
  • Future imports via nemar admin import-openneuro end with the reindex spinner showing "Refreshed enrichment + metadata columns"

Backfill plan

Once this lands and deploys, run nemar admin reindex --all (or --missing-metadata) to backfill the existing 30+ on* datasets. The bulk endpoint processes sequentially to respect rate limits.

Notes

  • The CLI's seedMetadata() now emits optional fields ONLY when there's content for them. Empty arrays are suppressed so downstream diffs make it obvious which fields came from seeding vs LLM enrichment.
  • BIDS IsIdenticalTo relation is preserved (was already correct for a 1:1 mirror; the issue text suggested IsDerivedFrom but IsIdenticalTo is the right DataCite vocabulary for a mirror with no transformation).
  • nemar_sync_skipped is plumbed through both /admin/datasets/:id/sync and /admin/datasets/:id/reindex responses so the CLI can render the skip clearly.

This is Phase 2 of 4. Next: Phase 3 (#511, QA sync + /qa/* route).

Three coordinated changes so freshly imported on* datasets get the same right-rail / catalog data as nm* datasets:

- runDatasetSync no longer throws hard for on*; it skips only the nemar.org push (which still needs alternate_id mapping) and keeps writing D1 metadata columns + sync status. Surfaced via new result.nemar_sync_skipped flag and a 'skipped' status in the admin reindex response.
- buildReindexFilterQuery includes on* in 'all', 'missing-metadata', and 'stale' filters. Sandbox (xx*) stays excluded.
- import-openneuro CLI seedMetadata expands the .nemar/metadata.json payload: bids_version, recording_modality + datatypes from a sub-*/datatype/ filesystem scan, funding_references from Funding, acknowledgements when present. After publication-approve the orchestrator now calls reindexDataset() so D1 metadata columns + LLM enrichment populate for the new dataset.

Existing on* datasets backfill via 'nemar admin reindex --all' once deployed.
@github-actions

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR516

Version: 0.8.18-PR516.9f93aa9
Commit: 9f93aa9


🤖 Updated on each push.

@neuromechanist
neuromechanist merged commit 443d287 into feature/issue-514-epic-website-followups May 16, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-512-phase2-openneuro-import branch May 18, 2026 11:10

This branch was previously deployed

1 inactive deployment
npm — 9f93aa9f Deployed May 16, 2026 by neuromechanist via publish #935
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