cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Machine Learning
Dive into the world of machine learning on the Databricks platform. Explore discussions on algorithms, model training, deployment, and more. Connect with ML enthusiasts and experts.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Model serving with custom pip index URL

ScyLukb
New Contributor

An mlflow model was logged with a custom pip requirements file which contains package versions (mlflow==2.11.3), as well as a custom --index-url. 

However model serving during the "Initializing model enviroment" step tries to pip install mlflow==2.2.2

How can this be avoided and only install the package versions provided in the requirements file and with the provided index url?

1 REPLY 1

stbjelcevic
Databricks Employee
Databricks Employee

Hi @ScyLukb ,

This is a common and frustrating problem that occurs when the Model Serving environment's built-in dependencies conflict with your model's specific requirements.

The root cause is that the Model Serving environment tries to install its own default version of mlflow (in your case, 2.2.2) before or instead of processing your custom requirements.txt file. This default version then conflicts with the one you've specified, or the environment setup simply ignores your file for that specific package.

To avoid this and force Model Serving to use your exact package versions and index URL, you must log the model with an explicit conda.yaml environment file that defines the entire environment.

This approach overrides the serving environment's defaults.

Solution: Log the Model with a conda.yaml File

Instead of just providing a requirements.txt file, you will manually define the Conda environment, including the pip section. This is the most robust way to control the serving environment.

Why This Works

  • Explicit > Implicit: By providing a full conda.yaml, you are explicitly defining the entire environment. You are no longer "suggesting" requirements with a requirements.txt but are instead "demanding" this exact environment.

  • Overrides Defaults: Model Serving will see this conda.yaml file and build a new, custom environment based on it, rather than trying to use its default environment image (which contains the problematic mlflow==2.2.2).

  • Correct pip Context: Placing the --index-url inside the pip: section ensures it's passed to the pip install command within the Conda environment as it's being built, so it can find all your custom packages.