提问者:小点点

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模块。有没有办法做到这一点?为此,我需要了解KFP在base_image上安装软件包时在哪里寻找软件包。我知道这可以通过使用自定义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]
):

共3个答案

匿名用户

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

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

匿名用户

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

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

匿名用户

我找到了这个问题的答案

在KFPSDK1.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]
):