JC3
New Contributor II

Thank you, @Kumaran.

The short version of this is below. Note that I have the following env vars loaded at runtime:

  • DATABRICKS_HOST
  • DATABRICKS_CLIENT_ID
  • DATABRICKS_CLIENT_SECRET
  • MLFLOW_TRACKING_URI

 

import os
import
mlflow

if __name__ == "__main__":
# attempt to use mlflow to search model registry and load model
mlflow_client = mlflow.MlflowClient(
registry_uri=os.getenv('MLFLOW_TRACKING_URI')
)

model_name = 'test-model'
for model in mlflow_client.search_model_versions(filter_string=f"name='{model_name}'"):
pymodel = mlflow.pyfunc.load_model(model_uri=f"models:/{model.name}/{model.version}")

 

If DATABRICKS_CLIENT_ID and DATABRICKS_CLIENT_SECRET were replaced by a personal access token at  DATABRICKS_TOKEN, then this works as expected. But not when using the Service principal's client id and secret, which is what I hope to use, so that auth is M2M.

Can you help here?