From 7514c1dc315b706fce4ee924a93c935cc7495977 Mon Sep 17 00:00:00 2001 From: Sherjeel Shabih Date: Thu, 18 Jan 2024 11:39:54 +0100 Subject: [PATCH] Fixes the case where the reader sends back a template entry with the concept name included --- pynxtools/dataconverter/helpers.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/pynxtools/dataconverter/helpers.py b/pynxtools/dataconverter/helpers.py index 8a6842788..377f4f12e 100644 --- a/pynxtools/dataconverter/helpers.py +++ b/pynxtools/dataconverter/helpers.py @@ -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 @@ -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 @@ -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"]: