Skip to content

Add OpenNeuro dataset import pipeline - #215

Merged
neuromechanist merged 3 commits into
devfrom
feature/openneuro-import
Mar 4, 2026
Merged

neuromechanist merged 3 commits into
devfrom
feature/openneuro-import

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Summary

  • Add on prefix support for OpenNeuro-sourced datasets (validation, D1 migration)
  • Add POST /admin/datasets/import backend endpoint for creating datasets with custom IDs
  • Add nemar admin import-openneuro <ds-id> CLI command that orchestrates clone, S3 copy, metadata seeding, and push
  • Add CI workflow template (onboard-openneuro.yml) for nemarDatasets/.github

Details

Maps OpenNeuro ds###### to NEMAR on######. Seeds .nemar/metadata.json with IsIdenticalTo relation linking the NEMAR DOI to the OpenNeuro DOI. Stores provenance (source: "openneuro", source_id) in D1.

Test plan

  • isValidDatasetId("on007262") returns true, isSandboxDatasetId("on007262") returns false
  • Backend and CLI build cleanly
  • Type checking passes
  • Manual test: nemar admin import-openneuro ds007262 against dev backend
  • Deploy CI workflow to nemarDatasets/.github and trigger with ds007262

Add 'on' prefix support for OpenNeuro-sourced datasets alongside
existing nm/xx prefixes. Includes backend import endpoint, CLI
orchestration command, D1 migration for source tracking, and a
CI workflow template for nemarDatasets/.github.

Maps ds###### -> on###### with IsIdenticalTo DOI relation.
@github-actions

github-actions Bot commented Mar 4, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR215

Version: 0.6.6-PR215.1de5b25
Commit: 1de5b25


🤖 Updated on each push.

- Fix shell injection in CI workflow (use env vars instead of direct interpolation)
- Remove dead code (readDataciteYml, duplicate run function)
- Check git add/commit/remote-remove exit codes
- Make data download failure a hard error (use --skip-data for metadata only)
- Consolidate Zod + manual validation into single regex schema
- Add last_activity_at to import INSERT
- Include error details in admin-facing error responses
- Add top-level try-catch in CLI command handler
- Fix step numbering mismatch in docstring
- Export runCommand from git-annex.ts and reuse it
- Extract DOI once and pass through to seedMetadata
@neuromechanist

Copy link
Copy Markdown
Contributor Author

PR Review Findings

Ran 4 specialized review agents (code-reviewer, silent-failure-hunter, comment-analyzer, code-simplifier) in parallel. All findings addressed in commit 9b45d2a.

Critical (4 found, 4 fixed)

Issue Fix
Shell injection in CI workflow -- ${{ inputs }} interpolated directly into run: blocks, exposing AWS secrets Replaced with env: block variables ($INPUT_IDS, $DATASET_ID, $SKIP_DATA)
Unchecked git add/git commit exit codes -- metadata commit could silently fail Now checks exit codes; fails on error (allows "nothing to commit" for idempotency)
Unchecked git remote remove -- could leave OpenNeuro origin in place, pushing to wrong remote Now checks exit code; tolerates "No such remote" for retries
Silent continuation after failed data download -- import reports success with missing data Now a hard failure; use --skip-data explicitly for metadata-only imports

Important (3 found, 3 fixed)

Issue Fix
Missing last_activity_at in INSERT -- risks premature stale cleanup Added datetime('now') to the import INSERT statement
Generic error message strips diagnostic context from admin Backend now includes the actual error in admin-facing responses
Audit log failure swallows dataset context Error log now includes dataset_id and admin.id

Code Quality (7 found, 7 fixed)

Issue Fix
Dead code: readDataciteYml defined but never called Removed
Duplicate run() function identical to runCommand in git-annex.ts Exported runCommand, imported and reused it
Inconsistent DOI extraction (with/without prefix strip) in two places Extracted once via extractOpenNeuroDoi(), passed as parameter
Imperative array build for relatedIdentifiers Simplified to ternary expression
Overlapping Zod schema + manual isValidDatasetId + startsWith("on") checks Consolidated into single Zod regex: /^on\d{6}$/
Step numbering mismatch between docstring (9 steps) and inline comments (7 steps) Aligned docstring to match implementation
No top-level try-catch in CLI command handler Added try-catch with user-friendly error message

Skipped (1 false positive)

  • CI uses npm install instead of Bun: Bun is not pre-installed on GitHub Actions ubuntu runners. npm is the correct approach for installing published npm packages in CI.

@neuromechanist
neuromechanist merged commit 6a080a8 into dev Mar 4, 2026
8 checks passed
@neuromechanist
neuromechanist deleted the feature/openneuro-import branch March 6, 2026 23:56

This branch was previously deployed

1 inactive deployment
npm — 1de5b25d Deployed Mar 4, 2026 by neuromechanist via publish #342
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