m_to_dict is not always reversible
I'm trying to fetch some classes from NOMAD and dump them in a yaml or json file that could be successfully processed when dropped again in NOMAD.
Using the m_to_dict function leads to a dict with several problems:
-
some m_annotations are missing an "a_" and this leads to errors in processing
-
in m_annotation>eln>component we get the following string strrting with "!" and this leads to errors in processing
m_annotations:
eln:
- component: !!python/object/apply:nomad.datamodel.metainfo.annotations.ELNComponentEnum
- StringEditQuantity
-
if I use the flag
resolve_references=True
, NOMAD will not be able to process the resolved inherited classes nested in thebase_sections
-
if I use the flag
resolve_references=False
, NOMAD will not be able to process the strings- /definitions/section_definitions/0
This is the lines I use to generate my definition that I will then dump in a json or yaml:
test = EntryArchive(
definitions=Package(
section_definitions=[
AFMresults.m_def,
AFMmeasurement.m_def,]
)
).m_to_dict(with_out_meta=True,
with_root_def=True,
resolve_references=False,
)