Skip to content

Fix docker #4230

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

Merged
merged 35 commits into from
Jun 30, 2021
Merged

Fix docker #4230

merged 35 commits into from
Jun 30, 2021

Conversation

shivanth
Copy link
Contributor

@shivanth shivanth requested review from cduck, vtomole and a team as code owners June 19, 2021 06:46
@shivanth shivanth requested a review from tanujkhattar June 19, 2021 06:46
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Jun 19, 2021
Copy link
Contributor

@balopat balopat left a comment

Choose a reason for hiding this comment

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

Thank you, I think this looks good. As mentioned in the issue, can you add a test to ensure that it builds the right thing? I'm thinking of something simple, like, after building the image, assert that docker run cirq-image python -c "import cirq; assert cirq.__version__ is not None" succeeds or something similar.

@shivanth
Copy link
Contributor Author

shivanth commented Jun 23, 2021

I've added have the test , but unfortunately will need to disable it since the Github actions image does not have docker in it. The added test is also a longrun test, it will increase the pipeline completion time.
Will add a pytest marker and remove this test from CI executions

@balopat
Copy link
Contributor

balopat commented Jun 23, 2021

This is great! We don't need the marker - we should just limit that test to Linux only.

@shivanth
Copy link
Contributor Author

shivanth commented Jun 23, 2021

we should just limit that test to Linux only.

Is there a way to selectively run tests based on os type/version?
One other way would be to setup a different github action to run docker tests.

@balopat
Copy link
Contributor

balopat commented Jun 23, 2021

we should just limit that test to Linux only.

Is there a way to selectively run tests based on os type/version?
One other way would be to setup a different github action to run docker tests.

I'd pull out the @only_on_posix decorator from below to a file called dev_tools/markers.py, import it in dev_tools/__init__.py and then you can just use it as @dev_tools.only_on_posix:

def only_on_posix(func):

@balopat
Copy link
Contributor

balopat commented Jun 23, 2021

we should just limit that test to Linux only.

Is there a way to selectively run tests based on os type/version?
One other way would be to setup a different github action to run docker tests.

I'd pull out the @only_on_posix decorator from below to a file called dev_tools/markers.py, import it in dev_tools/__init__.py and then you can just use it as @dev_tools.only_on_posix:

def only_on_posix(func):

Hmm...the Mac platform might match posix. We should use platform.

Also, as it's just a single test, an even simpler approach is just to have a simple if statement on top of the test which tests for Linux and if it's not, then use pytest.skip()

@shivanth
Copy link
Contributor Author

@balopat requesting review

@balopat
Copy link
Contributor

balopat commented Jun 25, 2021

I came up with a minimal python cirq installed docker image. This should serve as the base image for cirq docker

FROM python:3.8-slim AS compile-image

# Install dependencies.
# rm -rf /var/lib/apt/lists/* cleans up apt cache. See https://docs.docker.com/develop/develop-images/dockerfile_best-practices/
RUN DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \
     python3-pip \
     locales \
     && rm -rf /var/lib/apt/lists/*

# Configure UTF-8 encoding.
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && locale-gen
ENV LANG en_US.UTF-8  
ENV LANGUAGE en_US:en  
ENV LC_ALL en_US.UTF-8 

# Make python3 default
RUN rm -f /usr/bin/python \
     && ln -s /usr/bin/python3 /usr/bin/python

# Install cirq
RUN pip3 install cirq

We have to decide what we want to do with Docker.

  1. A base docker image that has cirq pre-installed - this is the minimum requirement
  2. Another image , like the above , for pre-release versions as well.
  3. Since notebooks are a thing with cirq, it might be worthwhile investing in an image that can support notebooks out of the box.

I like the combined stable / pre multi-stage image.
The notebook idea is valid as well - but then we have to figure out how to copy the right notebooks to the image - some notebooks will only work with pre and won't work with the stable version...I guess the user can figure that out then and use the pre image?

@shivanth shivanth requested a review from balopat June 29, 2021 13:50
Copy link
Contributor

@balopat balopat 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, it's much better for now.
Eventually we can evolve this further if there is user feedback.

@balopat balopat added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 30, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jun 30, 2021
@CirqBot
Copy link
Collaborator

CirqBot commented Jun 30, 2021

Automerge cancelled: A required status check is not present.

Missing statuses: ['cla/google']

@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jun 30, 2021
@shivanth
Copy link
Contributor Author

xref #3736

@balopat balopat added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jun 30, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jun 30, 2021
@CirqBot CirqBot merged commit 1433621 into quantumlib:master Jun 30, 2021
@CirqBot CirqBot removed automerge Tells CirqBot to sync and merge this PR. (If it's running.) front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. labels Jun 30, 2021
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants