Skip to content

Executor Attribute Error when trying to run custom python function-based components with Kubeflow Runner #3628

@bkhuong

Description

@bkhuong

Environment: Google Cloud (Uploading pipeline yaml to Kubeflow Pipelines instance)
TFX Version: 0.29
Python version: 3.7.3

Describe the current behavior
I get the following error:


2021-04-27 23:41:30.195332: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0
Traceback (most recent call last):
  File "/opt/conda/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/opt/conda/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/opt/conda/lib/python3.7/site-packages/tfx/orchestration/kubeflow/container_entrypoint.py", line 364, in <module>
    main()
  File "/opt/conda/lib/python3.7/site-packages/tfx/orchestration/kubeflow/container_entrypoint.py", line 319, in main
    component = json_utils.loads(args.serialized_component)
  File "/opt/conda/lib/python3.7/site-packages/tfx/utils/json_utils.py", line 193, in loads
    return json.loads(s, cls=_DefaultDecoder)
  File "/opt/conda/lib/python3.7/json/__init__.py", line 361, in loads
    return cls(**kw).decode(s)
  File "/opt/conda/lib/python3.7/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/opt/conda/lib/python3.7/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
  File "/opt/conda/lib/python3.7/site-packages/tfx/utils/json_utils.py", line 173, in _dict_to_object
    return _extract_class(dict_data)
  File "/opt/conda/lib/python3.7/site-packages/tfx/utils/json_utils.py", line 163, in _extract_class
    return getattr(importlib.import_module(module_name), class_name)
AttributeError: module '__main__' has no attribute 'PathGeneratorComponent_Executor'

Describe the expected behavior
The PathGeneratorComponent successfully outputs the string artifact "some string".

Standalone code to reproduce the issue

from tfx.dsl.component.experimental.annotations import OutputArtifact
from tfx.dsl.component.experimental.decorators import component
from tfx.types.standard_artifacts import String
from tfx.orchestration import pipeline
from tfx.orchestration.kubeflow import kubeflow_dag_runner

@component
def PathGeneratorComponent(
        output_path: OutputArtifact[String]
):
    output_path.value = "some string"


def create_pipeline():

    path_generator = PathGeneratorComponent()

    return pipeline.Pipeline(
        pipeline_name="test",
        pipeline_root="test",
        components=[path_generator]
    )

path_pipeline = create_pipeline()

config = kubeflow_dag_runner.KubeflowDagRunnerConfig(
    kubeflow_metadata_config=kubeflow_dag_runner.
        get_default_kubeflow_metadata_config(),
    tfx_image='tensorflow/tfx:0.29.0'
)

kfp_runner = kubeflow_dag_runner.KubeflowDagRunner(
    output_filename='test.yaml', config=config
)

kfp_runner.run(path_pipeline)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions