Skip to content

Reader

Reader

Bases: ABC

Base class for all readers.

checks()

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

extract(prj, ens_id, run_id, ctx)

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

ens_id

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)

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

run(prj, ens_id, run_id, reader_args=None, reader_kwargs=None)

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

PARAMETER DESCRIPTION

prj

Project to store all extracted data to.

TYPE: Project

ens_id

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.