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

Fix 330: dealing with multiple python versions and pip #331

Merged
merged 18 commits into from
May 6, 2019

Conversation

tonyyang-svail
Copy link
Collaborator

Fix #330

wangkuiyi
wangkuiyi previously approved these changes May 4, 2019
Dockerfile Outdated
@@ -1,13 +1,19 @@
FROM ubuntu:16.04

RUN apt-get update
RUN apt-get install -y python3-pip
RUN apt-get install -y wget curl python3-pip
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: I found using a python version manager, such as conda, pyenv, is more convenient. For example, we are using this approach in tf-plus: https://github.com/tensorflow/io/blob/master/dev/Dockerfile#L19

Copy link
Collaborator Author

@tonyyang-svail tonyyang-svail May 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zou000 Thanks for the suggestion. Indeed, adding source activate tfio-dev to ~/.bashrc neatly isolate the Linux built-in Python2 and our Python3. This approach avoids the error-prone

# Make python3 as default Python interpreter
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN chmod +x /usr/bin/python

Copy link
Collaborator Author

@tonyyang-svail tonyyang-svail May 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zou000 enabling python env in .bashrc has certain drawbacks. For example, if you do docker run image_name bash test.sh i.e. non-interactive bash, .bashrc is skipped, so the python env is not activated. One workaround is to define the source activate in entrypoint.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can think of 2 other ways:

  1. Invoke bash interactively e.g. docker run image_name bash -i test.sh
  2. The idea of a pyenv is very simple, it just needs to find the python binary under the env root dir, e.g. in your case, you just need to modify PATH:
ENV PATH=/miniconda/envs/sqlflow-dev/bin:$PATH

I like the PATH approach better. You can verify the result by:

docker run image_name python -c 'import sys; print(sys.path)'

Dockerfile Outdated Show resolved Hide resolved
@tonyyang-svail
Copy link
Collaborator Author

tonyyang-svail commented May 5, 2019

CI failed at

=== RUN   TestExecutorTrainAndPredictDNN
FAIL	github.com/sql-machine-learning/sqlflow/sql	0.265s

Update: TestExecutorTrainAndPredictDNN failed because go test was not able to find tensorflow Python package. Because we enable the Python virtual environment in .bashrc, but .bashrc is skipped on non-interactive bashes such as docker run image_names bash test.sh.

RUN pip3 install tensorflow==2.0.0-alpha0
RUN pip3 install mysql-connector-python
RUN pip3 install pyhive
# Miniconda - Python 3.6, 64-bit, x86, latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are duplicating some code in .Dev, can we group the duplicated ones and add some notes in case when they need to be synchronized?

Copy link
Collaborator

@weiguoz weiguoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@weiguoz weiguoz self-requested a review May 6, 2019 04:38
@tonyyang-svail tonyyang-svail merged commit ff96c18 into sql-machine-learning:develop May 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Continuous integration fails
5 participants