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 Python version pin #2085

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion images/docker-stacks-foundation/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ RUN set -x && \
'jupyter_core' && \
rm -rf /tmp/bin/ && \
# Pin major.minor version of python
mamba list python | grep '^python ' | tr -s ' ' | cut -d ' ' -f 1,2 >> "${CONDA_DIR}/conda-meta/pinned" && \
# https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html#preventing-packages-from-updating-pinning
Copy link
Member Author

Choose a reason for hiding this comment

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

Future contributors will be happy to see it's an official and recommended way of pinning packages.

mamba list --full-name 'python' | tail -1 | tr -s ' ' | cut -d ' ' -f 1,2 | sed 's/\.[^.]*$/.*/' >> "${CONDA_DIR}/conda-meta/pinned" && \
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 simplified a little bit the command here, --full-name is exactly what we need.
I used sed command from @ehfd issue: #2084 (comment), but removed extra space it was adding there.

mamba clean --all -f -y && \
fix-permissions "${CONDA_DIR}" && \
fix-permissions "/home/${NB_USER}"
Expand Down
10 changes: 10 additions & 0 deletions tests/docker-stacks-foundation/test_python_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,13 @@ def test_python_version(container: TrackedContainer) -> None:
major_minor_version = full_version[: full_version.rfind(".")]

assert major_minor_version == EXPECTED_PYTHON_VERSION


def test_python_pinned_version(container: TrackedContainer) -> None:
LOGGER.info(f"Checking that pinned python version is {EXPECTED_PYTHON_VERSION}.*")
logs = container.run_and_wait(
timeout=5,
tty=True,
command=["cat", "/opt/conda/conda-meta/pinned"],
)
assert logs.startswith(f"python {EXPECTED_PYTHON_VERSION}.*")