DarioB
DarioB

Reputation: 1609

kubeflow AttributeError: 'ComponentStore' object has no attribute 'uri_search_template'

I am trying to load some prebuit gcp kubeflow components using kfp.components.ComponentStore. However I am getting this error:

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

when at this line of code:

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

KFP version:

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

Steps to reproduce

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')

I got this code from an example that was running on kfp 0.2.5. This is probably some version problem but does anyone knows how to update this code to the newer version?

Upvotes: 1

Views: 934

Answers (1)

DarioB
DarioB

Reputation: 1609

I solved the issue. It is something that @Kabilan Mohanraj also mentioned is his comment. It looks like there is a bug if you don't set up uri_search_template when creating the ComponentStore. I solved it by providing it as parameter, it doesn't really matter what you pass to the constructor really, but it is required because in the code there is the following

if self.url_search_prefixes:

but if you don't pass something that attribute doesn't get created in the constructor. I fixed it like this:

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

I hope it will help someone in the future. I suggested in the github issue to address this by either make the error more clear or to have better check on uri_search_template attribute.

Upvotes: 1

Related Questions