python-3.xazuremodeldatabricksazure-databricks

Databricks ML Model Permissions


All,

From the Models Menu, I picked a model (Loan Approval Data) from the various versions and was able to set it up for "Real-Time Inference". I also did the same for 1994 Census Data. I have two questions pertaining to the usage:

  1. For the Loan Approval Model, When I click on "Use" to query the endpoint, I'm not seeing the sample Request. However, for the 1994 Census model I'm able to see the Sample Request & Response. Is there a reason why? I mean why do some models generate sample Request and some dont?

  2. How do I grant access to the Model? I had to create a PAT token and use it as a Bearer Token in postman for 1994 Census Model to work. What permissions do models and their endpoints need inorder to be functional?

Thanks, Gopi


Solution

  • Usually when you are using endpoint which is created using custom trained model you won't get the sample request.

    Only inbuilt will be having the sample request when querying endpoint.

    It is also possible that it depends on the model signature

    enter image description here

    and input example given like mentioned in this document

    enter image description here

    So, whenever you are logging and registering the model you do along with the signature and input example.

    Example code

    from mlflow.models.signature import infer_signature
    
    model_path = "models/diabetes_rf"
    signature = infer_signature(X_train, predictions)
    input_example = X_train[:5]
    mlflow.sklearn.log_model(rf, model_path, signature=signature, input_example=input_example)
    model_uri = f"runs:/{mlflow.active_run().info.run_id}/{model_path}"
    model_details = mlflow.register_model(model_uri, "RandomForestDiabetesModel")
    

    Next, when it comes to permission on model you can handle it in model tab as shown in image.

    enter image description here

    Here, you can set who can access model and use it.

    To use the serving endpoint, you just need PAT token to make successful request.