Skip to content

Commit

Permalink
TST: run tests in docker image + fix setup.cfg regression (#61)
Browse files Browse the repository at this point in the history
* add test-docker step to ci

This builds the main docker image, runs the pytests in it, and runs a
sample image through wsinfer in the docker image.

* fix path to _patchlib/presets/*.csv in package_data

* remote -it because input device is not a TTY

* add test-package job + rm -it in docker run cmd

* make python version a string "3.10"

* quiet the output of wget

* make pytest verbose in docker

* fix name to docker image
  • Loading branch information
kaczmarj authored Jan 9, 2023
1 parent 2b0af69 commit 25da8fe
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,49 @@ jobs:
run: python -m mypy wsinfer/
- name: Run tests
run: python -m pytest --verbose tests/
test-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build Docker image
run: docker build -t wsinferimage .
- name: Run pytest in Docker image
run: |
docker run --rm --workdir /opt/wsinfer/ --entrypoint bash wsinferimage \
-c "python -m pip install -e /opt/wsinfer[dev] && python -m pytest -v /opt/wsinfer/tests/test_all.py"
- name: Run wsinfer on a sample image in Docker
run: |
mkdir slides
cd slides
wget -q https://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/JP2K-33003-1.svs
cd ..
docker run --rm --volume $(pwd):/work --workdir /work wsinferimage run \
--wsi-dir slides/ --results-dir results/ --model resnet34 --weights TCGA-BRCA-v1
test -f results/run_metadata.json
test -f results/patches/JP2K-33003-1.h5
test -f results/model-outputs/JP2K-33003-1.csv
test $(wc -l < results/model-outputs/JP2K-33003-1.csv) -eq 653
test-package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install the package
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install torch torchvision --extra-index-url https://download.pytorch.org/whl/cpu
python -m pip install . --find-links https://girder.github.io/large_image_wheels
- name: Run the wsinfer command in a new directory
run: |
mkdir newdir && cd newdir
mkdir slides && cd slides
wget -q https://openslide.cs.cmu.edu/download/openslide-testdata/Aperio/JP2K-33003-1.svs
cd ..
wsinfer run --wsi-dir slides/ --results-dir results/ --model resnet34 --weights TCGA-BRCA-v1
test -f results/run_metadata.json
test -f results/patches/JP2K-33003-1.h5
test -f results/model-outputs/JP2K-33003-1.csv
test $(wc -l < results/model-outputs/JP2K-33003-1.csv) -eq 653
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ console_scripts =

[options.package_data]
wsinfer =
patchlib/presets/*.csv
_patchlib/presets/*.csv
modeldefs/*.yaml

[flake8]
Expand Down

0 comments on commit 25da8fe

Please sign in to comment.