SIENTIAPDE-1350: Refactor: Improve logging, configuration, and resource management. Includes .env updates, client initialization logging, and resource closing.

This commit is contained in:
Bruno Domingues
2025-11-24 23:08:29 -03:00
parent 2ee66552d2
commit 463906073e
10 changed files with 53 additions and 53 deletions

View File

@@ -84,6 +84,7 @@ def build_mongodb_config() -> dict[str, Any]:
'connection_string': connection_string,
'database_name': getenv('MONGODB_DATABASE_NAME', 'sientia'),
'ttl_index_seconds': int(getenv('MONGODB_TTL_INDEX_HOURS', '1')) * 3600,
'uri': uri,
}

View File

@@ -31,8 +31,8 @@ warnings.filterwarnings('ignore', category=FutureWarning, message=".*'squared' i
class ModelRepository:
def __init__(self, url, username, password, logger: Logger):
self.model_serving = ModelServing(tracking_uri=url, username=username, password=password)
self.logger = logger
self.logger.info(f'MLFlow client initialized at {url}')
def save_model(self, train_result: TrainModelResult) -> TrainModelResult:
"""

View File

@@ -86,7 +86,11 @@ class StorageRepository:
use_ssl=use_ssl,
)
self.logger.info(f'MinIO client initialized successfully: {endpoint_url}')
self.logger.info(f'MinIO client initialized at {endpoint_url}')
def close(self) -> None:
self.minio_client.close()
self.logger.info('MinIO client closed')
def fetch_file(self, bucket_name: str, file_name: str) -> BytesIO:
"""