vis4d.data.io.base

Backends for the data types a dataset of interest is saved in.

Those can be used to load data from diverse storage backends, e.g. from HDF5 files which are more suitable for data centers. The naive backend is the FileBackend, which loads from / saves to file naively.

Classes

DataBackend()

Abstract class of storage backends.

class DataBackend[source]

Abstract class of storage backends.

All backends need to implement three functions: get(), set() and exists(). get() reads the file as a byte stream and set() writes a byte stream to a file. exists() checks if a certain filepath exists.

abstract close()[source]

Close all opened files in the backend.

Return type:

None

abstract exists(filepath)[source]

Check if filepath exists.

Parameters:

filepath (str) – The filepath to check.

Returns:

True if the filepath exists, False otherwise.

Return type:

bool

abstract get(filepath)[source]

Get the file content at the given filepath as bytes.

Parameters:

filepath (str) – The filepath to retrieve the data from.”

Returns:

The content of the file as bytes.

Return type:

bytes

abstract isfile(filepath)[source]

Check if filepath is a file.

Parameters:

filepath (str) – The filepath to check.

Returns:

True if the filepath is a file, False otherwise.

Return type:

bool

abstract listdir(filepath)[source]

List all files in a directory.

Parameters:

filepath (str) – The directory to list.

Returns:

A list of all files in the directory.

Return type:

list[str]

abstract set(filepath, content, mode)[source]

Set the file content at the given filepath.

Parameters:
  • filepath (str) – The filepath to store the data at.

  • content (bytes) – The content to store as bytes.

  • mode (str) – The mode to open the file in.

Return type:

None