From 5373c7cab844b0a7942edfdad2d814c21cc4a56a Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Sat, 13 Jul 2024 11:34:39 -0700 Subject: [PATCH] clear --- src/hdmf_zarr/backend.py | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/hdmf_zarr/backend.py b/src/hdmf_zarr/backend.py index b88e201..4c02ac1 100644 --- a/src/hdmf_zarr/backend.py +++ b/src/hdmf_zarr/backend.py @@ -771,21 +771,18 @@ def __get_ref(self, ref_object, export_source=None): # determine the object_id of the source by following the parents of the builder until we find the root # the root builder should be the same as the source file containing the reference - if source_file is not None: - source_object_id = source_file.object_id + curr = builder + while curr is not None and curr.name != ROOT_NAME: + curr = curr.parent + if curr: + source_object_id = curr.get('object_id', None) + # We did not find ROOT_NAME as a parent. This should only happen if we have an invalid + # file as a source, e.g., if during testing we use an arbitrary builder. We check this + # anyways to avoid potential errors just in case else: - curr = builder - while curr is not None and curr.name != ROOT_NAME: - curr = curr.parent - if curr: - source_object_id = curr.get('object_id', None) - # We did not find ROOT_NAME as a parent. This should only happen if we have an invalid - # file as a source, e.g., if during testing we use an arbitrary builder. We check this - # anyways to avoid potential errors just in case - else: - source_object_id = None - warn_msg = "Could not determine source_object_id for builder with path: %s" % path - warnings.warn(warn_msg) + source_object_id = None + warn_msg = "Could not determine source_object_id for builder with path: %s" % path + warnings.warn(warn_msg) # by checking os.isdir makes sure we have a valid link path to a dir for Zarr. For conversion # between backends a user should always use export which takes care of creating a clean set of builders.