Kubeflow管道在哪里查找' packages_to_install '中的包?



我正在使用顶点AI中的Kubeflow管道来创建我的ML管道,并且已经能够使用Kubeflow组件中的标准封装,使用以下语法

@component(
# this component builds an xgboost classifier with xgboost
packages_to_install=["google-cloud-bigquery", "xgboost", "pandas", "sklearn", "joblib", "pyarrow"],
base_image="python:3.9",
output_component_file="output_component/create_xgb_model_xgboost.yaml"
)
def build_xgb_xgboost(project_id: str,
data_set_id: str,
training_view: str,
metrics: Output[Metrics],
model: Output[Model]
):

现在我需要在packages_to_install中添加我的自定义python模块。有办法吗?为此,我需要了解在base_image之上安装包时KFP在哪里查找包。我理解这可以使用自定义base_image来实现,我在其中构建了带有python模块的base_image。但这对我来说似乎是多余的,我更愿意在组件规范中指定适用的python模块像下面的

@component(
# this component builds an xgboost classifier with xgboost
packages_to_install=["my-custom-python-module","google-cloud-bigquery", "xgboost", "pandas", "sklearn", "joblib", "pyarrow"],
base_image="python:3.9",
output_component_file="output_component/create_xgb_model_xgboost.yaml"
)
def build_xgb_xgboost(project_id: str,
data_set_id: str,
training_view: str,
metrics: Output[Metrics],
model: Output[Model]
):

在底层,该步骤将在运行时执行组件时安装包。这需要将包托管在以后运行时环境可以访问的位置。

鉴于此,你需要将包上传到一个以后可以访问的位置,例如Jose提到的git存储库。

为此,我需要了解在base_image之上安装包时KFP在哪里查找包。

您在packages_to_install中指定的内容将传递给pip install命令,因此它将从PyPI中查找包。您还可以从源代码控制中安装软件包,因为pip支持它。参见示例:https://packaging.python.org/en/latest/tutorials/installing-packages/#installing-from-vcs

我找到了这个问题的答案

使用KFP SDK 1.8.12, Kubeflow允许您指定自定义pip_index_url参见Kubeflow特性请求

有了这个特性,我可以像这样安装我的自定义python模块

@component(
# this component builds an xgboost classifier with xgboost
pip_index_urls=[CUSTOM_ARTEFACT_REPO, "https://pypi.python.org/simple"],
packages_to_install=["my-custom-python-module","google-cloud-bigquery", "xgboost", "pandas", "sklearn", "joblib", "pyarrow"],
base_image="python:3.9",
output_component_file="output_component/create_xgb_model_xgboost.yaml"
)
def build_xgb_xgboost(project_id: str,
data_set_id: str,
training_view: str,
metrics: Output[Metrics],
model: Output[Model]
):

最新更新