h5rdmtoolbox.layout.core.Layout
h5rdmtoolbox.layout.core.Layout#
- class h5rdmtoolbox.layout.core.Layout(description='')[source]#
A layout is a collection of specifications that can be applied to an HDF5 file or group.
The class is inherited from LayoutSpecification. Some methods are overwritten.
Examples
>>> from h5rdmtoolbox import layout >>> lay = layout.Layout() >>> spec_all_dataset = lay.__set_meta_field__( >>> hdfdb.FileDB.find, # query function >>> flt={}, >>> objfilter='dataset' >>> ) >>> >>> # all datasets must be compressed with gzip (conditional spec. only called if parent spec is successful) >>> spec_compression = spec_all_dataset.__set_meta_field__( >>> hdfdb.FileDB.find_one, # query function >>> flt={'$compression': 'gzip'} # query parameter >>> ) >>> >>> # the file must have the dataset "/u" >>> spec_ds_u = lay.__set_meta_field__( >>> hdfdb.FileDB.find, # query function >>> flt={'$name': '/u'}, >>> objfilter='dataset' >>> ) >>> lay.validate('path/to/file.h5')
Methods
__init__([description])add(func, *[, n, rebase, description])Add a specification by providing a callable query obj.
add_alternative(func, *, n[, description])Add an alternative specification by providing a callable query obj.
get_failed()Return a list of failed specifications
get_summary([exclude_keys])return a summary as dictionary
get_valid()Return all successful specifications
is_valid()Return True if all specifications are valid.
reset()Reset the specification and all its children
validate(filename_or_root_group)Validate the layout by passing a filename or an opened root group
Attributes
calledReturn True if the specification has been called at least once.
failedReturn True if the specification failed
n_callsReturn number of calls
n_failsReturn number of failed calls
n_successesReturn number of successful calls
validation_flag