Skip to content

feat(export): portable MJCF_PATH + pre-export validation#5

Merged
HugoFara merged 1 commit into
talmolab:mainfrom
HugoFara:feat-export-trustworthy
Apr 22, 2026
Merged

feat(export): portable MJCF_PATH + pre-export validation#5
HugoFara merged 1 commit into
talmolab:mainfrom
HugoFara:feat-export-trustworthy

Conversation

@HugoFara

Copy link
Copy Markdown
Collaborator

Summary

Two loose ends from the export audit:

1. Portable MJCF_PATH. Uploaded XMLs were writing /tmp/tmpXXX.xml into the exported YAML, which is unusable to anyone else. _portable_mjcf now prefers xmlBasename (the original upload filename, passed through from the frontend via setXmlData) and falls back to reducing any absolute path to models/<basename> — the stac-mjx convention across configs/model/*.yaml. Relative paths pass through unchanged.

2. Pre-export validation. New frontend/src/validation.ts reports two classes of issue on export:

  • Errors (block the export): a mapping whose body isn't in the loaded model.
  • Warnings (go through but summarized in the status message): an unmapped keypoint in the dataset, or a mapping for a keypoint not in the currently loaded dataset.

Test plan

  • pytest --ignore=tests/test_acm_processing.py → 11/11 pass, including 5 new tests for _portable_mjcf and end-to-end use through dump_stac_yaml
  • npm run build clean (tsc + vite build)
  • Integration: TestClient.post('/api/export-config') with xmlBasename set produces MJCF_PATH: models/<basename>
  • Manual sanity: upload XML via "Load XML" button, export, confirm MJCF_PATH is models/<original_filename> rather than a /tmp/ path

Interaction with #3

Independent of PR #3 (template overlay). If #3 merges first, this one needs a trivial rebase to move the _portable_mjcf(config) call into _ui_managed_fields (the place #3 factored the canonical model fields into). If this merges first, #3 picks up the same wrapping automatically. Happy to rebase whichever lands second.

@HugoFara HugoFara added the bug Something isn't working label Apr 21, 2026
Two loose ends from the export audit:

Portable MJCF_PATH. Uploaded XMLs were writing /tmp/tmpXXX.xml into
exports, unusable anywhere else. _portable_mjcf now prefers xmlBasename
(the original upload filename, passed through from the frontend) and
falls back to reducing any absolute path to models/<basename> — the
stac-mjx convention. Relative paths pass through unchanged.

Pre-export validation. validateMappings reports two classes of issue:
errors (mapping to a body not in the loaded model) that block the
export, and warnings (unmapped keypoint, mapping for a keypoint not in
the dataset) that go through but are summarized in the status message.
@HugoFara HugoFara force-pushed the feat-export-trustworthy branch from 63040d3 to f5ba971 Compare April 22, 2026 21:31
@HugoFara

Copy link
Copy Markdown
Collaborator Author

Merging #5 after review of #3.

@HugoFara HugoFara merged commit b399e66 into talmolab:main Apr 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant