1.7.2. Connector base classes¶
This section contains documentation of the base classes of the connector classes.
-
class
connectors.connectors.
Connector
(instance, method, parallelization, executor)¶ Base class for connectors. Connectors are objects that replace methods of a class so that they can be connected to each other. This way changing data at one end of a connection chain will automatically cause the data at the other end of the chain to be updated, when that data is retrieved the next time.
Parameters: - instance – the instance of which the method is replaced by this connector
- method – the unbound method that is replaced by this connector
- parallelization – a flag from the
connectors.Parallelization
enum. See theset_parallelization()
method for details - executor – an
Executor
instance, that can be created with theconnectors.executor()
function. See theset_executor()
method for details
-
connect
(connector)¶ Abstract method that defines the interface of a
Connector
for connecting it with other connectors.Parameters: connector – the Connector
instance to which this connector shall be connectedReturns: the instance of which this Connector
has replaced a method
-
disconnect
(connector)¶ Abstract method that defines the interface of a
Connector
for disconnecting it from a connector, to which it is currently connected.Parameters: connector – a Connector
instance from which this connector shall be disconnectedReturns: the instance of which this Connector
has replaced a method
-
set_executor
(executor)¶ Sets the executor, which handles the computations, when the data is retrieved through this connector. An executor can be created with the
connectors.executor()
function. It manages the order and the parallelization of the computations, when updating the data in a processing chain. If multiple connectors in a processing chain need to be computed, the executor of the connector, which started the computations, is used for all computations.Parameters: executor – an Executor
instance, that can be created with theconnectors.executor()
function
-
set_parallelization
(parallelization)¶ Specifies, if and how the execution of this connector can be parallelized. The choices are no parallelization, the execution in a separate thread and the execution in a separate process. This method specifies a hint, which level of parallelization is possible with the connector. If the executor of the connector, through which the computation is started, does not support the specified level, the next simpler one will be chosen. E.g. if a connector can be parallelized in a separate process, but the executor only allows threads or sequential execution, the connector will be executed in a separate thread.
Parameters: parallelization – a flag from the connectors.Parallelization
enum
-
class
connectors._connectors._baseclasses.
InputConnector
(instance, method, laziness, parallelization, executor)¶ Base class for input connectors, that replace setter methods.
Parameters: - instance – the instance of which the method is replaced by this connector
- method – the unbound method that is replaced by this connector
- laziness – a flag from the
connectors.Laziness
enum. See theset_laziness()
method for details - parallelization – a flag from the
Parallelization
enum. See theset_parallelization()
method for details - executor – an
Executor
instance, that can be created with theconnectors.executor()
function. See theset_executor()
method for details
-
connect
(connector)¶ Connects this
InputConnector
to an output.Parameters: connector – the Connector
instance to which this connector shall be connectedReturns: the instance of which this InputConnector
has replaced a method
-
disconnect
(connector)¶ Disconnects this
InputConnector
from an output, to which is has been connected.Parameters: connector – a Connector
instance from which this connector shall be disconnectedReturns: the instance of which this Connector
has replaced a method
-
set_executor
(executor)¶ Sets the executor, which handles the computations, when the data is retrieved through this connector. An executor can be created with the
connectors.executor()
function. It manages the order and the parallelization of the computations, when updating the data in a processing chain. If multiple connectors in a processing chain need to be computed, the executor of the connector, which started the computations, is used for all computations.Parameters: executor – an Executor
instance, that can be created with theconnectors.executor()
function
-
set_laziness
(laziness)¶ Configures the lazy execution of the connector. Normally the connectors are executed lazily, which means, that any computation is only started, when the result of a processing chain is requested. For certain use cases it is necessary to disable this lazy execution, though, so that the values are updated immediately as soon as new data is available. There are different behaviors for the (non) lazy execution, which are described in the
connectors.Laziness
enum.Parameters: laziness – a flag from the connectors.Laziness
enum
-
set_parallelization
(parallelization)¶ Specifies, if and how the execution of this connector can be parallelized. The choices are no parallelization, the execution in a separate thread and the execution in a separate process. This method specifies a hint, which level of parallelization is possible with the connector. If the executor of the connector, through which the computation is started, does not support the specified level, the next simpler one will be chosen. E.g. if a connector can be parallelized in a separate process, but the executor only allows threads or sequential execution, the connector will be executed in a separate thread.
Parameters: parallelization – a flag from the connectors.Parallelization
enum