Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python components don't work for images with python 2 #666

Closed
alan-krumholz opened this issue Jan 10, 2019 · 4 comments
Closed

python components don't work for images with python 2 #666

alan-krumholz opened this issue Jan 10, 2019 · 4 comments

Comments

@alan-krumholz
Copy link

Same simple python code runs fine in an python 3 image but it won't run on a python 2 image:

import kfp
from kfp import compiler
import kfp.dsl as dsl
import kfp.notebook
import kfp.gcp as gcp
import datetime
OUTPUT_DIR = 'gs://pipelinestest/out'
PROJECT_NAME = 'energy-forecasting'
@dsl.python_component(
    name='Python test')
def python_Func() -> str:
    import tensorflow
    return("done")
P2Op = compiler.build_python_component(
    base_image = 'tensorflow/tensorflow:1.10.0',
    component_func = python_Func,
    staging_gcs_path = OUTPUT_DIR,
    target_image = 'gcr.io/' + PROJECT_NAME + '/component-p2:latest')
P3Op = compiler.build_python_component(
    base_image = 'tensorflow/tensorflow:1.10.0-py3',
    component_func = python_Func,
    staging_gcs_path = OUTPUT_DIR,
    target_image = 'gcr.io/' + PROJECT_NAME + '/component-p3:latest')

In the python 2 image, I get the following error:

ImportError: No module named 'tensorflow'

In the python3 image, the component runs fine.

@gaoning777
Copy link
Contributor

By default, the build_python_component configures the entrypoint as python3. That is why in python2 images, the tensorflow package is not found when you run python3 program.
To support this, we need to change the component builder to make the entrypoint configurable.

@gaoning777
Copy link
Contributor

fixing it in #730

@gaoning777
Copy link
Contributor

Now the component build supports python2. Fixed

@Ark-kun
Copy link
Contributor

Ark-kun commented Jul 26, 2019

def python_Func() -> str:

We only support Python 3.5+ officially.
Note that your function definition is only valid in Python 3.5+. It's a limitation of python, not Pipelines.

HumairAK pushed a commit to red-hat-data-services/data-science-pipelines that referenced this issue Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants