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.
27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from typing import Any
|
|
from logging import Logger
|
|
from temporalio import activity
|
|
from sientia_do.notifications.handlers import NotificationHandler
|
|
|
|
|
|
class BaseActivity:
|
|
def __init__(self, logger: Logger, notification_handler: NotificationHandler):
|
|
self.logger = logger
|
|
self.notification_handler = notification_handler
|
|
|
|
@activity.defn(name="prepare_activity")
|
|
async def prepare_activity(self, input_data: dict[str, Any]):
|
|
"""
|
|
Prepare the activity for the notification handler.
|
|
|
|
Args:
|
|
workflow_name (str): The name of the workflow.
|
|
schedule_name (str): The name of the schedule.
|
|
model_name (str): The name of the model.
|
|
model_id (str): The id of the model.
|
|
"""
|
|
self.notification_handler.base_notification.pipeline_name = input_data['workflow_name']
|
|
self.notification_handler.base_notification.schedule_name = input_data['schedule_name']
|
|
self.notification_handler.base_notification.model_name = input_data['model_name']
|
|
self.notification_handler.base_notification.model_id = input_data['model_id']
|