Conversation
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
One attach-time namespace case is still missing: the restored contact sensor declares site as a plain reference. MuJoCo’s generated dm_control schema uses type="reference" reference_namespace="site". Without that namespace, attaching a child model with a contact sensor configured by site leaves the child site name unprefixed and can fail compilation, the same class of regression this PR fixes for jointinparent. Please restore reference_namespace="site" and add an attach regression for the site-based contact sensor path.
|
Made the change in The change is right. The stated consequence does not reproduce. other_kwargs['reference_namespace'] = (
attribute_xml.get('reference_namespace') or name)An absent
So it does not fail compilation, and an attach regression for it passes with the bug present. I wrote the test you asked for first and it passed against the unfixed schema, which is the only reason I went looking for why. What I added instead asserts the invariant that can actually break: no attribute of The fallback is also why this was easy to miss when the element was restored, and why the file-level assertion seemed worth more than a per-attribute one. |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Rechecked de77a71f. You are right that the attach-time symptom I described is masked when the attribute name and fallback namespace are both site. Restoring the explicit namespace is still correct, and the file-level invariant that every reference declares its namespace is a stronger regression for this regeneration class. No remaining blocker from me.
…ration d2cf3a3 restored all three declarations this PR was opened to fix. The sensor contact element is back with the same 18 attributes, jointinparent carries reference_namespace="joint" on all nine actuators again, and custom/numeric data is an array of float again. The schema change here is therefore dropped, and what remains is the regression coverage, which nothing upstream added. The three declarations were lost once already and were restored by a regeneration rather than by a guard, so the same regeneration can drop them again. Each test asserts the behavior a user loses, not the text of the file: - a contact sensor parses and compiles, and its geom1 reference resolves - jointinparent is scoped to the child model on attach - custom/numeric accepts array data - no attribute of type="reference" omits its namespace The last one is the file-level invariant. schema.py falls back to the attribute's own name when reference_namespace is absent, so a dropped namespace is invisible wherever the two coincide and silently wrong where they do not. Asserting on the file catches the loss in both cases. Verified against the mutation each test is meant to catch. Reverting the contact element, jointinparent and numeric data on top of current main fails the first three. Stripping one reference_namespace fails the fourth with ['site'] has length of 1. dm_control/mjcf: 158 passed.
de77a71 to
b89132a
Compare
|
Rebased onto current main and cut this down to the tests. d2cf3a3 already restored all three declarations. The sensor Worth noting why it is dropped rather than left in. Upstream added its What is left is four tests. Three cover the declarations that were lost. The fourth asserts that no attribute of Each one is checked against the mutation it exists to catch, on top of current main:
Head is b89132a. Happy to close this instead if the generator is the intended home for the guard, but the three declarations came back through a regeneration rather than a check, so the next one can drop them again. |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
Rechecked current b89132a. The PR is now reduced to regression coverage only because current main already restored the three schema declarations. The four tests cover the contact sensor, jointinparent attach scoping, numeric array data, and the file-level invariant that every reference declares a namespace. That is a cleaner guard against future regeneration loss than carrying redundant schema edits. No blocker from me.
Fixes #552.
Superseded in part by d2cf3a3, which regenerated
schema.xmland restored all three declarations this PR was opened to fix. Rebased onto current main and reduced to the regression coverage, which nothing upstream added.Checked against main at 3e9cd0b:
sensorhas itscontactchild again, with the same 18 attributes the original hunk restored (verified as sorted attribute sets, identical).jointinparentcarriestype="reference" reference_namespace="joint"on all nine actuator elements again.custom/numericdataistype="array" array_type="float"again.Keeping the original schema hunk on top of that would have added a second
<element name="contact" repeated="true" namespace="sensor">to the same parent, shadowing the generated one. The suite still passed with the duplicate present, which is the argument for the tests rather than against them.What remains is four tests in
schema_test.py. Each asserts the behavior a user loses, not the text of the file:geom1reference resolvesjointinparentis scoped to the child model onattach()custom/numericaccepts array datatype="reference"omits itsreference_namespaceThe last one is the file-level invariant.
schema.py:152-153falls back to the attribute's own name whenreference_namespaceis absent, so a dropped namespace is invisible wherever the two coincide and silently wrong where they do not. Asserting on the file catches the loss in both cases.These three declarations were lost once and came back through a regeneration rather than a guard, so the next regeneration can drop them again. That is what the tests are for.
Verification, against the mutation each test is meant to catch:
dm_control/mjcf158 passed,schema_test.py4 passed.schema_test.py8 passed.jointinparentandnumericdataon top of current main: 3 failed, 5 passed.reference_namespace: fails with['site'] has length of 1.