SIENTIAPDE-1110
Update dependencies and enhance logging in activities; bump version in requirements and values.yaml
This commit is contained in:
@@ -2,10 +2,10 @@ from temporalio import activity, workflow
|
||||
|
||||
|
||||
with workflow.unsafe.imports_passed_through():
|
||||
from logging import Logger
|
||||
from sientia_do.notifications.handlers import NotificationHandler
|
||||
from sientia_do.notifications.models import NotificationLevel
|
||||
from sientia_do.temporal.activities.base import BaseActivity
|
||||
from sientia_do.temporal.utils.logger import Logger
|
||||
from laborious.utils.repository.opc_repository import OpcRepository
|
||||
from typing import Any
|
||||
import traceback
|
||||
@@ -89,16 +89,17 @@ class OPC(BaseActivity):
|
||||
- dict[Any, Any]: The data that was written to the OPC servers.
|
||||
|
||||
"""
|
||||
self.logger.debug("Writing data to OPC servers...")
|
||||
metadata = input_data['metadata']
|
||||
self.debug("Writing data to OPC servers...", metadata)
|
||||
data = DataFrame(input_data['data'])
|
||||
opc_output_config = input_data['opc_output_config']
|
||||
self.logger.debug(data)
|
||||
self.debug(data, metadata)
|
||||
|
||||
success = True
|
||||
|
||||
for server, config in opc_output_config.items():
|
||||
if self.opc_repository.get(server) is None:
|
||||
self.logger.error(f"OPC server {server} not found")
|
||||
self.error(f"OPC server {server} not found", metadata)
|
||||
continue
|
||||
|
||||
if 'prediction_tags' in config:
|
||||
@@ -137,15 +138,17 @@ class OPC(BaseActivity):
|
||||
Returns:
|
||||
dict[Any, Any]: The processed data as a dictionary.
|
||||
"""
|
||||
metadata = data['metadata']
|
||||
|
||||
if not success:
|
||||
data['prediction_confidence'] = OPC_WRITTING_ERROR_CONFIDENCE
|
||||
self.logger.debug(
|
||||
self.debug(
|
||||
"Some data could not be written to OPC servers, setting confidence to "
|
||||
f"{OPC_WRITTING_ERROR_CONFIDENCE}."
|
||||
)
|
||||
|
||||
else:
|
||||
self.logger.info("Data written to OPC servers successfully.")
|
||||
self.debug("Data written to OPC servers successfully.", metadata)
|
||||
|
||||
return data.to_dict()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user