Workers and Results

Operations on the data (represented by a Data object) are performed by worker classes, which are a subclass of the DataWorker class.

Usually the workflow looks as follows:

  1. Initialize the worker class w = Worker()

  2. Configure the worker class by applying a set of methods: w.set_metric(...), w.configure_fom(...)` etc.

  3. Run the worker class on a Data object: r = w.run(d). This returns a result object r.

Running a worker class returns a result class, which is formally a subclass of the AbstractResult` class.

Most prominently, it has a write method, that allows to writes the relevant part of the results back to the Data object. Thus the workflow continues as

  1. Write back to data object: r.write().

Worker

class clusterking.worker.AbstractWorker[source]

Bases: abc.ABC

The AbstractWorker class represents an abstract operation on some data.

It provides a number of methods to allow for configuration.

After configuration, run() can be called.

The underlying design patterns of this class are therefore the template method pattern and the command pattern.

__init__()[source]
abstract run(*args, **kwargs)[source]

Run the operation. Must be implemented in subclass.

class clusterking.worker.DataWorker[source]

Bases: clusterking.worker.AbstractWorker

The worker class represents an operation on some data.

It provides a number of methods to allow for configuration.

After configuration, run() can be called.

The underlying design patterns of this class are therefore the template method pattern and the command pattern.

__init__()[source]
abstract run(*args, **kwargs)[source]

Run the operation. Must be implemented in subclass.

Result

class clusterking.result.AbstractResult[source]

Bases: abc.ABC

__init__()[source]
class clusterking.result.DataResult(data: clusterking.data.data.Data)[source]

Bases: clusterking.result.AbstractResult

The result object represents the result of the execution of a Worker object on the Data object.

__init__(data: clusterking.data.data.Data)[source]

Initializer of the object.

Note

The Result is not meant to be initialized by the user. Rather it is a return object of the clusterking.worker.Worker.run() method.

abstract write(*args, **kwargs)[source]

Write relevant data back to the Data object that was passed to clusterking.worker.Worker.run().