Update dependencies and enhance ML model retraining functionality - Updated sientia-dataops-library version in requirements.txt from 1.3.3 to 1.3.4. - Incremented image tag in values.yaml from 0.2.4 to 0.2.5 and added a new environment variable MONGODB_TTL_INDEX_HOURS. - Introduced new methods in MLFlowRepository for model retraining and production model updates, including error handling and logging. - Added retrain_model and update_production_model activities in mlflow.py to support model management workflows. - Modified MongoDB connection settings in connectors_config.py for improved security and configuration flexibility.
60 lines
1.9 KiB
Python
60 lines
1.9 KiB
Python
"""
|
|
Builds the configuration for the connectors.
|
|
"""
|
|
|
|
from os import getenv
|
|
import json
|
|
|
|
|
|
def build_postgres_config():
|
|
return {
|
|
'host': getenv('POSTGRES_HOST', 'localhost'),
|
|
'port': int(getenv('POSTGRES_PORT', '5432')),
|
|
'user': getenv('POSTGRES_USER', 'sientia'),
|
|
'password': getenv('POSTGRES_PASSWORD', 'sientia'),
|
|
'dbname': getenv('POSTGRES_DBNAME', 'sientia'),
|
|
'min_connections': int(getenv('POSTGRES_MIN_CONNECTIONS', '5')),
|
|
'max_connections': int(getenv('POSTGRES_MAX_CONNECTIONS', '20'))
|
|
}
|
|
|
|
|
|
def build_mlflow_config():
|
|
return {
|
|
'host': getenv('MLFLOW_HOST', 'http://localhost'),
|
|
'port': int(getenv('MLFLOW_PORT', '5080')),
|
|
'username': getenv('MLFLOW_USERNAME', 'aignosi'),
|
|
'password': getenv('MLFLOW_PASSWORD', 'aignosi')
|
|
}
|
|
|
|
|
|
def build_opc_config():
|
|
opc_raw = getenv('OPC_CONFIG', None)
|
|
|
|
if opc_raw:
|
|
return json.loads(opc_raw)
|
|
|
|
return {
|
|
getenv('OPC_ID', '1'): {
|
|
'id': getenv('OPC_ID', '1'),
|
|
'url': getenv('OPC_URL', 'opc.tcp://localhost:4840'),
|
|
'server_uri': getenv('OPC_SERVER_URI', 'opc.tcp://localhost:4840'),
|
|
'cert_path': getenv('OPC_CERT_PATH', None),
|
|
'private_key_path': getenv('OPC_PRIVATE_KEY_PATH', None),
|
|
'server_cert_path': getenv('OPC_SERVER_CERT_PATH', None),
|
|
'reconnection_interval': int(getenv('OPC_RECONNECTION_INTERVAL', '120'))
|
|
}
|
|
}
|
|
|
|
|
|
def build_mongodb_config():
|
|
username = getenv('MONGODB_USERNAME', 'root')
|
|
password = getenv('MONGODB_PASSWORD', 'wKZDbMNU1c')
|
|
uri = getenv('MONGODB_URL', 'localhost:27018')
|
|
|
|
connection_string = f'mongodb://{username}:{password}@{uri}'
|
|
return {
|
|
'connection_string': connection_string,
|
|
'database_name': getenv('MONGODB_DATABASE_NAME', 'sientia'),
|
|
'ttl_index_seconds': int(getenv('MONGODB_TTL_INDEX_HOURS', '1')) * 3600
|
|
}
|