Skip to content

Reader

io.reader.Reader

Bases: ABC

Base class for all readers.

checks() classmethod

Optional pre‐flight checks (e.g. dependencies). Override if needed.

extract(prj, id_ens, id_run, ctx) abstractmethod classmethod

Extract and parse all possible information given the context. This method is responsible for calling all other methods.

PARAMETER DESCRIPTION
prj

Destination project to put extracted information.

TYPE: Project

id_ens

ID to store any ensemble data under.

TYPE: str

context

Information needed for the reader.

RETURNS DESCRIPTION
Project

Project after extracting all information.

prepare(*args, **kwargs) abstractmethod classmethod

Load files, open handles, build FSM state, etc. Return a dict representing the full parsing context.

run(prj, id_ens, id_run, reader_args=None, reader_kwargs=None) classmethod

Read and extract data from start to finish for a single ensemble.

PARAMETER DESCRIPTION
prj

Project to store all extracted data to.

TYPE: Project

id_ens

ID of this ensemble. This function will create the ensemble if it does not exist in prj.

TYPE: str

reader_args

Arguments for preparing the context needed for the reader.

TYPE: tuple[Any] | None DEFAULT: None

reader_kwargs

Keyword arguments for preparing the context needed for the reader.

TYPE: dict[str, Any] | None DEFAULT: None

RETURNS DESCRIPTION
Project

Project after extracting data.