feat(config_io): template-overlay export + UI sidecar#3
Merged
Conversation
Fixes the two remaining blockers that prevent the UI's export from being a drop-in stac-mjx config. 1. Template overlay. load_stac_yaml now returns `_rawTemplate` — the full parsed YAML. dump_stac_yaml uses it to overlay UI edits onto the original, preserving its shape (flat vs wrapped) and every field the UI does not manage (N_ITERS, ROOT_OPTIMIZATION_KEYPOINT, TRUNK_OPTIMIZATION_KEYPOINTS, SITES_TO_REGULARIZE, ...). Without a template, dump falls back to the wrapped UI-internal format. 2. Skeleton editor sidecar. `skeleton_editor:` no longer leaks into the main export — it moves to a separate download (`*.ui.yaml`) via a new /api/export-ui-sidecar endpoint that returns 204 when empty. Store gains a persisted `rawTemplate` field; Toolbar export now triggers both downloads in parallel and only emits the sidecar when non-default. Confirmed end-to-end: loading stac-mjx/configs/model/rodent.yaml, reassigning Snout, and re-exporting produces a file that compose_config() accepts and loads with all non-UI fields preserved.
4893759 to
f90f5df
Compare
4 tasks
When exporting after loading a config but before loading mocap data, the UI sends empty kpNames (and similar empty fields) that overwrote the template's populated KP_NAMES list. Now empty UI values are skipped if the template has a populated value at that key. Repro: load data/stac_rodent_acm.yaml, export without loading .mat — before: KP_NAMES: [] after: KP_NAMES preserved from template (21 entries)
Collaborator
Author
|
Double-checked with another model, merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the two remaining blockers that prevent the UI's export from being a drop-in
stac-mjxconfig.Template overlay.
load_stac_yamlnow returns_rawTemplate— the full parsed YAML.dump_stac_yamluses it to overlay UI edits onto the original, preserving its shape (flat vs wrapped) and every field the UI doesn't manage (N_ITERS,ROOT_OPTIMIZATION_KEYPOINT,TRUNK_OPTIMIZATION_KEYPOINTS,SITES_TO_REGULARIZE, ...). Without a template, dump falls back to the wrapped UI-internal format.Skeleton editor sidecar.
skeleton_editor:no longer leaks into the main export — it moves to a separate download (*.ui.yaml) via a new/api/export-ui-sidecarendpoint that returns 204 when there's nothing to save.Store gains a persisted
rawTemplatefield; Toolbar export triggers both downloads in parallel and only emits the sidecar when non-default.Why this matters
Before this change, exporting the UI state produced a YAML that
stac-mjxrejected with eitherConfigKeyError: Key 'skeleton_editor' not in 'Config'orConfigKeyError: Key 'model' not in 'ModelConfig', plus a dozen missing required fields. Now: loadconfigs/model/rodent.yaml, reassign a keypoint in the UI, re-export, drop it back intostac-mjx/configs/model/—compose_config()loads it cleanly with the UI edits applied and every other field preserved.Test plan
pytest tests/test_config_io.py— 10/10 pass_rawTemplateround-trip, flat-template overlay, wrapped-template overlay, skeleton_editor stripped from main export, no-template falls back to wrapped, sidecar None when default, sidecar emits non-defaultpytest tests/test_app.py—/api/healthstill passestsc --noEmitcleanTestClienthits/api/export-ui-sidecar(204 empty, 200 populated) and/api/export-config(template preserved, overlay applied)stac-mjx/configs/model/rodent.yaml, edit mappings, export, feed tostac_mjx.config.compose_config— loads successfully,N_ITERS=6,ROOT_OPTIMIZATION_KEYPOINT=SpineL, user edits appliedOut of scope
MJCF_PATHportability (still uses whateverxmlPaththe server returned from/api/load-xml)