Workers and Results
Contents
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:
Initialize the worker class
w = Worker()
Configure the worker class by applying a set of methods:
w.set_metric(...)
,w.configure_fom(...)`
etc.Run the worker class on a
Data
object:r = w.run(d)
. This returns a result objectr
.
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
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.
- 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.
Result
#
- 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 theData
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 theclusterking.worker.Worker.run()
method.