Passed
Push — mpeta ( a918a8...92227f )
by Konstantinos
05:23
created

so_magic.data.backend.backend.Backend.__init__()   A

Complexity

Conditions 1

Size

Total Lines 4
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
"""This module defines the Data Engine Wrapper as the Backend class which constructor can initialize Backend instances
2
."""
3
import attr
4
from so_magic.data.magic_datapoints_factory import BroadcastingDatapointsFactory
5
from so_magic.data.datapoints_manager import DatapointsManager
6
7
8
@attr.s
9
class Backend:
10
    """Wrapper of a data engine, a datapoints manager and a datapoints factory.
11
12
    Instances of this class act as data placeholders (aka data classes) and take at runtime a data engine (eg a set of
13
    pandas-dependent implementations of the "Tabular Data interfaces" defined in so_magic.data.interfaces).
14
15
    Args:
16
        engine_instance (DataEngine): a data engine represented as a class object (eg class MyClass: pass)
17
    """
18
    engine_instance = attr.ib(init=True)
19
    datapoints_manager = attr.ib(init=False, default=attr.Factory(DatapointsManager))
20
    datapoints_factory = attr.ib(init=True, default=attr.Factory(BroadcastingDatapointsFactory))
21
22
    @property
23
    def engine(self):
24
        """The Data Engine instance, that this object wraps around.
25
26
        Returns:
27
            DataEngine: the Data Engine instance object
28
        """
29
        return self.engine_instance
30
31
    @engine.setter
32
    def engine(self, engine):
33
        """Set the Data Engine instance to the input engine object.
34
35
        Args:
36
            engine (DataEngine): the Data Engine object to set with
37
        """
38
        self.engine_instance = engine
39