2 Load R Models from Unity Catalog
{mlflow}
doesn’t support directly logging R models to Unity Catalog (without jumping through a few hoops). However, you can easily load models from Unity Catalog.
2.1 How?
Yep, very straightforward, it just works as-is.
2.2 Why Is This So Simple?
A natural question is “why did I have to go through all the pain to register the model, but loading just works?”
The quick answer is that {mlflow}
doesn’t have internal consistency with how it operates, some methods use direct API calls (e.g. registration) and where as others defer to the mlflow CLI via a system call (e.g. loading).
2.2.1 The Details
As of version 2.20.1
we can split {mlflow}
into those that directly invokes mlflow’s REST API’s via R, or the mlflow CLI.
Invokes REST Client | Invokes CLI Client | |
---|---|---|
Not relevant to Unity Catalog (e.g. experiment tracking related) |
|
|
Relevant to Unity Catalog (e.g. model registry) |
|
|
mlflow_load_model()
calls mlflow_download_artifacts_from_uri()
, which in turn uses the CLI directly. The CLI was updated to support Unity Catalog, hence why it ‘just works’ and the functions inherit Unity Catalog compatibility without code changes.
You may notice mlflow_log_model()
has an asterix, that is because it uniquely calls CLI client (mlflow_log_artifact()
) and REST client (mlflow_record_logged_model()
), I’ve placed it in the REST column for now.
This is part of the problem discussed previously in Section 1.2.3. Unfortunately the CLI doesn’t expose the model registry methods required to support registering models to Unity Catalog, these need to be implemented as part of the REST client in {mlflow}
.