8000 Validation check for reserved prefixes and suffixes by lukaspie · Pull Request #639 · FAIRmat-NFDI/pynxtools · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Validation check for reserved prefixes and suffixes #639

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

Merged
merged 8 commits into from
May 19, 2025

Conversation

lukaspie
Copy link
Collaborator

NeXus defines reserved prefixes and suffixes that may only be used in a certain context.

Here, we implement checks for both prefixes and suffixes:

  • prefixes: these can only be used within a certain context (e.g. DECTRIS_ prefix is only valid for attributes in DECTRIS detectors, i.e., in NXmx). Any other use is prohibited. We check the context and log an error if such attributes exist out of context. Note that for some reserved prefixes, we can not write them from pynxtools, so their use is disallowed. We still write these attributes as undocumented, though (could be removed).
  • suffixes: These are already explicitly defined in NeXus (mostly in NXobject, but also in NXdata and NXtransformations). Note that you can use these suffixes freely outside of their scope (e.g. you can use FIELDNAME_end) anyway you like if you are not within NXtransformations. Here, we basically check that if a reserved suffix is used, the initial field also exists (e.g. if we define a field my_field_weights, we check that my_field exists as well.

@lukaspie lukaspie force-pushed the reserved-prefixes-suffixes branch from b600071 to 8afb8e6 Compare May 15, 2025 16:14
@lukaspie lukaspie linked an issue May 15, 2025 that may be closed by this pull request
1 task
Copy link
Collaborator
@rettigl rettigl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't completely oversee how this is intended to work, but generally looks reasonable to me apart from a few questions

@lukaspie
Copy link
Collaborator Author

@rettigl fixed most of what you were suggesting.

Before, I was also missing that fields with reserved suffixes must be written as e.g. FIELDNAME_weights[my_field_weights]. This makes the checking of associated fields more complicated, due to the concept name and brackets. Basically, I check that a key that starts with the same parent path and that either ends on my_field or [my_fiel 8000 d] exists. A bit clunky, but seems to work for now.

Copy link
Collaborator
@rettigl rettigl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now, apart from remaining debug code

@lukaspie lukaspie merged commit f50a827 into master May 19, 2025
17 checks passed
@lukaspie lukaspie deleted the reserved-prefixes-suffixes branch May 19, 2025 12:31
@lukaspie lukaspie mentioned this pull request May 20, 2025
4 tasks
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

Successfully merging this pull request may close these issues.

support NeXus reserved prefixes and suffixes
2 participants
0