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

backend: Pin python dependencies #3161

Merged

Conversation

discordianfish
Copy link
Member

@discordianfish discordianfish commented Feb 24, 2020

Builds/tests failed due to broken transident dependencies. This pins the
python dependencies to prevent this in the future.

The requirements.txt was created by running python3 -m pip install tfx==0.21.0 && python3 -m pip freeze in the current python:3.5 image


This change is Reviewable

@discordianfish
Copy link
Member Author

/retest

@Bobgy
Copy link
Contributor

Bobgy commented Feb 24, 2020

Thanks! looks like a first step of #3078.

@@ -0,0 +1,124 @@
absl-py==0.8.1
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be better if

The requirements.txt was created by running python3 -m pip install tfx==0.21.0 && python3 -m pip freeze in the current python:3.5 image

is clearly documented inside code instead of in the PR.

Did you ever try pip-tools? Would a separate requirements.in file for direct deps and a compiled requirements.txt suit this model better?

Copy link
Member Author

Choose a reason for hiding this comment

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

I just ran into the problem with unpinned dependencies, so fixed it in the most obvious way. I did't add the comment because it didn't seem to matter to me outside the context of the commit, because well, given subsequent runs of that command will yield a different requirements.txt.

Re/ pip-tools, not familiar with it. I don't do much python. Feel free to replace this PR with something better.

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought that comment is useful because we will probably install more dependencies/uninstall some dependencies from time to time. It will be a disaster to not know which ones are the actual direct dependencies.

Copy link
Contributor

Choose a reason for hiding this comment

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

/assign @Ark-kun
/assign @numerology
I'm not familiar with python env too. They will be able to help.

@discordianfish
Copy link
Member Author

Since I again ran into a failed test due to changed, unpinned dependencies, I'm looking into pip-tools for both. Stay tuned.

@discordianfish
Copy link
Member Author

/retest

@discordianfish
Copy link
Member Author

Looks like the dependencies as resolved on my local machine somehow don't work in CI.. So I guess we need to run pip-compile in the same docker image.
Any preferences how to update them? Is a comment in the README like this sufficient?

Copy link
Contributor

@Bobgy Bobgy left a comment

Choose a reason for hiding this comment

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

/lgtm
Thanks! This looks great to me.
Only one comment left.

@numerology @Ark-kun for more review.

RUN wget https://bootstrap.pypa.io/get-pip.py && python3 get-pip.py
RUN python3 -m pip install tfx==0.21.0
apt-get install --no-install-recommends -y -q default-jdk python3-setuptools python3-dev && \
pip install pip-tools==4.5.0
Copy link
Contributor

Choose a reason for hiding this comment

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

pip-tools is redundant here, right?

@Bobgy
Copy link
Contributor

Bobgy commented Feb 26, 2020

I think you can document this command, run it in the path with requirements.in:

docker run -v $(pwd):/host python:3.5 bash -c "pip install pip-tools==4.5.0 && pip-compile /host/requirements.in --dry-run"

and copy the generated content to requirements.txt (because if we generates requirements.txt in docker, it will be owned by root).

@discordianfish
Copy link
Member Author

Yeah haven't push my latest revision. Should be there in a bit.

@discordianfish
Copy link
Member Author

Ok this should be it. I've moved the command to a script and added a README to sample-test as well.

Copy link
Contributor

@Bobgy Bobgy left a comment

Choose a reason for hiding this comment

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

/lgtm
Thank you for your contribution! This is great.

One last comment

#!/bin/bash
set -euo pipefail

exec docker run -v "$PWD:/src" -w /src --rm python:3.5 bash \
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you!

Can you duplicate this script in sample-test folder too?
Very useful!

Copy link
Member Author

Choose a reason for hiding this comment

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

Hrm it can be invoked from sample-test, which is mentioned in the README I've created there. Maybe we should move it to the root of the repo? Or in /bin or /hack or something?

RUN pip3 install tfx==0.21.0

COPY ./test/sample-test/requirements.txt /python/src/github.com/kubeflow/pipelines/test/sample-test/requirements.txt
RUN pip3 install -r /python/src/github.com/kubeflow/pipelines/test/sample-test/requirements.txt
Copy link
Contributor

Choose a reason for hiding this comment

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

@discordianfish actually, this uses a google/cloud-sdk:279.0.0 image, can you try pinning dependency in this image.

@k8s-ci-robot k8s-ci-robot removed the lgtm label Feb 26, 2020
@discordianfish discordianfish force-pushed the python-pin-dependencies branch 3 times, most recently from 0ab6975 to f879307 Compare March 4, 2020 16:07
Builds/tests failed due to broken transident dependencies. This pins the
python dependencies to prevent this in the future.
@discordianfish
Copy link
Member Author

Ok tests pass now! @Ark-kun @Bobgy @numerology can you approve (again)?

@Bobgy
Copy link
Contributor

Bobgy commented Mar 5, 2020

Awesome, great thanks!
/lgtm
/approve

@jingzhang36 for backend approval
@Ark-kun @numerology for sample test approval

Didn't realize I have permission too for test folder

@discordianfish
Copy link
Member Author

/assign @rmgogogo

Let's get this merged before it outdates again :)

@jingzhang36
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Bobgy, jingzhang36

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit 7e610d1 into kubeflow:master Mar 5, 2020
Jeffwan pushed a commit to Jeffwan/pipelines that referenced this pull request Dec 9, 2020
* backend: Pin python dependencies

Builds/tests failed due to broken transident dependencies. This pins the
python dependencies to prevent this in the future.

* Add README to test/sample-test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants