LoaderAbstract#

class LoaderAbstract(params=None, **kwargs)#

Bases: Generic[T_Source_contra, T_Data], Module

Abstract class of Loader module.

The Loader is tasked with opening the data into Python. It may run post-processing if defined by the user.

Parameters:
  • params (Any | None)

  • kwargs (Any)

get_data(*, source=None, ignore_postprocess=False, load_kwargs=None, **kwargs)#

Load data and run post-processing.

The actual loading is done by load_data_concrete() that can be overwritten by subclasses.

Tries to run the method postprocess of the parent interface. If it raises NotImplementedError, postprocess will be ignored.

Parameters:
  • source (T_Source_contra | Sequence[T_Source_contra] | None) – Source location of the data to load. If left to None, get_source() is used.

  • ignore_postprocess (bool) – If True, do not apply postprocessing. Default is False.

  • load_kwargs (Mapping[str, Any] | None) – Arguments passed to function loading data.

  • kwargs (Any) – Arguments passed to the postprocessing function.

Return type:

T_Data

load_data_concrete(source, **kwargs)#

Load the data from datafiles.

This method should be implemented in subclasses to account for different format, libraries, etc.

Not implemented:

implement in a module subclass.

Parameters:
Return type:

Any

postprocess(data)#

Run operation after loading data.

Not implemented:

implement (if necessary) in your Loader module subclass.

Parameters:

data (T_Data)

Return type:

T_Data