From 07d879f87a092816159623b1fe29448489cc60c5 Mon Sep 17 00:00:00 2001 From: mavaylon1 Date: Wed, 21 Aug 2024 10:21:02 -0700 Subject: [PATCH] clean up --- src/hdmf/backends/hdf5/h5_utils.py | 3 +-- src/hdmf/backends/hdf5/h5tools.py | 1 - src/hdmf/build/manager.py | 10 +++------- src/hdmf/build/objectmapper.py | 3 ++- tests/unit/test_io_hdf5_h5tools.py | 14 ++++++-------- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/hdmf/backends/hdf5/h5_utils.py b/src/hdmf/backends/hdf5/h5_utils.py index 4b00da309..8a643dab2 100644 --- a/src/hdmf/backends/hdf5/h5_utils.py +++ b/src/hdmf/backends/hdf5/h5_utils.py @@ -110,11 +110,10 @@ def shape(self): def append(self, arg): # Get Builder - builder = self.io.manager.builders[arg.object_id] + builder = self.io.manager.get_builder(arg) # Get HDF5 Reference ref = self.io._create_ref(builder) - breakpoint() append_data(self.dataset, ref) diff --git a/src/hdmf/backends/hdf5/h5tools.py b/src/hdmf/backends/hdf5/h5tools.py index 0b7ec563b..9c6cc164e 100644 --- a/src/hdmf/backends/hdf5/h5tools.py +++ b/src/hdmf/backends/hdf5/h5tools.py @@ -1513,7 +1513,6 @@ def __get_ref(self, **kwargs): else: self.logger.debug("Getting reference for %s '%s'" % (container.__class__.__name__, container.name)) builder = self.manager.build(container) - breakpoint() path = self.__get_path(builder) self.logger.debug("Getting reference at path '%s'" % path) diff --git a/src/hdmf/build/manager.py b/src/hdmf/build/manager.py index e1426b748..930429aa3 100644 --- a/src/hdmf/build/manager.py +++ b/src/hdmf/build/manager.py @@ -92,11 +92,7 @@ def __init__(self, type_map): self.__containers = dict() self.__active_builders = set() self.__type_map = type_map - self.__ref_queue = deque() # a queue of the ReferenceBuilders that need to be added - - @property - def builders(self): - return self.__builders + self.__ref_queue = deque() # a queue of the ReferenceBuilders that need to be addedq @property def namespace_catalog(self): @@ -202,7 +198,7 @@ def prebuilt(self, **kwargs): ''' Save the Builder for a given AbstractContainer for future use ''' container, builder = getargs('container', 'builder', kwargs) container_id = self.__conthash__(container) - self.__builders[container.object_id] = builder + self.__builders[container_id] = builder builder_id = self.__bldrhash__(builder) self.__containers[builder_id] = container @@ -267,7 +263,7 @@ def get_builder(self, **kwargs): """Return the prebuilt builder for the given container or None if it does not exist.""" container = getargs('container', kwargs) container_id = self.__conthash__(container) - result = self.__builders.get(container.object_id) + result = self.__builders.get(container_id) return result @docval({'name': 'builder', 'type': (DatasetBuilder, GroupBuilder), diff --git a/src/hdmf/build/objectmapper.py b/src/hdmf/build/objectmapper.py index 35f2a6613..a46260fbd 100644 --- a/src/hdmf/build/objectmapper.py +++ b/src/hdmf/build/objectmapper.py @@ -11,7 +11,8 @@ ConstructError) from .manager import Proxy, BuildManager -from .warnings import MissingRequiredBuildWarning, DtypeConversionWarning, IncorrectQuantityBuildWarning +from .warnings import (MissingRequiredBuildWarning, DtypeConversionWarning, IncorrectQuantityBuildWarning, + IncorrectDatasetShapeBuildWarning) from hdmf.backends.hdf5.h5_utils import H5DataIO from ..container import AbstractContainer, Data, DataRegion diff --git a/tests/unit/test_io_hdf5_h5tools.py b/tests/unit/test_io_hdf5_h5tools.py index 0a4ff6b24..62ddc80e9 100644 --- a/tests/unit/test_io_hdf5_h5tools.py +++ b/tests/unit/test_io_hdf5_h5tools.py @@ -2972,18 +2972,16 @@ def test_append_dataset_of_references(self): with HDF5IO(self.paths[0], manager=get_baz_buildmanager(), mode='w') as write_io: write_io.write(bucket) - with HDF5IO(self.paths[0], manager=get_baz_buildmanager(), mode='a') as read_io: - read_bucket1 = read_io.read() + with HDF5IO(self.paths[0], manager=get_baz_buildmanager(), mode='a') as append_io: + read_bucket1 = append_io.read() new_baz = Baz(name='new') read_bucket1.add_baz(new_baz) - read_io.write(read_bucket1) + append_io.write(read_bucket1) - with HDF5IO(self.paths[0], manager=get_baz_buildmanager(), mode='a') as read_io: - read_bucket1 = read_io.read() - breakpoint() + with HDF5IO(self.paths[0], manager=get_baz_buildmanager(), mode='a') as ref_io: + read_bucket1 = ref_io.read() DoR = read_bucket1.baz_data.data - DoR.append(new_baz) - read_io.write(read_bucket1) + DoR.append(read_bucket1.bazs['new']) with HDF5IO(self.paths[0], manager=get_baz_buildmanager(), mode='r') as read_io: read_bucket1 = read_io.read()