Skip to content

Commit

Permalink
Improve ObjectMapper and fix related issues (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
rly committed Nov 16, 2020
1 parent 66b9496 commit b12a62b
Show file tree
Hide file tree
Showing 16 changed files with 1,589 additions and 267 deletions.
20 changes: 13 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
# HDMF Changelog

## HDMF 2.3.0 (Upcoming)
## HDMF 3.0.0 (Upcoming)

### Breaking changes
- Drop support for Python 3.5. @ajtritt (#459)
- Remove `hdmf.get_region_slicer` function. @ajtritt (#442)
- Remove unused or refactored internal builder functions `GroupBuilder.add_group`, `GroupBuilder.add_dataset`,
`GroupBuilder.add_link`, `GroupBuilder.set_builder`, `BaseBuilder.deep_update`, `GroupBuilder.deep_update`,
`DatasetBuilder.deep_update`. Make `BaseBuilder` not instantiable and refactor builder code. @rly (#452)
- Remove `hdmf.build.map.py`. Classes formerly in this file should be imported from `hdmf.build` instead. @rly (#463)
- Replace `MissingRequiredWarning` with `MissingRequiredBuildWarning`. @rly (#463)

### New features
- Drop support for Python 3.5. Add testing for Python 3.9. @ajtritt (#459)
- Add methods for automatic creation of `MultiContainerInterface` classes. @bendichter (#420, #425)
- Add ability to specify a custom class for new columns to a `DynamicTable` that are not `VectorData`,
`DynamicTableRegion`, or `VocabData` using `DynamicTable.__columns__` or `DynamicTable.add_column(...)`. @rly (#436)
- Add support for creating and specifying multi-index columns in a `DynamicTable` using `add_column(...)`.
@bendichter, @rly (#430)
- Add capability to add a row to a column after IO. @bendichter (#426)
- Add functionality for storing external resource references @ajtritt (#442)
- Add functionality for storing external resource references. @ajtritt (#442)
- Add method `hdmf.utils.get_docval_macro` to get a tuple of the current values for a docval_macro, e.g., 'array_data'
and 'scalar_data'. @rly (#446)
- Add SimpleMultiContainer, a data_type for storing a Container and Data objects together. @ajtritt (#449)
- Add `SimpleMultiContainer`, a data_type for storing a `Container` and `Data` objects together. @ajtritt (#449)
- Support `pathlib.Path` paths in `HDMFIO.__init__`, `HDF5IO.__init__`, and `HDF5IO.load_namespaces`. @dsleiter (#439)
- Use hdmf-common-schema 1.2.1. See https://hdmf-common-schema.readthedocs.io/en/latest/format_release_notes.html for details.
- Block usage of h5py 3+. h5py>=2.9, <3 is supported. @rly (#461)
Expand All @@ -22,9 +30,7 @@
### Internal improvements
- Refactor `HDF5IO.write_dataset` to be more readable. @rly (#428)
- Fix bug in slicing tables with DynamicTableRegions. @ajtritt (#449)
- Remove unused or refactored internal builder functions `GroupBuilder.add_group`, `GroupBuilder.add_dataset`,
`GroupBuilder.add_link`, `GroupBuilder.set_builder`, `BaseBuilder.deep_update`, `GroupBuilder.deep_update`,
`DatasetBuilder.deep_update`. Make `BaseBuilder` not instantiable and refactor builder code. @rly (#452)
- Add testing for Python 3.9. @ajtritt (#459)

### Bug fixes
- Fix development package dependency issues. @rly (#431)
Expand Down
5 changes: 3 additions & 2 deletions src/hdmf/build/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
from .manager import BuildManager
from .manager import TypeMap

from .warnings import MissingRequiredWarning, OrphanContainerWarning, DtypeConversionWarning
from .errors import BuildError, OrphanContainerBuildError, ReferenceTargetNotBuiltError
from .warnings import BuildWarning, MissingRequiredBuildWarning, DtypeConversionWarning, IncorrectQuantityBuildWarning
from .errors import (BuildError, OrphanContainerBuildError, ReferenceTargetNotBuiltError, ContainerConfigurationError,
ConstructError)
10 changes: 10 additions & 0 deletions src/hdmf/build/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@


class BuildError(Exception):
"""Error raised when building a container into a builder."""

@docval({'name': 'builder', 'type': Builder, 'doc': 'the builder that cannot be built'},
{'name': 'reason', 'type': str, 'doc': 'the reason for the error'})
Expand Down Expand Up @@ -36,3 +37,12 @@ def __init__(self, **kwargs):
reason = ("Could not find already-built Builder for %s '%s' in BuildManager"
% (self.__container.__class__.__name__, self.__container.name))
super().__init__(builder=builder, reason=reason)


class ContainerConfigurationError(Exception):
"""Error raised when the container class is improperly configured."""
pass


class ConstructError(Exception):
"""Error raised when constructing a container from a builder."""
13 changes: 9 additions & 4 deletions src/hdmf/build/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,17 +347,22 @@ def get_builder_dt(self, **kwargs):
builder = getargs('builder', kwargs)
return self.__type_map.get_builder_dt(builder)

@docval({'name': 'builder', 'type': (GroupBuilder, DatasetBuilder), 'doc': 'the builder to check'},
{'name': 'parent_data_type', 'type': (str, type), 'doc': 'the potential parent data_type'},
@docval({'name': 'builder', 'type': (GroupBuilder, DatasetBuilder, AbstractContainer),
'doc': 'the builder or container to check'},
{'name': 'parent_data_type', 'type': str,
'doc': 'the potential parent data_type that refers to a data_type'},
returns="True if data_type of *builder* is a sub-data_type of *parent_data_type*, False otherwise",
rtype=bool)
def is_sub_data_type(self, **kwargs):
'''
Return whether or not data_type of *builder* is a sub-data_type of *parent_data_type*
'''
builder, parent_dt = getargs('builder', 'parent_data_type', kwargs)
dt = self.get_builder_dt(builder)
ns = self.get_builder_ns(builder)
if isinstance(builder, (GroupBuilder, DatasetBuilder)):
ns = self.get_builder_ns(builder)
dt = self.get_builder_dt(builder)
else: # builder is an AbstractContainer
ns, dt = self.type_map.get_container_ns_dt(builder)
return self.namespace_catalog.is_sub_data_type(ns, dt, parent_dt)


Expand Down
7 changes: 0 additions & 7 deletions src/hdmf/build/map.py

This file was deleted.

0 comments on commit b12a62b

Please sign in to comment.