Commit f5a59d6a authored by Jean-Didier Totow's avatar Jean-Didier Totow
Browse files

Merge branch 'performaance-model-profiler' into 'morphemic-rc1.5'

update performance model profiler

See merge request melodic/morphemic-preprocessor!47
parents 2f52ce5c ab221619
......@@ -18,7 +18,7 @@ import sqlite3
path_ml_model = os.environ.get("MLMODELPATH","./models")
log_folder = os.environ.get("LOGS_FOLDER","./logs")
time_sklearn_training = int(os.environ.get("SKLEARNTIME","600")) #in seconde
time_sklearn_training = int(os.environ.get("SKLEARNTIME","600"))
local_database_path = os.environ.get("LOCAL_DATABASE_PATH","./db/")
logFile = log_folder + '/ml.log'
......
......@@ -35,73 +35,6 @@ _process_stop = False
db_evaluation_period = 60*2
db_last_evaluation = time.time()
"""
class ServerRPC(Thread):
def __init__(self):
self.port = 8767
self.max_workers = 10
super(ServerRPC, self).__init__()
def run(self):
server = grpc.server(futures.ThreadPoolExecutor(max_workers=self.max_workers))
service_pb2_grpc.add_PredictServicer_to_server(PredictRPC(), server)
server.add_insecure_port('[::]:{0}'.format(self.port))
server.start()
print("RPC server started on {0}".format(self.port))
#server.wait_for_termination()
while True:
if _process_stop:
break
time.sleep(5)
print("RPC server stopped normally")
rpc_server = ServerRPC()
rpc_server.start()
"""
"""
def DBEvaluationRoutine():
print("DB Evaluator routine started")
global db_last_evaluation
while True:
if _process_stop:
break
if time.time() - db_last_evaluation >= db_evaluation_period:
try:
conn = sqlite3.connect(local_database_path + "prediction.db")
cursor = conn.cursor()
data_to_send = []
for row in cursor.execute("SELECT * FROM Prediction"):
_json = {'application': row[1], 'target': row[2], 'features': json.loads(row[4]), 'prediction': row[3], 'variant': row[4]}
data_to_send.append(_json)
conn.close()
if data_to_send != []:
conn = stomp.Connection(host_and_ports = [(activemq_hostname, activemq_port)])
conn.connect(login=activemq_username,passcode=activemq_password)
time.sleep(2)
conn.send(body=json.dumps(data_to_send), destination=subscription_topic, persistent='false')
conn.disconnect()
print("Messages pushed to activemq")
print("Removing message to Local DB")
conn = sqlite3.connect(local_database_path + "prediction.db")
cursor = conn.cursor()
cursor.execute("DELETE FROM Prediction")
conn.commit()
conn.close()
else:
print("Nothing found")
except Exception as e:
print("An error occured")
print(e)
db_last_evaluation = time.time()
time.sleep(5)
print("DB Evaluation stopped")
thread = Thread(target=DBEvaluationRoutine, args=())
thread.start()
"""
class TrainRequest(BaseModel):
url_file: Optional[str] = None
application: str
......
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