hdmf.backends.io module

class hdmf.backends.io.HDMFIO(manager=None, source=None, herd_path=None)

Bases: object

  • manager (BuildManager) – the BuildManager to use for I/O

  • source (str or Path) – the source of container being built i.e. file path

  • herd_path (str) – The path to read/write the HERD file

abstract static can_read(path)

Determines whether a given path is readable by this HDMFIO class

property manager

The BuildManager this instance is using

property source

The source of the container being read/written i.e. file path


Read a container from the IO source.


the Container object that was read in

Return type:


write(container, herd=None)
  • container (Container) – the Container object to write

  • herd (HERD) – A HERD object to populate with references.

export(src_io, container=None, write_args={}, clear_cache=False)

Export from one backend to the backend represented by this class.

If container is provided, then the build manager of src_io is used to build the container, and the resulting builder will be exported to the new backend. So if container is provided, src_io must have a non-None manager property. If container is None, then the contents of src_io will be read and exported to the new backend.

The provided container must be the root of the hierarchy of the source used to read the container (i.e., you cannot read a file and export a part of that file.

Arguments can be passed in for the write_builder method using write_args. Some arguments may not be supported during export.

Example usage:

old_io = HDF5IO('old.nwb', 'r')
with HDF5IO('new_copy.nwb', 'w') as new_io:
NOTE: When implementing export support on custom backends. Export does not update the Builder.source

on the Builders. As such, when writing LinkBuilders we need to determine if LinkBuilder.source and LinkBuilder.builder.source are the same, and if so the link should be internal to the current file (even if the Builder.source points to a different location).

  • src_io (HDMFIO) – the HDMFIO object for reading the data to export

  • container (Container) – the Container object to export. If None, then the entire contents of the HDMFIO object will be exported

  • write_args (dict) – arguments to pass to write_builder

  • clear_cache (bool) – whether to clear the build manager cache

abstract read_builder()

Read data and return the GroupBuilder representing it


a GroupBuilder representing the read data

Return type:


abstract write_builder(builder)

Write a GroupBuilder representing an Container object


builder (GroupBuilder) – the GroupBuilder object representing the Container

abstract open()

Open this HDMFIO object for writing of the builder

abstract close()

Close this HDMFIO object to further reading/writing