Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nxinspect crashes when cannot resolve the link to an internal field #37

Open
jkotan opened this issue Oct 16, 2024 · 0 comments
Open

nxinspect crashes when cannot resolve the link to an internal field #37

jkotan opened this issue Oct 16, 2024 · 0 comments

Comments

@jkotan
Copy link

jkotan commented Oct 16, 2024

The issue is similar to #12 but for internal links i.e. when a target of internal link is not created
nxinspect crashes e.g.

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nexusformat/nexus/tree.py", line 4529, in __getitem__
    node = node.entries[name]
           ~~~~~~~~~~~~^^^^^^
KeyError: 'target'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/nexusformat/nexus/tree.py", line 5270, in __getattr__
    return getattr(self.nxlink, name)
                   ^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nexusformat/nexus/tree.py", line 5371, in nxlink
    self._link = self.internal_link
                 ^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nexusformat/nexus/tree.py", line 5403, in internal_link
    return self.nxroot[self._target]
           ~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nexusformat/nexus/tree.py", line 4531, in __getitem__
    raise NeXusError("Invalid path")
nexusformat.nexus.tree.NeXusError: Invalid path

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/jkotan/testinst/local/bin/nxinspect", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/jkotan/testinst/local/lib/python3.11/dist-packages/nxvalidate/scripts/nxinspect.py", line 75, in main
    validate_file(filename, path=path, definitions=definitions)
  File "/home/jkotan/testinst/local/lib/python3.11/dist-packages/nxvalidate/validate.py", line 953, in validate_file
    validator.validate(path)
  File "/home/jkotan/testinst/local/lib/python3.11/dist-packages/nxvalidate/validate.py", line 926, in validate
    validator.validate(item, indent=indent)
  File "/home/jkotan/testinst/local/lib/python3.11/dist-packages/nxvalidate/validate.py", line 576, in validate
    field_validator.validate(tag, item, parent=self, indent=indent)
  File "/home/jkotan/testinst/local/lib/python3.11/dist-packages/nxvalidate/validate.py", line 840, in validate
    self.check_type(field, tag['@type'])
  File "/home/jkotan/testinst/local/lib/python3.11/dist-packages/nxvalidate/validate.py", line 613, in check_type
    if is_valid_float(field.dtype):
                      ^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/nexusformat/nexus/tree.py", line 5272, in __getattr__
    raise NeXusError(f"Cannot resolve the link to '{self._target}'")
nexusformat.nexus.tree.NeXusError: Cannot resolve the link to '/scan/sample_environment/mlz_stressihtf2_v2/He/parameters/target/value'

Instead, it would be nice to print an error, e.g. simialar one to the external links

This is a broken link to "/scan/sample_environment/mlz_stressihtf2_v2/He/parameters/target/value"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant