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:
vitor-aignosi
2026-05-20 09:53:53 -03:00
parent ddb1618209
commit 4ea0754f0c
3 changed files with 49 additions and 2 deletions

View File

@@ -170,8 +170,19 @@ class MLFlowRepository(SientiaMonitoring):
# Sort by version number to get the latest
latest_version = max(stage_versions, key=lambda v: int(v.version))
run_id = latest_version.source.split('/')
return run_id[2]
source = latest_version.source
if source is None:
raise mlflow.exceptions.MlflowException(
f"Model '{model_name}' version '{latest_version.version}' in stage '{stage}' "
'has no source URI to resolve run ID.'
)
parts = source.split('/')
if len(parts) <= 2 or not parts[2]:
raise mlflow.exceptions.MlflowException(
f"Model '{model_name}' version '{latest_version.version}' in stage '{stage}' "
f"has invalid source URI '{source}' for run ID resolution."
)
return parts[2]
def get_next_run_name(self, model_name: str) -> str:
"""