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

Switch to uv python tool #579

Merged
merged 39 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
93e99d5
Make packages easier to read
jeremyestein May 8, 2024
4b1f8fa
Remove unneeded packages
jeremyestein May 8, 2024
d087520
Merge three pixl python docker images into one multi-stage dockerfile to
jeremyestein May 8, 2024
1e1c18e
Specify healthcheck command in only one place
jeremyestein May 8, 2024
63d6edb
De-dupe the pre-reqs installation code using a build arg
jeremyestein May 8, 2024
46a08e0
De-dupe the actual install as well
jeremyestein May 8, 2024
3b0bac0
Unite orthanc Dockerfiles
jeremyestein May 21, 2024
418579a
Merge branch 'main' into jeremy/refactor-dockerfiles
jeremyestein Dec 18, 2024
98fa689
Further de-duping of code in Dockerfile to tidy up the merge
jeremyestein Dec 18, 2024
8ff1e3c
Remind developers that being in the virtual env with everything
jeremyestein Dec 16, 2024
fdb7bd8
First attempt at defining a UV workspace that brings together all the
jeremyestein Dec 18, 2024
9c52f3a
Create a .dockerignore (must be in build context root) and exclude some
jeremyestein Dec 19, 2024
2fc6f99
Put apt install and cleanup in the same RUN command so they have the
jeremyestein Dec 20, 2024
d94c35c
Install uv and use it to install our python packages
jeremyestein Dec 20, 2024
3dd2c9a
Make orthanc Dockerfile use uv
jeremyestein Dec 21, 2024
f58f3c1
Reference script in new layout (which is now closer to original sourc…
jeremyestein Dec 21, 2024
182490a
Need to expose the pytest_pixl module
jeremyestein Dec 21, 2024
04feb24
Update GHA tests to use uv
jeremyestein Dec 21, 2024
3b346a6
uv.lock file is supposed to be checked into source control (see
jeremyestein Dec 21, 2024
c65c6ca
Need to run inside the venv
jeremyestein Dec 21, 2024
e44d4be
Add setuptools for the sake of pydicom
jeremyestein Dec 21, 2024
48e5474
Add more build stages to avoid re-downloading spec (which is only needed
jeremyestein Jan 6, 2025
add1753
Use docker cache when running uv sync during build (only cache the uv
jeremyestein Jan 6, 2025
0fda05c
Add uv to pre-commit
jeremyestein Jan 8, 2025
3b3e176
Merge branch 'main' into jeremy/uv-python
jeremyestein Jan 8, 2025
aeba2be
Move dev/test dependencies to dependency group in root level pyprojec…
jeremyestein Jan 8, 2025
f1beece
Remove now redundant parameters from uv sync
jeremyestein Jan 9, 2025
91434e6
Merge branch 'main' into jeremy/uv-python
jeremyestein Jan 9, 2025
22558ab
Make non-editable top-level build work (was only including dev dirs
jeremyestein Jan 9, 2025
618a2f5
Add uv instructions to replace pip install calls
jeremyestein Jan 8, 2025
6df32e9
Remove setuptools dep as it does not in fact seem to be needed
jeremyestein Jan 9, 2025
806227b
Revert "Remove setuptools dep as it does not in fact seem to be needed"
jeremyestein Jan 9, 2025
c2a92c6
Merge branch 'main' into jeremy/uv-python
jeremyestein Jan 20, 2025
99d50a8
Consistently set all modules to require Python >=3.11
jeremyestein Jan 20, 2025
8512c9b
ruff fixes resulting from Python version change
jeremyestein Jan 20, 2025
5e5f516
Apply suggestions from code review
jeremyestein Jan 20, 2025
e9ec00c
Remove unnecessary line continuation characters
jeremyestein Jan 20, 2025
d78c148
Remove instructions for conda and venv
jeremyestein Jan 20, 2025
be5f8fb
Remove references to conda and venv as per review feedback
jeremyestein Jan 20, 2025
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
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**/build
.git
**/.mypy_cache
.venv*
**/.pytest_cache
**/.ruff_cache
**/__pycache__
35 changes: 18 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,23 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

- name: Init Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5
- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.10"
python-version: "3.11"
cache: "pip"
enable-cache: true


- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install -e pytest-pixl/
pip install -e pixl_core/[test]
pip install -e ${{ matrix.package_dir }}/[test]
uv sync --all-extras --all-packages
p-j-smith marked this conversation as resolved.
Show resolved Hide resolved

- name: Run tests and generate coverage report
working-directory: ${{ matrix.package_dir }}
run: COV_CORE_SOURCE=src COV_CORE_CONFIG=.coveragerc COV_CORE_DATAFILE=.coverage.eager pytest --cov=src --cov-append --cov-report=xml --cov-report=term-missing
run: |
source ../.venv/bin/activate
COV_CORE_SOURCE=src COV_CORE_CONFIG=.coveragerc COV_CORE_DATAFILE=.coverage.eager pytest --cov=src --cov-append --cov-report=xml --cov-report=term-missing
env:
ENV: test
AZURE_KEY_VAULT_NAME: test
Expand All @@ -91,19 +92,19 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3
- name: Init Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5

- name: Install uv
uses: astral-sh/setup-uv@v4
with:
version: "0.5.10"
python-version: "3.11"
cache: "pip"
enable-cache: true

- name: Install Python dependencies
# The -e option is required here due to the way the
# Editable install required here due to the way the
# code determines the export directory. See issue #318.
run: |
pip install -e pytest-pixl/
pip install -e pixl_core/[test]
pip install -e cli/[test]
uv sync --all-extras --all-packages

- name: Create .secrets.env
run: touch test/.secrets.env
Expand All @@ -129,7 +130,7 @@ jobs:
HASHER_API_AZ_TENANT_ID: ${{ secrets.EXPORT_AZ_TENANT_ID }}
HASHER_API_AZ_KEY_VAULT_NAME: ${{ secrets.EXPORT_AZ_KEY_VAULT_NAME }}
run: |
./run-system-test.sh coverage
uv run ./run-system-test.sh coverage
echo FINISHED SYSTEM TEST SCRIPT

- name: Dump queue docker logs for debugging
Expand Down Expand Up @@ -183,4 +184,4 @@ jobs:
with:
directory: test
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
9 changes: 7 additions & 2 deletions cli/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,13 @@ dev = [
pixl = "pixl_cli.main:cli"

[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
requires = ["hatchling>=1.0.0"]
build-backend = "hatchling.build"

[tool.hatch.build.targets.wheel]
dev-mode-dirs = [
"src"
]

[tool.coverage.report]
exclude_also = [
Expand Down
22 changes: 15 additions & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ services:
hasher-api:
build:
context: .
dockerfile: ./docker/hasher-api/Dockerfile
dockerfile: ./docker/pixl-python/Dockerfile
target: hasher_api
args:
PIXL_PACKAGE_DIR: hasher
<<: *build-args-common
environment:
<<: [*proxy-common, *pixl-common-env]
Expand All @@ -93,7 +95,6 @@ services:
networks:
- pixl-net
healthcheck:
test: ["CMD", "curl", "-f", "http://hasher-api:8000/heart-beat"]
interval: 10s
timeout: 30s
retries: 5
Expand All @@ -102,9 +103,11 @@ services:
orthanc-anon:
build:
context: .
dockerfile: ./docker/orthanc-anon/Dockerfile
dockerfile: ./docker/orthanc/Dockerfile
target: pixl_orthanc_anon
args:
<<: *build-args-common
ORTHANC_DIR: orthanc-anon
ORTHANC_CONCURRENT_JOBS: ${ORTHANC_CONCURRENT_JOBS}
platform: linux/amd64
command: /run/secrets
Expand Down Expand Up @@ -171,9 +174,11 @@ services:
orthanc-raw:
build:
context: .
dockerfile: ./docker/orthanc-raw/Dockerfile
dockerfile: ./docker/orthanc/Dockerfile
target: pixl_orthanc_raw
args:
<<: *build-args-common
ORTHANC_DIR: orthanc-raw
ORTHANC_RAW_MAXIMUM_STORAGE_SIZE: ${ORTHANC_RAW_MAXIMUM_STORAGE_SIZE}
ORTHANC_RAW_JOB_HISTORY_SIZE: ${ORTHANC_RAW_JOB_HISTORY_SIZE}
ORTHANC_CONCURRENT_JOBS: ${ORTHANC_CONCURRENT_JOBS}
Expand Down Expand Up @@ -249,8 +254,10 @@ services:
export-api:
build:
context: .
dockerfile: ./docker/export-api/Dockerfile
dockerfile: ./docker/pixl-python/Dockerfile
target: export_api
args:
PIXL_PACKAGE_DIR: pixl_export
<<: *build-args-common
environment:
<<:
Expand Down Expand Up @@ -297,8 +304,10 @@ services:
imaging-api:
build:
context: .
dockerfile: ./docker/imaging-api/Dockerfile
dockerfile: ./docker/pixl-python/Dockerfile
target: imaging_api
args:
PIXL_PACKAGE_DIR: pixl_imaging
<<: *build-args-common
depends_on:
queue:
Expand All @@ -308,7 +317,6 @@ services:
orthanc-anon:
condition: service_healthy
healthcheck:
test: curl -f http://0.0.0.0:8000/heart-beat
interval: 10s
timeout: 30s
retries: 5
Expand Down
2 changes: 0 additions & 2 deletions docker/.dockerignore

This file was deleted.

50 changes: 0 additions & 50 deletions docker/export-api/Dockerfile

This file was deleted.

46 changes: 0 additions & 46 deletions docker/hasher-api/Dockerfile

This file was deleted.

50 changes: 0 additions & 50 deletions docker/imaging-api/Dockerfile

This file was deleted.

53 changes: 0 additions & 53 deletions docker/orthanc-anon/Dockerfile

This file was deleted.

Loading