from data_pipeline.log_writer.log_writer import Logger LOGGER_DB_NAME = "logs" LOGGER_MEASUREMENT = "logs" LOGGER_HOST = "uipserver.ddns.net" LOGGER_PORT = "8086" LOGGER_COMPONENT = "Daten klassifizieren" logger = Logger(LOGGER_DB_NAME, LOGGER_MEASUREMENT, LOGGER_HOST, LOGGER_PORT, LOGGER_COMPONENT) from flask import * import data_pipeline.daten_klassifizieren.trainingsdata_editing_engine as trainingsdata import data_pipeline.daten_klassifizieren.classification_engine as classification import data_pipeline.daten_klassifizieren.training_engine as training import data_pipeline.exception.exceptions as ex import traceback app = Flask(__name__) http_status_codes = { "HTTPOK": 200, "HTTPBadRequest": 400, "HTTPInternalServerError": 500, "ConfigException": 900, "DBException": 901, "PersistorException": 902, "FileException": 903, "SklearnException": 904 } @app.route('/')
from flask import * from datetime import datetime import time from data_pipeline.daten_bereinigen.src.bereinigungs_engine import bereinigungs_engine as cleaning_eng import data_pipeline.exception.exceptions as exceptions import data_pipeline.konfiguration.src.config_validator as validator from data_pipeline.log_writer.log_writer import Logger app = Flask(__name__) logger = Logger("logs", "cleaning_logs", "uipserver.ddns.net", 8086, "Cleaning_API") expected_keys = set([ 'sensor_data_timeframe', 'to', 'from', 'sensor_data', 'from_db', 'to_db', 'from_measurement', 'to_measurement', 'value_name', 'register', 'frame_width', 'freq', 'threshold', 'historic_weatherdata', 'from_db', 'to_db', 'from_measurement', 'to_measurement', 'value_name', 'register', 'frame_width', 'freq', 'threshold', 'forecast_weatherdata', 'from_db', 'to_db', 'from_measurement', 'to_measurement', 'value_name', 'register', 'frame_width', 'freq', 'threshold' ]) def check_if_request_empty(): """ Checks if the incoming http-post-request comes with an empty body. :raise InvalidConfigException if the body is empty. :return request-object. """ if int(request.headers.get('Content-Length')) == 0: raise exceptions.NoDataException('Message must not be empty', 900)
import multiprocessing import pandas as pd from datetime import datetime import data_pipeline.exception.exceptions as exc import data_pipeline.db_connector.src.read_manager.read_manager as rm import data_pipeline.db_connector.src.write_manager.write_manager as wm from data_pipeline.log_writer.log_writer import Logger # initialize logger logger = Logger("logs", "logs", "uipserver.ddns.net", 8086, "Cleaning_Engine") def get_data(from_db, from_measurement, value_name, register, time): """ Retrieve data from database Name in documentation: get_data :param from_db: database from which the data should be extracted :param from_measurement: the measurement from which the data should be extracted :param value_name: name of the field in influxdb :param register: register of the desired curve which should be cleaned :param time: tart and end time of the desired period where the curve should be cleaned :return: returns temperature data as a Pandas.Series """ query = "" if isInt(register): query = "SELECT {0} FROM {1} WHERE register='{2}' and time >= {3}ms and time <= {4}ms".format( value_name, from_measurement, register, time["from"], time["to"]) else: query = "SELECT {0} FROM {1} WHERE time >={2}ms AND time <={3}ms".format( value_name, from_measurement, time["from"], time["to"])