1
|
|
|
from .data_manager import DataManager |
2
|
|
|
from .features.phi import PhiFunctionRegistrator |
3
|
|
|
from .features import FeatureManager |
4
|
|
|
from .command_factories import DataManagerCommandFactory |
5
|
|
|
|
6
|
|
|
from .built_in_commands import encode_nominal_subsets_command |
7
|
|
|
from .built_in_data_manager_commands import select_variables_command |
8
|
|
|
from .pd_commands import data_manager_commands, arbitrary_commands |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
def init_data_manager(engine): |
12
|
|
|
# Initialize DataManager instance and DataManagerCommandFactory |
13
|
|
|
my_data_manager = DataManager( |
14
|
|
|
engine, |
15
|
|
|
type('PhiFunction', (PhiFunctionRegistrator,), {}), |
16
|
|
|
FeatureManager([]), |
17
|
|
|
) |
18
|
|
|
mega_cmd_factory = DataManagerCommandFactory(my_data_manager) |
19
|
|
|
mega_cmd_factory.subject.attach(my_data_manager.commands_manager.command.accumulator) |
20
|
|
|
|
21
|
|
|
my_data_manager.commands_manager.decorators = type('EngineCommandDecorators', (object,), { |
22
|
|
|
'data_manager_command': mega_cmd_factory.build_command_prototype, |
23
|
|
|
'arbitrary_command': my_data_manager.engine.backend.dec, |
24
|
|
|
})() |
25
|
|
|
|
26
|
|
|
# Build backend-agnostic, built-in engine commands |
27
|
|
|
my_data_manager.engine.backend.dec()(encode_nominal_subsets_command) |
28
|
|
|
mega_cmd_factory.build_command_prototype()(select_variables_command) |
29
|
|
|
|
30
|
|
|
# Build backend-dependent (eg dependent on pandas) client engine commands |
31
|
|
|
for arbitrary_cmd in arbitrary_commands: |
32
|
|
|
my_data_manager.engine.backend.dec()(arbitrary_cmd) |
33
|
|
|
|
34
|
|
|
for data_manager_cmd in data_manager_commands: |
35
|
|
|
mega_cmd_factory.build_command_prototype()(data_manager_cmd) |
36
|
|
|
|
37
|
|
|
return my_data_manager |
38
|
|
|
|