Skip to content

Commit

Permalink
Update Dependencies and use Python 3.12 (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmsmkn authored Jun 17, 2024
1 parent 48336b1 commit cffa44e
Show file tree
Hide file tree
Showing 10 changed files with 318 additions and 332 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
- published

env:
PYTHON_VERSION: '3.11'
PYTHON_VERSION: '3.12'

concurrency:
group: ${{ github.head_ref || github.run_id }}
Expand Down Expand Up @@ -48,7 +48,6 @@ jobs:
run: |
poetry install
poetry run make -C dist clean
poetry run make -C dist all
- name: Run pytest
run: poetry run pytest

Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ repos:
hooks:
- id: pyupgrade
language: python
args: [--py311-plus]
args: [--py312-plus]
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11
FROM python:3.12

RUN mkdir -p /opt/src/dist

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The application contains:
- A `fastapi` web server that implements the SageMaker endpoints
- and `pydantic` models that interface between S3, and run the original inference jobs.

The application is compiled on Python 3.11 using `pyinstaller`, and then distributed as a statically linked binary using `staticx`.
The application is compiled on Python 3.12 using `pyinstaller`, and then distributed as a statically linked binary using `staticx`.
It is able to adapt any container, including ones based on `scratch` or `alpine` images.

## Usage
Expand Down
4 changes: 2 additions & 2 deletions dist/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ sagemaker-shim-static-${TEST_VERSION}: sagemaker-shim-${TEST_VERSION}
staticx "sagemaker-shim-${TEST_VERSION}" "sagemaker-shim-static-${TEST_VERSION}"

crane-src.tar.gz:
curl -L https://github.com/google/go-containerregistry/releases/download/v0.17.0/go-containerregistry_Linux_x86_64.tar.gz -o crane-src.tar.gz && \
echo "1b4d3ee1e214776bd74b88741ccf1b070e8ed5660056f05af632a1a399fe21c6 crane-src.tar.gz" | shasum -c - || exit 1
curl -L https://github.com/google/go-containerregistry/releases/download/v0.19.2/go-containerregistry_Linux_x86_64.tar.gz -o crane-src.tar.gz && \
echo "8e5a27413b3fa3b95467c8d36dfb55f7109075872a05fcc0dd674f537439513d crane-src.tar.gz" | shasum -c - || exit 1

crane: crane-src.tar.gz
tar -xzvf crane-src.tar.gz crane && \
Expand Down
620 changes: 304 additions & 316 deletions poetry.lock

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "sagemaker-shim"
version = "0.3.0a2"
version = "0.3.0"
description = "Adapts algorithms that implement the Grand Challenge inference API for running in SageMaker"
authors = ["James Meakin <[email protected]>"]
license = "Apache-2.0"
Expand All @@ -16,8 +16,8 @@ sagemaker-shim = "sagemaker_shim.cli:cli"

[tool.poetry.dependencies]
# Only support one version of python at a time
python = "^3.11,<3.12"
fastapi = "!=0.89.0"
python = "^3.12,<3.13"
fastapi = "!=0.89.0,<0.111.0" # See https://github.com/DIAGNijmegen/rse-sagemaker-shim/issues/26
uvicorn = "*"
click = "*"
boto3 = "*"
Expand Down Expand Up @@ -48,7 +48,7 @@ line_length = 79

[tool.black]
line-length = 79
target-version = ['py311']
target-version = ['py312']

[tool.pytest.ini_options]
markers = [
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[mypy]
python_version = 3.11
python_version = 3.12
plugins = pydantic.mypy
strict = True

Expand Down
4 changes: 2 additions & 2 deletions tests/test_container_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _container_helper(request) -> None:
def _container(*, base_image="ubuntu:latest", host_port=8080, cmd=None):
client = docker.from_env()
registry = client.containers.run(
image="registry:2.7",
image="registry:2",
ports={5000: None},
auto_remove=True,
detach=True,
Expand Down Expand Up @@ -181,7 +181,7 @@ def test_alpine_image(minio):
# https://github.com/JonathonReinhart/staticx/issues/143
host_port = 8081
with _container(
base_image="python:3.11-alpine",
base_image="python:3.12-alpine",
host_port=host_port,
cmd=["python", "-c", "print('hello_world')"],
):
Expand Down
3 changes: 1 addition & 2 deletions tests/test_patch_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _registry_helper(request) -> None:
def registry():
client = docker.from_env()
registry = client.containers.run(
image="registry:2.7",
image="registry:2",
ports={5000: None},
auto_remove=True,
detach=True,
Expand Down Expand Up @@ -76,7 +76,6 @@ def test_patch_image(registry):
assert new_config["config"]["Entrypoint"] == ["/sagemaker-shim"]
assert "Cmd" not in new_config["config"]
assert set(new_config["config"]["Env"]) == {
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GRAND_CHALLENGE_COMPONENT_CMD_B64J=WyJzaCJd",
"GRAND_CHALLENGE_COMPONENT_ENTRYPOINT_B64J=bnVsbA==",
"GRAND_CHALLENGE_COMPONENT_USER=0:0",
Expand Down

0 comments on commit cffa44e

Please sign in to comment.