Add unit tests for connectors configuration, logger, workflows, and predictions batch - Implement tests for MLflow, OPC, and Postgres configuration builders to validate environment variable handling and default values. - Create tests for the logger to ensure default settings and handler configurations are correct. - Add comprehensive tests for the FormatAndExportPrediction and PredictionProcess workflows, covering various scenarios including path flags and activity execution. - Introduce tests for the PredictionsBatch workflow to verify the execution of local activities and child workflows. - Include a values.yaml file for Kubernetes deployment configuration, specifying image details, service account settings, environment variables, and resource limits.
54 lines
2.2 KiB
Python
54 lines
2.2 KiB
Python
from temporalio import activity, workflow
|
|
|
|
with workflow.unsafe.imports_passed_through():
|
|
from laborious.activities.postgres import Postgres
|
|
from laborious.activities.mlflow import MLFlow
|
|
from laborious.activities.gates import Gates
|
|
from laborious.activities.opc import OPC
|
|
from typing import Any
|
|
from logging import Logger
|
|
from sientia_do.notifications.handlers import NotificationHandler
|
|
|
|
|
|
class Activities(Postgres, MLFlow, Gates, OPC):
|
|
|
|
def __init__(self,
|
|
postgres_config: dict[str, Any],
|
|
mlflow_config: dict[str, Any],
|
|
opc_config: dict[str, Any],
|
|
logger: Logger, notification_handler: NotificationHandler):
|
|
|
|
# Initialize parent classes
|
|
Postgres.__init__(self, host=postgres_config['host'],
|
|
port=postgres_config['port'],
|
|
user=postgres_config['user'],
|
|
password=postgres_config['password'],
|
|
dbname=postgres_config['dbname'],
|
|
min_connections=postgres_config['min_connections'],
|
|
max_connections=postgres_config['max_connections'],
|
|
logger=logger,
|
|
notification_handler=notification_handler)
|
|
|
|
MLFlow.__init__(self, mlflow_host=mlflow_config['host'],
|
|
mlflow_port=mlflow_config['port'],
|
|
mlflow_username=mlflow_config['username'],
|
|
mlflow_password=mlflow_config['password'],
|
|
logger=logger,
|
|
notification_handler=notification_handler)
|
|
|
|
Gates.__init__(self, logger=logger,
|
|
notification_handler=notification_handler)
|
|
|
|
OPC.__init__(self,
|
|
opc_servers=opc_config,
|
|
logger=logger,
|
|
notification_handler=notification_handler)
|
|
|
|
@activity.defn(name="prepare_activity")
|
|
async def prepare_activity(self, input_data: dict[str, Any]):
|
|
await super().prepare_activity(input_data)
|
|
|
|
def shutdown(self):
|
|
Postgres.close(self)
|
|
OPC.shutdown(self)
|