SIENTIAPDE-994
Refactor and enhance the laborious workflow and utilities - Removed outdated test file `test_predictions_batch.py` from workflows. - Added `input_sample.json` for standardized input configuration. - Introduced `connectors_config.py` to manage database and service configurations. - Implemented a logging utility in `logger.py` for consistent logging across the application. - Created `policies.py` to define retry policies for workflows. - Developed comprehensive tests for `MLFlowRepository` in `test_model_repository.py`. - Added extensive tests for `OpcRepository` in `test_opc_repository.py`. - Updated `test_predictions_batch.py` to reflect new workflow structure and testing methodology.
This commit is contained in:
@@ -5,17 +5,16 @@ from temporalio import activity, workflow
|
||||
|
||||
with workflow.unsafe.imports_passed_through():
|
||||
from laborious.activities.base import BaseActivity
|
||||
from laborious.utils.repository.model_repository import MLFlowRepository
|
||||
from typing import Any
|
||||
from logging import Logger
|
||||
from sientia_do.notifications.handlers import NotificationHandler
|
||||
from laborious.utils.repository.model_repository import MLFlowRepository
|
||||
from sientia_do.notifications.models import NotificationLevel
|
||||
|
||||
|
||||
class MLFlow(BaseActivity):
|
||||
def __init__(self, mlflow_host: str, mlflow_port: int, mlflow_username: str,
|
||||
mlflow_password: str, logger: Logger, notification_handler: NotificationHandler):
|
||||
super().__init__(logger, notification_handler)
|
||||
BaseActivity.__init__(self, logger, notification_handler)
|
||||
self.mlflow_host = mlflow_host
|
||||
self.mlflow_port = mlflow_port
|
||||
self.mlflow_username = mlflow_username
|
||||
@@ -33,7 +32,7 @@ class MLFlow(BaseActivity):
|
||||
input_data (dict): The input data. Contains:
|
||||
data (dict[str, Any]): The data to transform.
|
||||
model_name (str): The name of the model.
|
||||
model_retention (int): The retention of the model.
|
||||
model_retention (int): The retention of the model in minutes.
|
||||
Returns:
|
||||
dict[str, Any]: The transformed data.
|
||||
"""
|
||||
@@ -54,6 +53,8 @@ class MLFlow(BaseActivity):
|
||||
response_data = self.model_monitoring_repository.transform(
|
||||
model_name, data, model_retention)
|
||||
|
||||
self.logger.debug(response_data)
|
||||
|
||||
return response_data
|
||||
|
||||
@activity.defn(name="request_predict")
|
||||
@@ -80,4 +81,6 @@ class MLFlow(BaseActivity):
|
||||
response_data = self.model_monitoring_repository.predict(
|
||||
model_name, data, model_retention)
|
||||
|
||||
self.logger.debug(response_data)
|
||||
|
||||
return response_data
|
||||
|
||||
Reference in New Issue
Block a user