SIENTIAPDE-1478

Refactor validation script and improve logging in API and model repository

- Updated validation script to include 'e2e/' directory in code formatting and linting checks.
- Enhanced error logging in API class to improve readability of error messages.
- Refactored debug logging in model repository for better structured output.
- Cleaned up import statements in various files for improved organization.
This commit is contained in:
vitor-aignosi
2026-01-16 16:47:33 -03:00
parent 241f283724
commit 69b2f93ab2
8 changed files with 42 additions and 25 deletions

View File

@@ -333,11 +333,13 @@ async def test_process_pi_web_api_response_with_errors(api):
)
assert confidence == PI_WEB_API_PREDICTION_ERROR_CONFIDENCE
assert message == "The number of written tags does not match the number of tag names: Expected ['tag1', 'tag2'] tags, but ['tag2'] tags were written."
assert (
message
== "The number of written tags does not match the number of tag names: Expected ['tag1', 'tag2'] tags, but ['tag2'] tags were written."
)
assert api.emit_metric.call_count == 2
@mark.asyncio
async def test_process_pi_web_api_response_missing_tags(api):
"""Test processing response when number of written tags doesn't match expected."""
@@ -361,7 +363,10 @@ async def test_process_pi_web_api_response_missing_tags(api):
)
assert confidence == PI_WEB_API_PREDICTION_ERROR_CONFIDENCE
assert message == "The number of written tags does not match the number of tag names: Expected ['tag1', 'tag2'] tags, but ['tag1'] tags were written."
assert (
message
== "The number of written tags does not match the number of tag names: Expected ['tag1', 'tag2'] tags, but ['tag1'] tags were written."
)
api.send_notification_async.assert_called_once()
call_args = api.send_notification_async.call_args
assert call_args.kwargs['notification_id'] == 'WRITE_PI_WEB_API_PREDICTION_ERROR'
@@ -392,7 +397,10 @@ async def test_process_pi_web_api_response_missing_webid(api):
)
assert confidence == PI_WEB_API_PREDICTION_ERROR_CONFIDENCE
assert message == "The number of written tags does not match the number of tag names: Expected ['tag1', 'tag2'] tags, but ['tag2'] tags were written."
assert (
message
== "The number of written tags does not match the number of tag names: Expected ['tag1', 'tag2'] tags, but ['tag2'] tags were written."
)
api.error.assert_any_call('The response did not contain some WebIds', metadata['metadata'])
@@ -419,7 +427,10 @@ async def test_process_pi_web_api_response_missing_tag_name(api):
)
assert confidence == PI_WEB_API_PREDICTION_ERROR_CONFIDENCE
assert message == "The number of written tags does not match the number of tag names: Expected ['tag1'] tags, but [] tags were written."
assert (
message
== "The number of written tags does not match the number of tag names: Expected ['tag1'] tags, but [] tags were written."
)
api.error.assert_any_call(
'The response did not contain the tag name for WebId unknown_web_id', metadata['metadata']
)

View File

@@ -812,7 +812,14 @@ async def test_fit_models_not_df_target_name_none_and_not_in_model(
data = MagicMock()
output = await mlflow_repository.fit_models(
'model_name', data, 'latest_production_id', metadata['metadata'], 'sklearn', False, 'pyfunc', None
'model_name',
data,
'latest_production_id',
metadata['metadata'],
'sklearn',
False,
'pyfunc',
None,
)
mlflow_repository.download_model.assert_has_calls(