schema editor `merge_schemas` modifies input schemas
Closed this issue · 0 comments
braingram commented
Calling merge_schemas
modifies the inputs. A minimal example is as follows:
import stdatamodels.jwst.datamodels.schema_editor
s0 = {'title': 'a'}
s1 = {'title': 'b'}
merged = stdatamodels.jwst.datamodels.schema_editor.Keyword_db.merge_schemas(None, [s0, s1])
assert merged['title'] == 'b'
assert s1['title'] == 'b'
assert s0['title'] == 'b'
This creates an issue during combining the keywords into a schema:
stdatamodels/src/stdatamodels/jwst/datamodels/schema_editor.py
Lines 985 to 987 in 15e5ae6
The call to
create_dict
(which calls merge_schemas
) modifies the schema created from the keyword files. This can be seen by stepping through the above code in pdb.After line 985 the following is False
'subpixel_number' in keyword_db.schema['properties']['meta']['properties']['dither']['properties']['allOf'][0]
After line 986 the above is True as the first item was modified by a call to merge_schemas
.