From 7b53584069c323322c86215eaf0c566a0a178a9c Mon Sep 17 00:00:00 2001
From: dmt <>
Date: Thu, 3 Oct 2019 19:00:33 +0200
Subject: [PATCH] Add destruction settings and add 'knowledge_dir' as config
 parameter.

---
 cml/shared/settings.py | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/cml/shared/settings.py b/cml/shared/settings.py
index 3c9dbcf..206fff2 100644
--- a/cml/shared/settings.py
+++ b/cml/shared/settings.py
@@ -56,11 +56,11 @@ class Settings(metaclass=MetaSettings):
     LEARN_DIR: str = ""
     MAX_LEARN_DIR: int = 0
     USE_EXISTING_MODELS: bool = False
-    SET_FEATURES: str = ""
+    KNOWLEDGE_DIR = ""
+
     SET_TARGETS: str = ""
     SORT_TIME_STAMP: bool = False
-    CUT_TIME_STAMP: bool = False
-    BLOCK_SIZE: int = 0
+
     MAX_BLOCKS: int = 0
     STACK_ITERATIONS: int = 0
     LEARN_BLOCK_MINIMUM: int = 0
@@ -85,15 +85,20 @@ class PreprocessingSettings:
 
 @dataclass
 class BlockProcessingSettings:
-    block_size = int
-    max_blocks = int
-    stack_iterations = int
-    learn_block_minimum = int
-    sigma_zeta_cutoff = float
+    block_size: int
+    max_blocks: int
+    stack_iterations: int
+    learn_block_minimum: int
+    sigma_zeta_cutoff: float
+
+
+@dataclass
+class DeconstructionSettings:
+    pass
 
 
 def specific_settings_factory(settings_type: str):
-    types = {
+    factory = {
         "general": starmap(
             GeneralSettings, [(Settings.INPUT_FILE,
                                Settings.LEARN_DIR,
@@ -109,15 +114,19 @@ def specific_settings_factory(settings_type: str):
                                        Settings.MAX_BLOCKS,
                                        Settings.STACK_ITERATIONS,
                                        Settings.LEARN_BLOCK_MINIMUM,
-                                       Settings.SIGMA_ZETA_CUTOFF)])
+                                       Settings.SIGMA_ZETA_CUTOFF)]),
+        "deconstruction": starmap(
+            DeconstructionSettings, [()]
+        )
     }
 
-    return next(types[settings_type])
+    return next(factory[settings_type])
 
 
 def read_settings(path: str):
     try:
-        config = ConfigParser(path)
+        config = ConfigParser()
+        config.read(path)
         configure_main_settings_class(config)
     except AttributeError as e:
         # TODO (dmt): Implement proper error handling.
@@ -126,11 +135,12 @@ def read_settings(path: str):
 
 def configure_main_settings_class(config):
 
-    default = config["DEFAULT"]
+    default = config["GENERAL"]
     Settings.INPUT_FILE = default["input_file"]
     Settings.LEARN_DIR = default["learn_dir"]
     Settings.MAX_LEARN_DIR = default["max_learn_dir"]
     Settings.USE_EXISTING_MODELS = default["use_existing_models"]
+    Settings.KNOWLEDGE_DIR = default["knowledge_dir"]
 
     preprocessing = config["PREPROCESSING"]
     Settings.SET_FEATURES = preprocessing["set_features"]
-- 
GitLab