QTZPOC-20

QTZPOC-20: Prioritize code/ directory download and sys.path injection before model loading, enabling MLflow flavors to stream models directly from URIs and simplifying joblib artifact handling.
This commit is contained in:
2026-09-01 13:27:32 -03:00
parent c1a44a9d7a
commit 30ff378cb7
8 changed files with 464 additions and 245 deletions

View File

@@ -1114,8 +1114,15 @@ no fallback between flavors: a failing loader propagates.
retrain (`model.pkl` + `code/`, no `MLmodel`, so only this runtime reads it back).
Every flavor puts the artifact's own `code/` on `sys.path` before loading, **when that directory
exists**: MLflow's loaders only do it when the `MLmodel` manifest declares `code`, so `sklearn` and
`pyfunc` resolve the URI to a local directory first and load from there.
exists**: MLflow's loaders only do it when the `MLmodel` manifest declares `code`. `download_model`
owns that step for all of them — it asks the registry whether the artifact carries `code/` and, only
then, downloads that one directory. The models themselves are never pre-downloaded: `sklearn` and
`pyfunc` load straight from the model URI and fetch what they need.
`download_model` does not branch on the flavor: past that shared first step it delegates to
`load_predict_model` / `load_transform_model`, and its only branch left is `load_wrapper`, which is
orthogonal to the flavor. It returns `(model, artifact_dir)`, the directory the retrain path re-logs
`code/` from.
Full reference, including how to switch an existing model over: **[docs/model-flavors.md](docs/model-flavors.md)**.