Skip to content

Resolve "Parsing nexus files generates a lot of warnings and errors"

Fixed some problems of #1934

  • I fixed a bug in the attribute generation. Basically some attributes were missing. But this only solved a small portion of the problems.
  • I fixed a bug in the MetainforNormalizer which tried to call things called "normalize" in the schema, but where not actually normalize functions.
  • I fixed the error handling a bit to better see what is actually causing the problems.

The first error type mentioned in #1934

This is fixed with the MetainforNormalizer fix.

The second error type mentioned in #1934

These are a few separate issues repeating. They are reported while setting an attribute, but they are caused because the parser could not find the quantity or section to put the attribute on. Therefore, they do not seem to be attribute problems. They are indicating a few mapping problems that I cannot resolve!

  • string unit in nxdl_path, where the parser only expects instances of ET.Element. This maybe is a problem in pynxtools.nexus.HandleNexus which produces all the nxdl_path.
WARNING  nomad.client         2024-03-14T13:46:17 Error while setting attribute.
  - exception: Traceback (most recent call last):
      File "/Users/markus/Documents/Projects/nomad-fairdi/nomad/parsing/nexus/nexus.py", line 167, in _populate_data
        assert isinstance(
    AssertionError: nx_path is not a list of ET.Element, one segment is "units:<class 'str'>"
  • The parsre tries to set version__attribute to nexus.NXentry.COLLECTION:SubSection, but the nexus mapping does not define attributes on sub sections, I guess this is supposed to go to the section that the sub-section points to?
WARNING  nomad.client         2024-03-14T13:46:17 Error while setting attribute.
  - exception: Traceback (most recent call last):
      File "/Users/markus/Documents/Projects/nomad-fairdi/nomad/parsing/nexus/nexus.py", line 194, in _populate_data
        assert isinstance(
    AssertionError: nexus.NXentry.COLLECTION:SubSection is not a Quantity
  • nexus.NXelectronanalyser.NXtransformations has no suitable quantity for depends_on__field
WARNING  nomad.client         2024-03-14T13:46:18 Error while setting attribute.
  - exception: Traceback (most recent call last):
      File "/Users/markus/Documents/Projects/nomad-fairdi/nomad/parsing/nexus/nexus.py", line 182, in _populate_data
        assert metainfo_def, f'{current.m_def} has no suitable property for {parent_field_name}'
    AssertionError: nexus.NXelectronanalyser.NXtransformations:Section has no suitable property for depends_on__field
  • nexus.NXelectronanalyser.NXtransformations has no suitable quantity for transformation_type__field
WARNING  nomad.client         2024-03-14T13:46:18 Error while setting attribute.
  - exception: Traceback (most recent call last):
      File "/Users/markus/Documents/Projects/nomad-fairdi/nomad/parsing/nexus/nexus.py", line 182, in _populate_data
        assert metainfo_def, f'{current.m_def} has no suitable property for {parent_field_name}'
    AssertionError: nexus.NXelectronanalyser.NXtransformations:Section has no suitable property for transformation_type__field

Then there are a few less frequent things:

  • The value "HHG laser" is not an enum value for nexus.NXsource.type__field.
  • NaN value is not set for field on size__field[size__field]

The third error mentioned in #1934

These errors are caused because we try to interpret enum values as floats. This is all for this nexus.NXtransformations.AXISNAME__field, which is defined as a float in the schema. I guess it should not be a float?

Edited by Markus Scheidgen

Merge request reports