deploy_to_kyma
Method to deploy a MLflow Databricks model to SAP Kyma Kubernetes.
predict
Method to perform inferencing on the deployed SAP Kyma Kubernetes endpoint.
Method to deploy a MLflow Databricks model to SAP Kyma Kubernetes.
deploy_to_kyma(databricks_config_path)
- Use any linux environment.
- Python version compatible with latest version of mlflow. The compatible python version can be found here
- A running docker daemon.
-
Create a Kyma service account by referring the (tutorial).
-
In step 2.1 of the (tutorial), add the following fields:
- Add 'namespaces' under 'rules -> resources' section of yaml file.
- Add 'watch' under 'rules -> verbs' section of yaml file.
-
In step 4.1 of the (tutorial), replace the following:
- Replace the value of 'name' under 'clusters' section with the cluster name of the kyma kubernetes cluster.
- Replace the value of 'name' under 'users' section and 'user' under 'contexts'-> 'context' with 'OIDCUser' user.
- Replace the value of 'name', 'context -> cluster' under 'contexts' section with the cluster name of the kyma kubernetes cluster.
- Replace the value of 'current-context' with the cluster name of the kyma kubernetes cluster.
-
The 'kubeconfig.yaml' file is generated to connect to Kyma Kubernetes.
- Generate a Databricks personal access token in the Databricks Workspace by referring the link.
-
Ensure that the Azure Container Registry is created via the Azure portal (link). Also, take a note of the login server in the overview page of the created Azure Container Registry.
-
Create a Service Principal and assign 'AcrPush' role to the Service Principal in the Azure Container Registry.
-
Register an application with Azure AD and create a service principal using the (link)
-
Get the Application (client) ID by referring (get application id). The Application (client) ID is the "SERVICE_PRINCIPAL_ID".
-
Create a new application secret by referring (create new application secret). The value of the client secret displayed is the "SERVICE_PRINCIPAL_PASSWORD".
-
Assign 'AcrPush' role to the created Service Principal in the Azure Container Registry using the Azure CLI (link) or Azure Portal (link).
-
-
Preferably, create an AzureML notebook by referring the (guide) to run the SAP Kyma Kubernetes deployment steps.
-
Create an IAM user that does not have MFA enabled by referring the (guide) and ensure the IAM user has EC2 container registry access permissions for pushing and pulling to ecr. (link).
-
Preferably, create a Sagemaker Notebook Instance by referring the (guide), to run the SAP Kyma Kubernetes deployment steps.
-
You must also create a profile using aws cli that connects to the IAM user with EC2 container registry access permissions. Please ensure the region of this profile is the same region as the jupyter instance by referring (link). If you have a Sagemaker Notebook Instance created, please run it in the Sagemaker Notebook instance terminal.
databricks_config_path (str):
The file path of the Databricks configuration json file.
The Databricks configuration json file must contain the following configurations.
Databricks configuration json
{
"DATABRICKS_URL":<Databricks Workspace Url>,
"DATABRICKS_ACCESS_TOKEN":<Databricks Personal Access Token created in the Pre-requisite section>,
"MODEL_URI":<URI of the Databricks MLflow model to deploy in the form of "runs:/{run_id}/{model_name}>,
"CONTAINER_REGISTRY_TYPE":<Type of container registry to use. The supported container registry types are 'ACR' for Azure Container Registry and 'ECR' for AWS Elastic Container Registry>,
"SERVICE_NAME":<Name of the service or deployment>,
"KUBECONFIG_PATH":<File path to the kubeconfig.yaml file created in the Pre-requisite section>,
"OVERWRITE_SERVICE":<Optional. Overwrites the existing deployment if set to true.>
Azure ACR Specifc Configurations
"SERVICE_PRINCIPAL_ID":<Service Principal ID created in the Pre-requisite section>,
"SERVICE_PRINCIPAL_PASSWORD":<Service Principal Password created in the Pre-requisite section>,
"ACR":<Azure Container registry login server in the form of "<mycontainerregistry>.azurecr.io">,
AWS ECR Specifc Configurations
"PROFILE_NAME":<Name of the profile created in the Pre-requisite section>
}
SAP Kyma Kubernetes Endpoint.
Example:
from fedml_databricks import deploy_to_kyma
endpoint_url=deploy_to_kyma(databricks_config_path='<path-to-databricks-config-json-file>')
Method to perform inferencing on the deployed SAP Kyma Kubernetes endpoint.
predict(endpoint_url,content_type,data)
endpoint_url (str):
The endpoint url of the SAP Kyma Kubernetes deployment.
content_type:
They type of content passed. Accepted content types are "application/json" and "text/csv".
data:
The data used for inferencing. Please refer the ways to format the test data for inferencing by referring the (link)
The result of inferencing.
Example 1: Inferencing the SAP Kyma Kubernetes webservice endpoint with pandas dataframe in csv format.
#Predict using the endpoint_url
from fedml_databricks import predict
predict(endpoint_url=<kyma-endpoint-url>,content_type="text/csv",data=df.to_csv(index=False))
Example 2: Inferencing the SAP Kyma Kubernetes webservice endpoint with pandas dataframe in json format.
#Predict using the endpoint_url
import json
data = {
"dataframe_records": df.to_dict(orient='records')
}
json_data = json.dumps(data)
from fedml_databricks import predict
predict(endpoint_url=<kyma-endpoint-url>,content_type="application/json",data=json_data)