SIENTIAPDE-994
Refactor and enhance the laborious workflow and utilities - Removed outdated test file `test_predictions_batch.py` from workflows. - Added `input_sample.json` for standardized input configuration. - Introduced `connectors_config.py` to manage database and service configurations. - Implemented a logging utility in `logger.py` for consistent logging across the application. - Created `policies.py` to define retry policies for workflows. - Developed comprehensive tests for `MLFlowRepository` in `test_model_repository.py`. - Added extensive tests for `OpcRepository` in `test_opc_repository.py`. - Updated `test_predictions_batch.py` to reflect new workflow structure and testing methodology.
This commit is contained in:
@@ -51,7 +51,7 @@ async def test_input_gate_specific_variables_null_values_with_stop_policy_only(
|
||||
}
|
||||
|
||||
result = await gates.input_gate(input_data)
|
||||
assert result == ('stop', -1)
|
||||
assert result == ('stop', -1, 'Input data with bad quality')
|
||||
|
||||
input_args = specific_variables_null_values_mock.call_args
|
||||
assert input_args[0][0].equals(DataFrame(
|
||||
@@ -98,7 +98,7 @@ async def test_input_gate_specific_variables_null_values_with_continue_policy_on
|
||||
}
|
||||
|
||||
result = await gates.input_gate(input_data)
|
||||
assert result == ('continue', 2)
|
||||
assert result == ('continue', 2, 'Input data with bad quality')
|
||||
|
||||
input_args = specific_variables_null_values_mock.call_args
|
||||
assert input_args[0][0].equals(DataFrame(
|
||||
@@ -145,7 +145,7 @@ async def test_input_gate_specific_variables_null_values_no_filtered(
|
||||
}
|
||||
|
||||
result = await gates.input_gate(input_data)
|
||||
assert result == (None, 0)
|
||||
assert result == (None, 0, '')
|
||||
|
||||
specific_variables_null_values_input_args = specific_variables_null_values_mock.call_args
|
||||
|
||||
@@ -197,7 +197,7 @@ async def test_input_gate_one_stop_policy(
|
||||
}
|
||||
|
||||
result = await gates.input_gate(input_data)
|
||||
assert result == ('stop', -1)
|
||||
assert result == ('stop', -1, 'Input data with bad quality')
|
||||
|
||||
specific_variables_null_values_input_args = specific_variables_null_values_mock.call_args
|
||||
assert specific_variables_null_values_input_args[0][0].equals(DataFrame(
|
||||
@@ -251,7 +251,7 @@ async def test_input_gate_one_continue_policy(
|
||||
}
|
||||
|
||||
result = await gates.input_gate(input_data)
|
||||
assert result == ('continue', 2)
|
||||
assert result == ('continue', 2, 'Input data with bad quality')
|
||||
|
||||
specific_variables_null_values_input_args = specific_variables_null_values_mock.call_args
|
||||
assert specific_variables_null_values_input_args[0][0].equals(DataFrame(
|
||||
@@ -305,7 +305,7 @@ async def test_input_gate_no_filtered(
|
||||
}
|
||||
|
||||
result = await gates.input_gate(input_data)
|
||||
assert result == (None, 0)
|
||||
assert result == (None, 0, '')
|
||||
|
||||
specific_variables_null_values_input_args = specific_variables_null_values_mock.call_args
|
||||
assert specific_variables_null_values_input_args[0][0].equals(DataFrame(
|
||||
@@ -340,7 +340,7 @@ async def test_input_gate_error(
|
||||
}
|
||||
|
||||
result = await gates.input_gate(input_data)
|
||||
assert result == (None, 0)
|
||||
assert result == (None, 0, '')
|
||||
|
||||
gates.notification_handler.build_and_send_notification.assert_called_once_with(
|
||||
notification_id='INTPUT_GATE_ERROR__SPECIFIC_VARIABLES_NULL_VALUES',
|
||||
@@ -389,7 +389,7 @@ async def test_mlflow_response_gate_no_filtered(
|
||||
}
|
||||
|
||||
result = await gates.mlflow_response_gate(input_data)
|
||||
assert result == (None, 0)
|
||||
assert result == (None, 0, '')
|
||||
|
||||
api_error_filter_mock.assert_called_once_with(
|
||||
input_data['data'],
|
||||
@@ -433,7 +433,7 @@ async def test_mlflow_response_gate_filtered(
|
||||
}
|
||||
|
||||
result = await gates.mlflow_response_gate(input_data)
|
||||
assert result == ('continue', 255)
|
||||
assert result == ('continue', 255, "Error")
|
||||
|
||||
api_error_filter_mock.assert_called_once_with(
|
||||
input_data['data'],
|
||||
@@ -480,7 +480,7 @@ async def test_mlflow_content_gate_no_filtered(
|
||||
}
|
||||
|
||||
result = await gates.mlflow_content_gate(input_data)
|
||||
assert result == (None, 0)
|
||||
assert result == (None, 0, '')
|
||||
|
||||
nan_values_filter_mock_args = nan_values_filter_mock.call_args
|
||||
assert nan_values_filter_mock_args[0][0].equals(DataFrame(
|
||||
@@ -504,7 +504,8 @@ async def test_mlflow_content_gate_filtered(
|
||||
if x == 'path_confidence':
|
||||
return transform_filter_path_confidence
|
||||
|
||||
mlflow_content_filter_functions_mock.__getitem__.side_effect = transform_filter_functions_side_effect
|
||||
mlflow_content_filter_functions_mock.__getitem__.side_effect = \
|
||||
transform_filter_functions_side_effect
|
||||
|
||||
input_data = {
|
||||
'filters': {
|
||||
@@ -521,7 +522,8 @@ async def test_mlflow_content_gate_filtered(
|
||||
}
|
||||
|
||||
result = await gates.mlflow_content_gate(input_data)
|
||||
assert result == ('repeat', -1)
|
||||
assert result == (
|
||||
'repeat', -1, "Transformed data not passed the content filter")
|
||||
|
||||
nan_values_filter_mock_args = nan_values_filter_mock.call_args
|
||||
assert nan_values_filter_mock_args[0][0].equals(DataFrame(
|
||||
|
||||
Reference in New Issue
Block a user