Commit 512fadca authored by Alex's avatar Alex

Added clustering config as yaml

parent ee159e16
layers:
user:
properties:
starting-point:
properties:
- Latitude_StartingPoint
- Longitude_StartingPoint
\ No newline at end of file
import yaml
### init logging ###
import logging
LOG_FORMAT = (
'%(levelname) -5s %(asctime)s %(name)s:%(funcName) -35s %(lineno) -5d: %(message)s')
logging.basicConfig(level=logging.INFO, format=LOG_FORMAT)
LOGGER = logging.getLogger(__name__)
class ClusteringConfig:
config_path = 'configs/clustering.yaml'
config: dict = None
def __init__(self):
self.config = self.load_config()
def load_config(self) -> dict:
config = None
with open(self.config_path, 'r') as stream:
try:
config = yaml.safe_load(stream)
except yaml.YAMLError as exc:
LOGGER.error(exc)
config = {}
return config
def get_config(self):
return self.config
def get_layer_configs(self):
for key, layer in self.config['layers'].items():
layer['layer-name'] = key
yield layer
import io import io
from flask import request, Response from flask import request, Response
from db.repository import Repository from db.repository import Repository
from processing.clusterer import Clusterer from processing.clustering.clusterer import Clusterer
from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
repo = Repository() repo = Repository()
......
...@@ -7,7 +7,7 @@ if os.path.exists(modules_path): ...@@ -7,7 +7,7 @@ if os.path.exists(modules_path):
from db.entities import Location, PopularLocation, LocationCluster, TimeCluster from db.entities import Location, PopularLocation, LocationCluster, TimeCluster
from typing import List, Dict, Tuple from typing import List, Dict, Tuple
from db.repository import Repository from db.repository import Repository
from processing.clusterer import Clusterer from processing.clustering.clusterer import Clusterer
DEBUG = False DEBUG = False
......
import unittest import unittest
import sys import sys
sys.path.insert(1, '../') sys.path.insert(1, '../')
# python -m unittest discover # python -m unittest discover
from processing.clusterer import Clusterer from processing.clustering.clusterer import Clusterer
class TestClusterer(unittest.TestCase): class TestClusterer(unittest.TestCase):
clusterer:Clusterer = None clusterer:Clusterer = None
......
import unittest
import sys
sys.path.insert(1, './')
# python -m unittest discover
from processing.clustering.clustering_config import ClusteringConfig
class TestClusteringConfig(unittest.TestCase):
def setUp(self):
self.clustering_config = ClusteringConfig()
def test_get_layer_configs_noneInput_noneOutput(self):
for layer_config in self.clustering_config.get_layer_configs():
self.assertIn('layer-name', layer_config)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment