mlrl.testbed.experiments.output.writer module

Author Michael Rapp (michael.rapp.ml@gmail.com)

Provides classes for writing output data to sinks.

class mlrl.testbed.experiments.output.writer.DataExtractor

Bases: ABC

An abstract base class for all classes that extract output data from the state of an experiment.

abstractmethod extract_data(state: ExperimentState, sinks: list[Sink]) list[tuple[ExperimentState, OutputData]]

Must be implemented by subclasses in order to extract output data from the state of an experiment.

Parameters:
  • state – The state from which the output data should be extracted

  • sinks – The sinks to which the extracted data should be written

Returns:

A list that contains the output data that has been extracted and the corresponding states

class mlrl.testbed.experiments.output.writer.DatasetExtractor(properties: Properties, context: Context)

Bases: DataExtractor, ABC

An abstract base class for all extractors that use DatasetInputData that has previously been loaded via an input reader.

extract_data(state: ExperimentState, _: list[Sink]) list[tuple[ExperimentState, OutputData]]

See mlrl.testbed.experiments.output.writer.DataExtractor.extract_data()

class mlrl.testbed.experiments.output.writer.OutputWriter(*extractors: DataExtractor)

Bases: object

Allows to write output data to one or several sinks.

add_sinks(*sinks: Sink) OutputWriter

Adds one or several sinks, output data should be written to.

Parameters:

sinks – The sinks to be added

Returns:

The OutputWriter itself

create_input_reader(args: Namespace, input_directory: Path) InputReader | None

May be overridden by subclasses in order to create an InputReader that can read the data produced by this output writer.

Parameters:
  • args – The command line arguments specified by the user

  • input_directory – The directory, the data should be read from

Returns:

The InputReader that has been created or None, if no such reader is available

create_sources(input_directory: Path) list[Source]

Creates and returns a list that contains all sources that can read the data produced by this output writer.

Parameters:

input_directory – The directory, the data should be read from

Returns:

A list that contains the sources that has been created

sinks: list[Sink]
write(state: ExperimentState)

Writes the input data.

Parameters:

state – The current state of the experiment

class mlrl.testbed.experiments.output.writer.ResultWriter(*extractors: DataExtractor, input_data: InputData | None = None)

Bases: OutputWriter

Allows to write experimental results to one or several sinks.

create_input_reader(args: Namespace, input_directory: Path) InputReader | None

May be overridden by subclasses in order to create an InputReader that can read the data produced by this output writer.

Parameters:
  • args – The command line arguments specified by the user

  • input_directory – The directory, the data should be read from

Returns:

The InputReader that has been created or None, if no such reader is available

class mlrl.testbed.experiments.output.writer.TabularDataExtractor(properties: TabularProperties, context: Context)

Bases: DataExtractor

Uses TabularInputData that has previously been loaded via an input reader.

extract_data(state: ExperimentState, _: list[Sink]) list[tuple[ExperimentState, OutputData]]

See mlrl.testbed.experiments.output.writer.DataExtractor.extract_data()

class mlrl.testbed.experiments.output.writer.TextualDataExtractor(properties: Properties, context: Context)

Bases: DataExtractor

Uses TextualInputData that has previously been loaded via an input reader.

extract_data(state: ExperimentState, _: list[Sink]) list[tuple[ExperimentState, OutputData]]

See mlrl.testbed.experiments.output.writer.DataExtractor.extract_data()