SIENTIAPDE-1712

SIENTIAPDE-1712 Refactor debug logging for DataFrames across multiple classes. Introduced a new method to log DataFrame content conditionally based on row count in Gates, MLFlow, ModelMetrics, and MLFlowRepository classes, improving debugging capabilities while managing log output effectively.
This commit is contained in:
vitor-aignosi
2026-03-30 08:54:56 -03:00
parent f84d38a837
commit a8259d716a
5 changed files with 95 additions and 47 deletions

View File

@@ -20,6 +20,7 @@ with workflow.unsafe.imports_passed_through():
from sientia_do.utils.formatters import create_sample_dict
from laborious.utils.models.minio_dataframe_payload import MinioDataFramePayload
from laborious.utils.dataframe_debug import build_dataframe_debug_message
from laborious.utils.repository.minio_manager import MinioManager
from laborious.utils.repository.model_repository import MLFlowRepository
@@ -104,19 +105,11 @@ class MLFlow(MinioManager):
- data (Any): Dataframe-like object expected to expose shape and to_csv
- metadata (dict[str, Any]): Workflow metadata for contextual logging
"""
if not hasattr(data, 'shape') or not hasattr(data, 'to_csv'):
self.debug(f'{message}\n{data}', metadata)
return
rows = data.shape[0]
if rows <= self._MAX_DEBUG_DATAFRAME_ROWS:
self.debug(f'{message}\n{data.to_csv()}', metadata)
return
self.debug(
(
f'{message} skipped because dataframe has {rows} rows '
f'(max: {self._MAX_DEBUG_DATAFRAME_ROWS}). Shape: {data.shape}'
build_dataframe_debug_message(
message=message,
data=data,
max_rows=self._MAX_DEBUG_DATAFRAME_ROWS,
),
metadata,
)