modelrunner.storage.backend package

class HDFStorage(file_or_path, *, mode='read', compression=True)[source]

Bases: StorageBase

storage that stores data in an HDF file

Parameters:
  • file_or_path (str or Path or Store) – File path to the file/folder or a zarr Store

  • mode (str or AccessMode) – The file mode with which the storage is accessed. Determines allowed operations.

  • compression (bool) – Whether to store the data in compressed form. Automatically enabled chunked storage.

close()[source]

closes the storage, potentially writing data to a persistent place

Return type:

None

extensions: list[str] = ['h5', 'hdf', 'hdf5']

all file extensions supported by this storage

Type:

list of str

is_group(loc)[source]

determine whether the location is a group

Parameters:

loc (sequence of str) – A list of strings determining the location in the storage

Returns:

True if the loation is a group

Return type:

bool

keys(loc=None)[source]

return all sub-items defined at a given location

Parameters:

loc (sequence of str) – A list of strings determining the location in the storage

Returns:

a list of all items defined at this location

Return type:

list

mode: AccessMode

access mode

Type:

AccessMode

class JSONStorage(path, *, mode='read', simplify=True, **kwargs)[source]

Bases: TextStorageBase

storage that stores data in a JSON text file

Note that the data is only written once the storage is closed.

Parameters:
  • path (str or Path) – File path to the file

  • mode (str or AccessMode) – The file mode with which the storage is accessed. Determines allowed operations.

  • simplify (bool) – Flag indicating whether the data is stored in a simplified form

extensions: list[str] = ['json']

all file extensions supported by this storage

Type:

list of str

class MemoryStorage(*, mode='insert')[source]

Bases: StorageBase

store items in memory

Parameters:

mode (str or AccessMode) – The file mode with which the storage is accessed. Determines allowed operations.

clear()[source]

truncate the storage by removing all stored data.

Parameters:

clear_data_shape (bool) – Flag determining whether the data shape is also deleted.

Return type:

None

is_group(loc)[source]

determine whether the location is a group

Parameters:

loc (sequence of str) – A list of strings determining the location in the storage

Returns:

True if the loation is a group

Return type:

bool

keys(loc)[source]

return all sub-items defined at a given location

Parameters:

loc (sequence of str) – A list of strings determining the location in the storage

Returns:

a list of all items defined at this location

Return type:

list

class YAMLStorage(path, *, mode='read', simplify=True, **kwargs)[source]

Bases: TextStorageBase

storage that stores data in a YAML text file

Note that the data is only written once the storage is closed.

Parameters:
  • path (str or Path) – File path to the file

  • mode (str or AccessMode) – The file mode with which the storage is accessed. Determines allowed operations.

  • simplify (bool) – Flag indicating whether the data is stored in a simplified form

encode_internal_attrs = True
extensions: list[str] = ['yaml', 'yml']

all file extensions supported by this storage

Type:

list of str

class ZarrStorage(store_or_path, *, mode='read')[source]

Bases: StorageBase

storage that stores data in an zarr file or database

Parameters:
  • store_or_path (str or Path or Store) – File path to the file/folder or a zarr Store

  • mode (str or AccessMode) – The file mode with which the storage is accessed. Determines allowed operations.

property can_update: bool

indicates whether the storage supports updating items

Type:

bool

close()[source]

closes the storage, potentially writing data to a persistent place

Return type:

None

extensions: list[str] = ['zarr', 'zip', 'sqldb', 'lmdb']

all file extensions supported by this storage

Type:

list of str

is_group(loc, *, ignore_cls=False)[source]

determine whether the location is a group

Parameters:
  • loc (sequence of str) – A list of strings determining the location in the storage

  • ignore_cls (bool) –

Returns:

True if the loation is a group

Return type:

bool

keys(loc=None)[source]

return all sub-items defined at a given location

Parameters:

loc (sequence of str) – A list of strings determining the location in the storage

Returns:

a list of all items defined at this location

Return type:

list

mode: AccessMode

access mode

Type:

AccessMode