FeatureStoreClient() log_model 无法使用 mlflow.spark 风味运行推理

问题描述 投票:0回答:2

我正在使用

FeatureStoreClient().log_model(...,flavor = mlflow.spark,...)
记录模型,并在尝试使用

对模型进行推理后
fs.score_batch(f"models:/{model_name}/Production", batch_scoring)

在 databricks 运行时环境中。

运行批量推理后出现以下错误:

2023/11/17 20:51:40 WARNING mlflow.pyfunc: Detected one or more mismatches between the model's dependencies and the current Python environment:
 - databricks-feature-lookup (current: uninstalled, required: databricks-feature-lookup==0.*)
To fix the mismatches, call `mlflow.pyfunc.get_model_dependencies(model_uri)` to fetch the model's environment and install dependencies using the resulting environment file.
2023/11/17 20:51:40 WARNING mlflow.pyfunc: Calling `spark_udf()` with `env_manager="local"` does not recreate the same environment that was used during training, which may lead to errors or inaccurate predictions. We recommend specifying `env_manager="conda"`, which automatically recreates the environment that was used to train the model and performs inference in the recreated environment.
PythonException: 'ModuleNotFoundError: No module named 'ml''. Full traceback below:

我不知道如何解决这个问题,任何帮助将不胜感激。

我曾经... - 在 log_model 中尝试不同的风格 -尝试更好地理解 mlflow 模型口味 API

pyspark databricks apache-spark-mllib mlflow feature-store
2个回答
1
投票

似乎 model.predict 找不到 ml 模块。您可以检查您的代码,也许您正在使用自定义模块 ml.py (或包),简单搜索导入。自定义代码必须包含在 fs.log_model 中


0
投票

错误“'ModuleNotFoundError:没有名为'ml'的模块”表明您要使用的ml模块及其工件无法通过score_batch() API访问。当您使用 fs.log_model() 记录模型时,您可能没有正确指定 code_path()。如果您使用自定义模块并将其定义在与用于推理的笔记本不同的单独笔记本中,请确保在 log_model() API 的 code_path() 参数中传递该自定义模块的路径。我在 this repo 中添加了一个代码示例。

© www.soinside.com 2019 - 2024. All rights reserved.