def test_build_docker_with_env_override(iris_data, sk_model): with mlflow.start_run() as active_run: mlflow.sklearn.log_model(sk_model, "model") model_uri = "runs:/{run_id}/model".format( run_id=active_run.info.run_id) x, _ = iris_data df = pd.DataFrame(x) image_name = pyfunc_build_image(model_uri, extra_args=["--install-mlflow"]) host_port = get_safe_port() scoring_proc = pyfunc_serve_from_docker_image_with_env_override( image_name, host_port, gunicorn_options) _validate_with_rest_endpoint(scoring_proc, host_port, df, x, sk_model)
def test_build_docker_with_env_override(iris_data, sk_model, enable_mlserver): with mlflow.start_run() as active_run: if enable_mlserver: # MLServer requires Python 3.7, so we'll force that Python version with mock.patch("mlflow.utils.environment.PYTHON_VERSION", "3.7"): mlflow.sklearn.log_model(sk_model, "model") else: mlflow.sklearn.log_model(sk_model, "model") model_uri = "runs:/{run_id}/model".format(run_id=active_run.info.run_id) x, _ = iris_data df = pd.DataFrame(x) extra_args = ["--install-mlflow"] if enable_mlserver: extra_args.append("--enable-mlserver") image_name = pyfunc_build_image(model_uri, extra_args=extra_args) host_port = get_safe_port() scoring_proc = pyfunc_serve_from_docker_image_with_env_override( image_name, host_port, gunicorn_options ) _validate_with_rest_endpoint(scoring_proc, host_port, df, x, sk_model, enable_mlserver)