1313# limitations under the License.
1414#
1515import tempfile
16-
16+ import shutil
1717import lightgbm as lgb
1818import mlflow
1919import mlflow .environment_variables
@@ -132,7 +132,9 @@ def test_track_run_with_experiment_name(handler):
132132 # Set the mlflow experiment name
133133 mlflow .environment_variables .MLFLOW_EXPERIMENT_NAME .set (f"{ handler } _test_track" )
134134 with tempfile .TemporaryDirectory () as test_directory :
135- mlflow .set_tracking_uri (test_directory ) # Tell mlflow where to save logged data
135+ # Use SQLite backend instead of filesystem (filesystem will be deprecated in Feb 2026)
136+ db_uri = f"sqlite:///{ os .path .join (test_directory , 'mlflow.db' )} "
137+ mlflow .set_tracking_uri (db_uri ) # Tell mlflow where to save logged data
136138
137139 # Create a project for this tester:
138140 project = mlrun .get_or_create_project (name = "default" , context = test_directory )
@@ -149,17 +151,43 @@ def test_track_run_with_experiment_name(handler):
149151 trainer_run = func .run (
150152 local = True ,
151153 handler = handler ,
152- artifact_path = test_directory ,
154+ output_path = test_directory ,
153155 )
154156
157+ # Find the MLflow logged model and prepare it for serving
158+ # Note: In MLflow 2.24+, we must dynamically discover model paths since MLflow changed
159+ # its directory structure from predictable paths (e.g., experiment_name/0/model/) to
160+ # UUID-based paths (e.g., experiment_id/run_uuid/artifacts/model/).
161+
162+ # Create MLflow client to query the tracking server
163+ mlflow_client = mlflow .tracking .MlflowClient (tracking_uri = db_uri )
164+
165+ # Get the experiment by name to obtain its ID
166+ experiment = mlflow_client .get_experiment_by_name (f"{ handler } _test_track" )
167+
168+ # Search for runs in this experiment and get the run ID
169+ # (There should only be one run from our training above)
170+ run_id = mlflow_client .search_runs (experiment_ids = [experiment .experiment_id ])[0 ].info .run_id
171+
172+ # Find all models logged in this run
173+ logged_models = mlflow .search_logged_models (filter_string = f"source_run_id = '{ run_id } '" )
174+
175+ # Extract the artifact location and remove the "file://" prefix
176+ model_artifacts_dir = logged_models ["artifact_location" ].tolist ()[0 ].replace ("file://" , "" )
177+
178+ # Package the model artifacts as a zip file for MLFlowModelServer
179+ # Note: MLFlowModelServer requires models to be packaged as zip archives
180+ # rather than loose directories for deployment
181+ model_path = os .path .join (test_directory , f"{ handler } -model-serving" )
182+ os .makedirs (model_path , exist_ok = True )
183+ shutil .make_archive (os .path .join (model_path , "model" ), 'zip' , model_artifacts_dir )
184+
155185 serving_func = project .set_function (
156186 func = os .path .abspath ("function.yaml" ),
157187 name = f"{ handler } -server" ,
158188 )
159189 model_name = f"{ handler } -model"
160190 # Add the model
161- upper_handler = handler .replace ("_" , "-" )
162- model_path = test_directory + f"/{ upper_handler } -test-{ upper_handler } /0/model/"
163191 serving_func .add_model (
164192 model_name ,
165193 class_name = "MLFlowModelServer" ,
0 commit comments