SIENTIAPDE-1199

Refactor logging in Gates and MLFlow activities to use info level for key operations

- Updated logging statements in the Gates class to replace debug logs with info logs for input and output gate operations, enhancing visibility.
- Modified MLFlow class to use info logs for data transformation and prediction processes, improving clarity in the logging output.
- Adjusted OPC class to return the count of successfully written tags, providing better insight into data writing operations.
This commit is contained in:
vitor-aignosi
2025-08-20 10:38:08 -03:00
parent 89384d7783
commit 8b9bb8d720
4 changed files with 67 additions and 30 deletions

View File

@@ -115,7 +115,9 @@ class OPC(BaseActivity):
def manage_output_tags(
self, server_id: str, config: dict[str, Any], data: DataFrame,
metadata: dict[str, Any], success: bool) -> bool:
metadata: dict[str, Any], success: bool) -> tuple[bool, int]:
count = 0
if 'prediction_tags' in config:
for tag, tag_config in config['prediction_tags'].items():
local_success = self.write_data(
@@ -129,6 +131,7 @@ class OPC(BaseActivity):
if local_success:
self.info(
f"Prediction data written to OPC server {server_id} for tag {tag}.", metadata)
count += 1
success = success and local_success
if 'confidence_tags' in config:
@@ -144,9 +147,10 @@ class OPC(BaseActivity):
if local_success:
self.info(
f"Confidence data written to OPC server {server_id} for tag {tag}.", metadata)
count += 1
success = success and local_success
return success
return success, count
@activity.defn(name='write_opc_data')
async def write_opc_data(self, input_data: dict[str, Any]) -> dict[Any, Any]:
@@ -168,21 +172,28 @@ class OPC(BaseActivity):
"""
metadata = input_data['metadata']
self.debug("Writing data to OPC servers...", metadata)
self.info("Writing data to OPC servers...", metadata)
data = DataFrame(input_data['data'])
opc_output_config = input_data['opc_output_config']
self.debug(data, metadata)
self.info(f"Data to write: {data.size} rows", metadata)
success = True
success_count = 0
for server_id, config in opc_output_config.items():
if not self.validate_server(server_id, metadata):
success = False
continue
success = success and self.manage_output_tags(
local_success, local_count = self.manage_output_tags(
server_id, config, data, metadata, success)
success = success and local_success
success_count += local_count
self.info(
f"Data written to OPC server {server_id}: {local_count} of {len(config['prediction_tags'])} prediction tags and {len(config['confidence_tags'])} confidence tags", metadata)
return self.process_confidence(data, success, metadata)