Skip to content

Commit 15253e3

Browse files
[CIVIS-9806] ENH update civis-python to v2.4.0; add uv (#99)
* ENH update base image to python 3.12.7 * ENH update core dependency versions * FIX include awscli v2 in requirements files * TST expected shell commands should be available * ENH add uv to image * MAINT update changelog * FIX version env vars * MAINT update readme * MAINT always build images for dev branches * TST add an apt-get test * FIX set env var for uv to use system python * STY typos * TST uv
1 parent 739d8b6 commit 15253e3

9 files changed

+116
-44
lines changed

.circleci/test_image.py

+29
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
import os
44
import re
5+
import shutil
6+
import subprocess
57
import unittest
68

79

10+
# Just use the stdlib's `unittest` rather than needing to install `pytest`.
811
class TestImage(unittest.TestCase):
912

1013
def test_version(self):
@@ -42,6 +45,32 @@ def test_civis_can_import(self):
4245
import civis.ml # noqa: F401
4346
import civis.utils # noqa: F401
4447

48+
def test_shell_commands_available(self):
49+
"""Ensure the main shell commands are available."""
50+
# A non-exhaustive list of commands -- we just test those we'd likely use.
51+
expected_cmds = "aws civis curl git pip python unzip uv wget".split()
52+
for cmd in expected_cmds:
53+
self.assertIsNotNone(shutil.which(cmd), f"{cmd} not found in PATH")
54+
55+
def _test_shell_command(self, cmd: str):
56+
"""Check if the shell command runs successfully in the image."""
57+
try:
58+
subprocess.check_call(cmd, shell=True)
59+
except subprocess.CalledProcessError as e:
60+
self.fail(
61+
f"apt-get test failed with return code {e.returncode}\n"
62+
f"stdout: {e.stdout}\n"
63+
f"stderr: {e.stderr}"
64+
)
65+
66+
def test_apt_get(self):
67+
"""Ensure that apt-get works in the image."""
68+
self._test_shell_command("apt-get update -y && apt-get install -y htop")
69+
70+
def test_uv(self):
71+
"""Ensure that uv works in the image."""
72+
self._test_shell_command("uv pip install python-iso639")
73+
4574

4675
if __name__ == "__main__":
4776
unittest.main()

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,19 @@ Version number changes (major.minor.micro) in this package denote the following:
99

1010
## Unreleased
1111

12+
## [8.1.0]
13+
14+
- Python version updated to v3.12.7
15+
- Core dependencies updated to latest versions:
16+
* awscli 2.17.37 -> 2.19.5
17+
* boto3 1.34.127 -> 1.35.58
18+
* civis 2.3.0 -> 2.4.0
19+
* numpy 2.0.0 -> 2.1.3
20+
* pandas 2.2.2 -> 2.2.3
21+
* scikit-learn 1.5.0 -> 1.5.2
22+
* scipy 1.13.1 -> 1.14.1
23+
- uv added to the image
24+
1225
## [8.0.1]
1326

1427
- Python version updated to v3.12.6

Dockerfile

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG PLATFORM=linux/x86_64
2-
ARG BASE_IMAGE=python:3.12.6-slim
2+
ARG BASE_IMAGE=python:3.12.7-slim
33

44
# This is the primary build target used for the production image
55
FROM --platform=$PLATFORM $BASE_IMAGE AS production
@@ -37,25 +37,24 @@ COPY requirements-full.txt .
3737
RUN pip install --progress-bar off --no-cache-dir -r requirements-full.txt && \
3838
rm requirements-full.txt
3939

40+
# Install uv.
41+
ADD https://astral.sh/uv/0.5.1/install.sh /uv-installer.sh
42+
RUN sh /uv-installer.sh && rm /uv-installer.sh
43+
ENV PATH="/root/.local/bin/:$PATH" \
44+
UV_SYSTEM_PYTHON=1
45+
4046
# Instruct joblib to use disk for temporary files. Joblib defaults to
4147
# /shm when that directory is present. In the Docker container, /shm is
4248
# present but defaults to 64 MB.
4349
# https://github.com/joblib/joblib/blob/0.11/joblib/parallel.py#L328L342
4450
ENV JOBLIB_TEMP_FOLDER=/tmp
4551

46-
ENV VERSION=8.0.1 \
52+
ENV VERSION=8.1.0 \
4753
VERSION_MAJOR=8 \
48-
VERSION_MINOR=0 \
49-
VERSION_MICRO=1
50-
51-
# Install the AWSCLI for moving match targets in the QC workflow.
52-
# See https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html#cliv2-linux-install
53-
RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" && \
54-
unzip awscliv2.zip && \
55-
./aws/install && \
56-
rm -rf aws awscliv2.zip
54+
VERSION_MINOR=1 \
55+
VERSION_MICRO=0
5756

58-
# This build target is for testing in Circle CI.
57+
# This build target is for testing in CircleCI.
5958
FROM --platform=$PLATFORM production AS test
6059
COPY .circleci/test_image.py .
6160
COPY CHANGELOG.md .

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ default location for staging temporary files to the /tmp directory.
6666
The normal default is /shm. /shm is a RAM disk which defaults to a 64 MB size
6767
in Docker containers, too small for typical scientific computing.
6868

69-
# Updating existing PyPi Package Version
70-
1. Update version of existing package in `requirements-core.txt`
69+
# Updating Existing Package Versions
70+
1. Update versions of existing packages in `requirements-core.txt`
7171
2. Run script `generate-requirements-full.sh`
7272

7373
# Creating Equivalent Local Environments
@@ -88,7 +88,7 @@ and describe any changes in the [change log](CHANGELOG.md).
8888
## For Maintainers
8989

9090
This repo has autobuild enabled. Any PR that is merged to master will
91-
be built as the `latest` tag on Dockerhub.
91+
be built as the `latest` tag on DockerHub.
9292
Once you are ready to create a new version, go to the "releases" tab of the repository and click
9393
"Draft a new release". GitHub will prompt you to create a new tag, release title, and release
9494
description. The tag should use semantic versioning in the form "vX.X.X"; "major.minor.micro".

buildspec/push.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ phases:
1010
- echo $COMMIT_HASH_SHORT
1111
- echo $BRANCH_NAME
1212
- docker build --tag ${FIPS_REPOSITORY_URI}:${COMMIT_HASH_SHORT} --tag ${FIPS_REPOSITORY_URI}:${BRANCH_NAME} .
13-
# This config tests the codebuild login and the build but does not push dev images.
14-
# The following lines can be temporarily uncommented to test a dev image.
15-
# - docker image push --all-tags ${FIPS_REPOSITORY_URI}
13+
# We have a life cycle policy in place to expire and delete images from dev branches,
14+
# so there are no issues with pushing as many of these images as there may be.
15+
- docker image push --all-tags ${FIPS_REPOSITORY_URI}
1616
post_build:
1717
commands:
1818
- echo Build completed!

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ services:
88
- .:/app
99
stdin_open: true
1010
tty: true
11-
working_dir: /app
11+
working_dir: /app

generate-requirements-full.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
# Run this script to update requirements-core.txt.
33
# It uses Docker to ensure that the environment matches what will be used in the production image.
44
set -e
5-
docker compose run --rm pip-tools /bin/sh -c "pip install --upgrade pip-tools && pip-compile --output-file=requirements-full.txt --pip-args='--prefer-binary' --strip-extras --upgrade requirements-core.txt"
5+
docker compose run --rm pip-tools /bin/sh -c "apt-get update -y && apt-get install -y git && pip install --upgrade pip-tools && pip-compile --output-file=requirements-full.txt --pip-args='--prefer-binary' --strip-extras --upgrade requirements-core.txt"

requirements-core.txt

+10-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
boto3==1.34.127
2-
civis==2.3.0
3-
numpy==2.0.0
4-
pandas==2.2.2
1+
# awscli v2 is not officially available on PyPI (https://github.com/aws/aws-cli/issues/4947).
2+
# Specifying awscli in requirements-core.txt here ensures that it (and its transitive dependencies)
3+
# are taken into account when generating the final requirements-full.txt file.
4+
awscli @ git+https://github.com/aws/[email protected]
5+
boto3==1.35.58
6+
civis==2.4.0
7+
numpy==2.1.3
8+
pandas==2.2.3
59
requests==2.32.3
6-
scikit-learn==1.5.0
7-
scipy==1.13.1
10+
scikit-learn==1.5.2
11+
scipy==1.14.1

requirements-full.txt

+45-18
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,41 @@ attrs==24.2.0
88
# via
99
# jsonschema
1010
# referencing
11-
boto3==1.34.127
11+
awscli @ git+https://github.com/aws/[email protected]
1212
# via -r requirements-core.txt
13-
botocore==1.34.162
13+
awscrt==0.22.0
14+
# via awscli
15+
boto3==1.35.58
16+
# via -r requirements-core.txt
17+
botocore==1.35.58
1418
# via
1519
# boto3
1620
# s3transfer
17-
certifi==2024.7.4
21+
certifi==2024.8.30
1822
# via requests
19-
charset-normalizer==3.3.2
23+
cffi==1.17.1
24+
# via cryptography
25+
charset-normalizer==3.4.0
2026
# via requests
21-
civis==2.3.0
27+
civis==2.4.0
2228
# via -r requirements-core.txt
2329
click==8.1.7
2430
# via civis
25-
cloudpickle==3.0.0
31+
cloudpickle==3.1.0
2632
# via civis
27-
idna==3.8
33+
colorama==0.4.6
34+
# via awscli
35+
cryptography==43.0.1
36+
# via awscli
37+
distro==1.8.0
38+
# via awscli
39+
docutils==0.19
40+
# via awscli
41+
idna==3.10
2842
# via requests
2943
jmespath==1.0.1
3044
# via
45+
# awscli
3146
# boto3
3247
# botocore
3348
joblib==1.4.2
@@ -38,21 +53,26 @@ jsonref==1.1.0
3853
# via civis
3954
jsonschema==4.23.0
4055
# via civis
41-
jsonschema-specifications==2023.12.1
56+
jsonschema-specifications==2024.10.1
4257
# via jsonschema
43-
numpy==2.0.0
58+
numpy==2.1.3
4459
# via
4560
# -r requirements-core.txt
4661
# pandas
4762
# scikit-learn
4863
# scipy
49-
pandas==2.2.2
64+
pandas==2.2.3
5065
# via -r requirements-core.txt
51-
python-dateutil==2.9.0.post0
66+
prompt-toolkit==3.0.38
67+
# via awscli
68+
pycparser==2.22
69+
# via cffi
70+
python-dateutil==2.9.0
5271
# via
72+
# awscli
5373
# botocore
5474
# pandas
55-
pytz==2024.1
75+
pytz==2024.2
5676
# via pandas
5777
pyyaml==6.0.2
5878
# via civis
@@ -64,15 +84,19 @@ requests==2.32.3
6484
# via
6585
# -r requirements-core.txt
6686
# civis
67-
rpds-py==0.20.0
87+
rpds-py==0.21.0
6888
# via
6989
# jsonschema
7090
# referencing
71-
s3transfer==0.10.2
91+
ruamel-yaml==0.17.21
92+
# via awscli
93+
ruamel-yaml-clib==0.2.8
94+
# via awscli
95+
s3transfer==0.10.3
7296
# via boto3
73-
scikit-learn==1.5.0
97+
scikit-learn==1.5.2
7498
# via -r requirements-core.txt
75-
scipy==1.13.1
99+
scipy==1.14.1
76100
# via
77101
# -r requirements-core.txt
78102
# scikit-learn
@@ -82,9 +106,12 @@ tenacity==9.0.0
82106
# via civis
83107
threadpoolctl==3.5.0
84108
# via scikit-learn
85-
tzdata==2024.1
109+
tzdata==2024.2
86110
# via pandas
87-
urllib3==2.2.2
111+
urllib3==1.26.20
88112
# via
113+
# awscli
89114
# botocore
90115
# requests
116+
wcwidth==0.2.13
117+
# via prompt-toolkit

0 commit comments

Comments
 (0)