SIENTIAPDE-1646
Enhance MLFlow run ID resolution with error handling for missing and invalid source URIs - Added checks in `get_model_run_id` method to raise exceptions for models with missing or invalid source URIs. - Introduced new test cases to validate error handling for these scenarios. - Updated `requirements-light.txt` to include `mlflow` as a dependency.
This commit is contained in:
@@ -142,6 +142,41 @@ def test_get_model_run_id_success(mlflow_repository):
|
||||
assert output == '1'
|
||||
|
||||
|
||||
def test_get_model_run_id_missing_source(mlflow_repository):
|
||||
mlflow_repository.client.search_registered_models.return_value = [MagicMock(name='test')]
|
||||
|
||||
mlflow_repository.client.search_model_versions.return_value = [
|
||||
MagicMock(current_stage='Production', version='1', source='runs/test/0'),
|
||||
MagicMock(current_stage='Production', version='2', source=None),
|
||||
]
|
||||
|
||||
with pytest.raises(mlflow_lib.exceptions.MlflowException) as exc_info:
|
||||
mlflow_repository.get_model_run_id('test')
|
||||
|
||||
assert (
|
||||
str(exc_info.value)
|
||||
== "Model 'test' version '2' in stage 'Production' has no source URI to resolve run ID."
|
||||
)
|
||||
|
||||
|
||||
def test_get_model_run_id_invalid_source(mlflow_repository):
|
||||
mlflow_repository.client.search_registered_models.return_value = [MagicMock(name='test')]
|
||||
|
||||
mlflow_repository.client.search_model_versions.return_value = [
|
||||
MagicMock(current_stage='Production', version='1', source='runs/test/0'),
|
||||
MagicMock(current_stage='Production', version='2', source='runs/test'),
|
||||
]
|
||||
|
||||
with pytest.raises(mlflow_lib.exceptions.MlflowException) as exc_info:
|
||||
mlflow_repository.get_model_run_id('test')
|
||||
|
||||
assert (
|
||||
str(exc_info.value)
|
||||
== "Model 'test' version '2' in stage 'Production' has invalid source URI "
|
||||
"'runs/test' for run ID resolution."
|
||||
)
|
||||
|
||||
|
||||
def test_get_next_run_name(mlflow, mlflow_repository):
|
||||
mlflow.search_runs.return_value = [1, 2, 3]
|
||||
output = mlflow_repository.get_next_run_name('run')
|
||||
|
||||
Reference in New Issue
Block a user