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

RHOAIENG-9707: chore(tests/containers): try to install the cowsay package to check the python venv is writable #873

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jiridanek
Copy link
Member

https://issues.redhat.com/browse/RHOAIENG-9707

Description

  _________________________________________________
 /                                                 \
| Checks that the Python virtualenv in the image is |
|  writable.                                        |
 \                                                 /
  =================================================
                                                 \
                                                  \
                                                    ^__^
                                                    (oo)\_______
                                                    (__)\       )\/\
                                                        ||----w |
                                                        ||     ||

How Has This Been Tested?

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Copy link
Contributor

openshift-ci bot commented Jan 29, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from jiridanek. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@openshift-ci openshift-ci bot added the size/s label Jan 29, 2025
@jstourac
Copy link
Member

LGTM, just wondering whether we should rather/also check the variant where python3 isn't used in the command. I mean, when user will simply execute pip install cowsay and then cowsay -t Hello. Technically these results should be identical as the very same python env should be used in both cases. 🤔

@jiridanek
Copy link
Member Author

We should rather/also check the variant where python3 isn't used in the command. I mean, when user will simply execute pip install cowsay and then cowsay -t Hello.

I don't know. @opendatahub-io/notebook-devs, thoughts? Thanks.

Copy link
Contributor

openshift-ci bot commented Jan 29, 2025

@jiridanek: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/images a171ed9 link true /test images

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@daniellutz
Copy link
Contributor

from my understanding, the python3 -m pip install command would be more reliable, because you are already specifying the desired python version on it, and to me, technically, python3 -m pip install and pip install would be the same, so no issues regarding that, from my understanding.

this one looks good to me!

/lgtm

@jiridanek
Copy link
Member Author

because you are already specifying the desired python version on it

we're already in a python virtual environment when the image starts, and that sets up PATH to /opt/app-root/bin, where pip is present; so although in general case python3 -m pip is preferable, and /opt/app-root/bin/python3 -m pip is even better, in this case should be all the same.

the setting of python virtual env for auto activation is done through some magic around BASH_ENV variable.

    # The following echo adds the unset command for the variables set below to the \
    # venv activation script. This is inspired from scl_enable script and prevents \
    # the virtual environment to be activated multiple times and also every time \
    # the prompt is rendered. \
    echo "unset BASH_ENV PROMPT_COMMAND ENV" >> ${APP_ROOT}/bin/activate

# For RHEL/Centos 8+ scl_enable isn't sourced automatically in s2i-core
# so virtualenv needs to be activated this way
ENV BASH_ENV="${APP_ROOT}/bin/activate" \
    ENV="${APP_ROOT}/bin/activate" \
    PROMPT_COMMAND=". ${APP_ROOT}/bin/activate"

https://github.com/sclorg/s2i-python-container/blob/master/3.11/Dockerfile.rhel9#L84-L94

I was looking into it for

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.

3 participants