Skip to content

Commit

Permalink
Fixes the case where the reader sends back a template entry with the …
Browse files Browse the repository at this point in the history
…concept name included
  • Loading branch information
sherjeelshabih committed Jan 18, 2024
1 parent faa2792 commit 7514c1d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pynxtools/dataconverter/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,14 @@ def is_valid_data_field(value, nxdl_type, path):
return value


def path_in_data_dict(nxdl_path: str, data: dict) -> Tuple[bool, str]:
def path_in_data_dict(nxdl_path: str, hdf_path: str, data: dict) -> Tuple[bool, str]:
"""Checks if there is an accepted variation of path in the dictionary & returns the path."""
accepted_unfilled_key = None
for key in data.keys():
if nxdl_path == convert_data_converter_dict_to_nxdl_path(key):
if (
nxdl_path == convert_data_converter_dict_to_nxdl_path(key)
or convert_data_dict_path_to_hdf5_path(key) == hdf_path
):
if data[key] is None:
accepted_unfilled_key = key
continue
Expand Down Expand Up @@ -438,7 +441,12 @@ def all_required_children_are_set(optional_parent_path, data, nxdl_root):
if (
nxdl_key[0 : nxdl_key.rfind("/")] == optional_parent_path
and is_node_required(nxdl_key, nxdl_root)
and data[path_in_data_dict(nxdl_key, data)[1]] is None
and data[
path_in_data_dict(
nxdl_key, convert_data_dict_path_to_hdf5_path(key), data
)[1]
]
is None
):
return False

Expand Down Expand Up @@ -500,7 +508,9 @@ def ensure_all_required_fields_exist(template, data, nxdl_root, logger=pynx_logg
if entry_name == "@units":
continue
nxdl_path = convert_data_converter_dict_to_nxdl_path(path)
is_path_in_data_dict, renamed_path = path_in_data_dict(nxdl_path, data)
is_path_in_data_dict, renamed_path = path_in_data_dict(
nxdl_path, convert_data_dict_path_to_hdf5_path(path), data
)

renamed_path = path if renamed_path is None else renamed_path
if path in template["lone_groups"]:
Expand Down

0 comments on commit 7514c1d

Please sign in to comment.