Skip to content

Commit 40f88cb

Browse files
[CIVIS-2325] DEP upgrade to Python 3.12, update dependency versions (#94)
* DEP use python 3.12, update dependency versions * TST drop legacy test for numpy not using mkl * MAINT update changelog * DEP refresh req files for requests * TST set up test suite * MAINT add github templates * TST close file object properly * TST run test suite in verbose mode
1 parent 3b879f4 commit 40f88cb

File tree

10 files changed

+130
-71
lines changed

10 files changed

+130
-71
lines changed

.circleci/config.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
1-
version: 2
1+
version: 2.1
22
jobs:
33
build:
44
docker:
5-
- image: circleci/python:3.7.0
5+
- image: cimg/python:3.12
66
steps:
77
- checkout
88
- setup_remote_docker
99
- run:
1010
name: Build container
11-
command: docker build -t ds-python .
11+
command: docker build --target test -t ds-python .
1212
- run:
1313
name: Verify build completed
1414
command: docker run ds-python /bin/bash -c "echo BUILDS OK"
1515
- run:
16-
name: Check that scipy links to OpenBLAS
17-
command: docker run ds-python python -c "from scipy.linalg import _fblas"
18-
- run:
19-
name: Check that numpy imports from bash shell
20-
command: docker run -t ds-python /bin/bash -c "python -c 'import numpy'"
21-
- run:
22-
name: Verify that numpy does not link to MKL
23-
command: docker run ds-python python -c "from numpy.distutils import system_info; assert system_info.get_info('mkl') == {}"
24-
- run:
25-
name: Validate compatability of civis-python with other packages
26-
command: docker run ds-python /bin/bash -c "python -c 'import civis'"
27-
- run:
28-
name: Run numpy unit tests
29-
command: docker run ds-python /bin/bash -c 'pip install pytest hypothesis; python -c "import numpy; numpy.test()"'
16+
name: Run tests
17+
command: docker run ds-python /test_image.py -vv

.circleci/test_image.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
3+
import os
4+
import re
5+
import unittest
6+
7+
8+
class TestImage(unittest.TestCase):
9+
10+
def test_version(self):
11+
version_in_env_var = os.getenv("VERSION")
12+
major = os.getenv("VERSION_MAJOR")
13+
minor = os.getenv("VERSION_MINOR")
14+
micro = os.getenv("VERSION_MICRO")
15+
self.assertTrue(major.isdigit())
16+
self.assertTrue(minor.isdigit())
17+
self.assertTrue(micro.isdigit())
18+
self.assertEqual(version_in_env_var, f"{major}.{minor}.{micro}")
19+
20+
with open("CHANGELOG.md") as changelog:
21+
version_in_changelog = re.search(
22+
r"##\s+\[(\d+\.\d+\.\d+)]", changelog.read()
23+
).groups()[0]
24+
self.assertEqual(version_in_changelog, version_in_env_var)
25+
26+
def test_scipy_links_to_openblas(self):
27+
from scipy.linalg import _fblas # noqa: F401
28+
29+
def test_numpy_can_import(self):
30+
import numpy as np # noqa: F401
31+
32+
def test_civis_can_import(self):
33+
import civis # noqa: F401
34+
35+
36+
if __name__ == "__main__":
37+
unittest.main()

.github/ISSUE_TEMPLATE/general.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
name: General
3+
about: Ask a question, report a potential issue, etc.
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
**Note:** Civis employees should _not_ use the GitHub Issues feature at the public "civis-python" codebase
11+
to file a ticket, and should instead use the internal ticketing system.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
3+
---
4+
5+
- [ ] (For Civis employees only) Reference to a relevant ticket in the pull request title
6+
- [ ] Changelog entry added to `CHANGELOG.md` at the repo's root level
7+
- [ ] Description of change in the pull request description
8+
- [ ] If applicable, unit tests have been added and/or updated
9+
- [ ] The CircleCI builds have all passed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ Version number changes (major.minor.micro) in this package denote the following:
99

1010
## Unreleased
1111

12+
## [7.1.0]
13+
- Python updated to v3.12.3
14+
- Core dependencies updated to latest versions:
15+
* awscli 1.29.5 -> 1.32.109
16+
* boto3 1.28.5 -> 1.34.109
17+
* civis 1.16.1 -> 2.0.0
18+
* numpy 1.25.1 -> 1.26.4
19+
* pandas 2.0.3 -> 2.2.2
20+
* requests 2.31.0 -> 2.32.2
21+
* scikit-learn 1.3.0 -> 1.5.0
22+
* scipy 1.11.1 -> 1.13.0
23+
1224
## [7.0.0]
1325
- Python updated to v3.11.4
1426
- Refactors Dockerfile to use the official Python docker image

Dockerfile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.11.4-bookworm
1+
FROM python:3.12.3-slim AS production
22

33
LABEL maintainer = support@civisanalytics.com
44

@@ -35,7 +35,14 @@ RUN pip install -r requirements-full.txt && \
3535
# https://github.com/joblib/joblib/blob/0.11/joblib/parallel.py#L328L342
3636
ENV JOBLIB_TEMP_FOLDER=/tmp
3737

38-
ENV VERSION=7.0.0 \
38+
ENV VERSION=7.1.0 \
3939
VERSION_MAJOR=7 \
40-
VERSION_MINOR=0 \
40+
VERSION_MINOR=1 \
4141
VERSION_MICRO=0
42+
43+
FROM production AS test
44+
COPY .circleci/test_image.py .
45+
COPY CHANGELOG.md .
46+
47+
# Defaults to production as the final stage
48+
FROM production

README.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
[![CircleCI](https://circleci.com/gh/civisanalytics/datascience-python/tree/master.svg?style=svg)](https://circleci.com/gh/civisanalytics/datascience-python/tree/master)
44

5-
This image is created from the official Ubuntu 18.04 Docker image and contains popular Python packages for data science.
6-
7-
If you are reading this README on DockerHub, then the links to files in the GitHub respository will be broken. Please read this documentation from [GitHub](https://github.com/civisanalytics/datascience-python) instead.
5+
If you are reading this README on DockerHub, then the links to files in the GitHub repository will be broken. Please read this documentation from [GitHub](https://github.com/civisanalytics/datascience-python) instead.
86

97
# Introduction
108

@@ -35,7 +33,7 @@ to retrieve a reproducible environment.
3533

3634
Inside the datascience-python Docker image, Python packages are installed in the `root`
3735
environment. For a full list of included Python libraries, see the
38-
[environment.yml](environment.yml) file.
36+
[requirements-core.txt](requirements-core.txt) file.
3937

4038
To start a Docker container from the datascience-python image and
4139
interact with it from a bash prompt, use
@@ -56,7 +54,7 @@ VERSION_MAJOR
5654
VERSION_MINOR
5755
VERSION_MICRO
5856
```
59-
VERSION contains the full version string, e.g. "1.0.3". VERSION_MAJOR,
57+
VERSION contains the full version string, e.g., "1.0.3". VERSION_MAJOR,
6058
VERSION_MINOR, and VERSION_MICRO each contain a single integer.
6159

6260
## Joblib Temporary Files
@@ -68,10 +66,6 @@ default location for staging temporary files to the /tmp directory.
6866
The normal default is /shm. /shm is a RAM disk which defaults to a 64 MB size
6967
in Docker containers, too small for typical scientific computing.
7068

71-
# Install a new PyPi Package Dependency
72-
1. Add new dependency to `requirements-core.txt` file. Include the version
73-
2. Run script `generate-requirements-full.sh`
74-
7569
# Updating existing PyPi Package Version
7670
1. Update version of existing package in `requirements-core.txt`
7771
2. Run script `generate-requirements-full.sh`
@@ -96,7 +90,7 @@ and describe any changes in the [change log](CHANGELOG.md).
9690
This repo has autobuild enabled. Any PR that is merged to master will
9791
be built as the `latest` tag on Dockerhub.
9892
Once you are ready to create a new version, go to the "releases" tab of the repository and click
99-
"Draft a new release". Github will prompt you to create a new tag, release title, and release
93+
"Draft a new release". GitHub will prompt you to create a new tag, release title, and release
10094
description. The tag should use semantic versioning in the form "vX.X.X"; "major.minor.micro".
10195
The title of the release should be the same as the tag. Include a change log in the release description.
10296
Once the release is tagged, DockerHub will automatically build three identical containers, with labels

generate-requirements-full.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
#!/bin/bash
2-
pip install pip-tools
3-
pip-compile --output-file=requirements-full.txt --pip-args='--prefer-binary' requirements-core.txt
2+
python --version
3+
pip install --upgrade pip-tools
4+
pip-compile --output-file=requirements-full.txt --pip-args='--prefer-binary' --strip-extras --upgrade requirements-core.txt

requirements-core.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
awscli==1.29.5
2-
boto3==1.28.5
3-
civis==1.16.1
4-
numpy==1.25.1
5-
pandas==2.0.3
6-
requests==2.31.0
7-
scikit-learn==1.3.0
8-
scipy==1.11.1
1+
awscli==1.32.109
2+
boto3==1.34.109
3+
civis==2.0.0
4+
numpy==1.26.4
5+
pandas==2.2.2
6+
requests==2.32.2
7+
scikit-learn==1.5.0
8+
scipy==1.13.0

requirements-full.txt

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
#
2-
# This file is autogenerated by pip-compile with Python 3.11
2+
# This file is autogenerated by pip-compile with Python 3.12
33
# by the following command:
44
#
5-
# pip-compile --output-file=requirements-full.txt --pip-args='--prefer-binary' requirements-core.txt
5+
# pip-compile --output-file=requirements-full.txt --pip-args='--prefer-binary' --strip-extras requirements-core.txt
66
#
7-
attrs==23.1.0
7+
attrs==23.2.0
88
# via
99
# jsonschema
1010
# referencing
11-
awscli==1.29.5
11+
awscli==1.32.109
1212
# via -r requirements-core.txt
13-
boto3==1.28.5
13+
boto3==1.34.109
1414
# via -r requirements-core.txt
15-
botocore==1.31.5
15+
botocore==1.34.109
1616
# via
1717
# awscli
1818
# boto3
1919
# s3transfer
20-
certifi==2023.5.7
20+
certifi==2024.2.2
2121
# via requests
22-
charset-normalizer==3.2.0
22+
charset-normalizer==3.3.2
2323
# via requests
24-
civis==1.16.1
24+
civis==2.0.0
2525
# via -r requirements-core.txt
26-
click==8.1.6
26+
click==8.1.7
2727
# via civis
28-
cloudpickle==2.2.1
28+
cloudpickle==3.0.0
2929
# via civis
30-
colorama==0.4.4
30+
colorama==0.4.6
3131
# via awscli
3232
docutils==0.16
3333
# via awscli
34-
idna==3.4
34+
idna==3.7
3535
# via requests
3636
jmespath==1.0.1
3737
# via
@@ -41,65 +41,65 @@ joblib==1.2.0
4141
# via
4242
# civis
4343
# scikit-learn
44-
jsonref==0.2
44+
jsonref==1.1.0
4545
# via civis
46-
jsonschema==4.18.4
46+
jsonschema==4.22.0
4747
# via civis
48-
jsonschema-specifications==2023.7.1
48+
jsonschema-specifications==2023.12.1
4949
# via jsonschema
50-
numpy==1.25.1
50+
numpy==1.26.4
5151
# via
5252
# -r requirements-core.txt
5353
# pandas
5454
# scikit-learn
5555
# scipy
56-
pandas==2.0.3
56+
pandas==2.2.2
5757
# via -r requirements-core.txt
58-
pyasn1==0.5.0
58+
pyasn1==0.6.0
5959
# via rsa
60-
python-dateutil==2.8.2
60+
python-dateutil==2.9.0.post0
6161
# via
6262
# botocore
6363
# pandas
64-
pytz==2023.3
64+
pytz==2024.1
6565
# via pandas
6666
pyyaml==6.0.1
6767
# via
6868
# awscli
6969
# civis
70-
referencing==0.30.0
70+
referencing==0.35.1
7171
# via
7272
# jsonschema
7373
# jsonschema-specifications
74-
requests==2.31.0
74+
requests==2.32.2
7575
# via
7676
# -r requirements-core.txt
7777
# civis
78-
rpds-py==0.9.2
78+
rpds-py==0.18.1
7979
# via
8080
# jsonschema
8181
# referencing
8282
rsa==4.7.2
8383
# via awscli
84-
s3transfer==0.6.1
84+
s3transfer==0.10.1
8585
# via
8686
# awscli
8787
# boto3
88-
scikit-learn==1.3.0
88+
scikit-learn==1.5.0
8989
# via -r requirements-core.txt
90-
scipy==1.11.1
90+
scipy==1.13.0
9191
# via
9292
# -r requirements-core.txt
9393
# scikit-learn
9494
six==1.16.0
9595
# via python-dateutil
96-
tenacity==8.2.2
96+
tenacity==8.3.0
9797
# via civis
98-
threadpoolctl==3.2.0
98+
threadpoolctl==3.5.0
9999
# via scikit-learn
100-
tzdata==2023.3
100+
tzdata==2024.1
101101
# via pandas
102-
urllib3==1.26.16
102+
urllib3==2.2.1
103103
# via
104104
# botocore
105105
# requests

0 commit comments

Comments
 (0)