SIENTIAPDE-994

Implement new get_last_timestamp method in Gates class, refactor MLFlow activity methods to return only transformed data, and update PredictionsBatch and PredictionProcess workflows to utilize Activities module. Add detailed docstrings for new methods and enhance test coverage for get_last_timestamp functionality.
This commit is contained in:
vitor-aignosi
2025-05-12 11:36:21 -03:00
parent d09fb6ac5e
commit eb6d2dd79c
8 changed files with 540 additions and 83 deletions

View File

@@ -26,7 +26,7 @@ class MLFlow(BaseActivity):
)
@activity.defn(name="request_transform")
async def request_transform(self, input_data: dict[str, Any]) -> tuple[dict[str, Any], str]:
async def request_transform(self, input_data: dict[str, Any]) -> dict[str, Any]:
"""
Access MLFlow model to get the transformed data.
Args:
@@ -35,7 +35,7 @@ class MLFlow(BaseActivity):
model_name (str): The name of the model.
model_retention (int): The retention of the model.
Returns:
tuple[dict[str, Any], str]: The transformed data and the latest timestamp of the data.
dict[str, Any]: The transformed data.
"""
self.logger.info('Transforming data...')
data = DataFrame(input_data['data'])
@@ -54,12 +54,10 @@ class MLFlow(BaseActivity):
response_data = self.model_monitoring_repository.transform(
model_name, data, model_retention)
timestamp = max(data['timestamp'].values.tolist())
return response_data, timestamp
return response_data
@activity.defn(name="request_predict")
async def request_predict(self, input_data: dict[str, Any]) -> tuple[dict[str, Any], str]:
async def request_predict(self, input_data: dict[str, Any]) -> dict[str, Any]:
"""
Access MLFlow model to get the predicted data.
Args:
@@ -68,7 +66,7 @@ class MLFlow(BaseActivity):
model_name (str): The name of the model.
model_retention (int): The retention of the model.
Returns:
tuple[dict[str, Any], str]: The predicted data and the latest timestamp of the data.
dict[str, Any]: The predicted data.
"""
self.logger.info('Predicting data...')
data = DataFrame(input_data['data'])