kubeflow 属性错误:"组件存储"对象没有属性"uri_search_template"



我正在尝试使用kfp.components.ComponentStore加载一些预组装的gcp kubeflow组件。然而,我得到了这个错误:

line 180, in _load_component_spec_in_component_ref
if self.uri_search_template:
AttributeError: 'ComponentStore' object has no attribute 'uri_search_template'

当在这行代码时:

mlengine_train_op = component_store.load_component('ml_engine/train')

KFP版本:

kfp                             1.8.10
kfp-pipeline-spec               0.1.13
kfp-server-api                  1.7.1

复制的步骤

import kfp
from kfp.components import func_to_container_op
COMPONENT_URL_SEARCH_PREFIX = "https://raw.githubusercontent.com/kubeflow/pipelines/1.7.1/components/gcp/"
component_store = kfp.components.ComponentStore(
local_search_paths=None, url_search_prefixes=[COMPONENT_URL_SEARCH_PREFIX])
mlengine_train_op = component_store.load_component('ml_engine/train')
mlengine_deploy_op = component_store.load_component('ml_engine/deploy')

我从一个在kfp0.2.5上运行的示例中得到了这段代码。这可能是版本问题,但有人知道如何将此代码更新到新版本吗?

我解决了这个问题。@Kabilan Mohanraj也提到了他的评论。如果在创建ComponentStore时没有设置uri_search_template,那么看起来会有一个bug。我通过将其作为参数来解决它,实际上传递给构造函数的内容并不重要,但它是必需的,因为在代码中有以下

if self.url_search_prefixes:

但是,如果不传递某个属性,则不会在构造函数中创建该属性。我是这样修复的:

component_store = kfp.components.ComponentStore(
local_search_paths=["local_search_path"], url_search_prefixes=[COMPONENT_URL_SEARCH_PREFIX]), uri_search_template="{name}/"

我希望它将来能帮助到别人。我在github问题中建议通过更清楚地显示错误或更好地检查uri_search_template属性来解决这个问题。

最新更新