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

Nexus file parsing refactoring #303

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Nexus file parsing refactoring #303

wants to merge 2 commits into from

Conversation

domna
Copy link
Collaborator

@domna domna commented Mar 30, 2024

A general note on the code: It is really hard to understand what is happening in this code part and I'm not sure whether there are other problems because it's hard to get a general overview. I have a few recommendations on general refactoring:

  • Introduce an nxdl object which holds its own inheritance chain and properties (doc, requiredness, etc). From it docstrings and parent elements can be deduced at any time. This can also be easily and more consistently translated to nomad metainfo.
  • The nxdl_path then just is a list of these objects
  • Docstring generation is then a separate process of traversing these objects. This avoids the logging/path generation concurrency

nx_name=get_nxdl_entry(hdf_info),
hdf_node=hdf_node,
hdf_path=hdf_info["hdf_path"] if "hdf_path" in hdf_info else None,
hdf_root=hdf_info["hdf_root"] if "hdf_root" in hdf_info else None,
)
# Copy the nxdl_path, otherwise the cached object is altered
nxdl_path = nxdl_path.copy()
Copy link
Collaborator

Choose a reason for hiding this comment

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

also covert by another PR

self.input_file_name = (
nexus_file
if nexus_file is not None
else os.path.join(local_dir, "../../tests/data/nexus/201805_WSe2_arpes.nxs")
Copy link
Collaborator

Choose a reason for hiding this comment

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

default option is to run it as an example on the provided test file


def visit_node(self, hdf_name, hdf_node):
"""Function called by h5py that iterates on each node of hdf5file.
It allows h5py visititems function to visit nodes."""
if self.d_inq_nd is None and self.c_inq_nd is None:
process_node(hdf_node, "/" + hdf_name, self.parser, self.logger)
Copy link
Collaborator

Choose a reason for hiding this comment

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

default option is to annotate the whole file

@domna domna mentioned this pull request Apr 4, 2024
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.

2 participants