Skip to content

Commit

Permalink
Revert "Implement WsiAnnotations in C++ (#252)"
Browse files Browse the repository at this point in the history
This reverts commit a497eab.
  • Loading branch information
jonasteuwen authored Sep 26, 2024
1 parent a497eab commit 28d7b1e
Show file tree
Hide file tree
Showing 56 changed files with 768 additions and 120,792 deletions.
3 changes: 1 addition & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
---
BasedOnStyle: Google
IndentWidth: 2
Language: Cpp
ColumnLimit: 120
AccessModifierOffset: -4
Expand Down Expand Up @@ -71,6 +69,7 @@ IncludeCategories:
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
Expand Down
44 changes: 24 additions & 20 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
CODECOV_CI: true
steps:
- name: Install build dependencies
run: |
sudo apt update
sudo apt install -y meson libgl1-mesa-glx libcairo2-dev libgdk-pixbuf2.0-dev libglib2.0-dev libjpeg-dev libpng-dev libtiff5-dev libxml2-dev libopenjp2-7-dev libsqlite3-dev zlib1g-dev libzstd-dev
sudo apt install -y libfftw3-dev libexpat1-dev libgsf-1-dev liborc-0.4-dev libtiff5-dev ninja-build libboost-all-dev libopencv-dev
- name: Install Rust for pyhaloxml
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "Rust and Cargo installed in:"
echo $HOME/.cargo/bin
ls $HOME/.cargo/bin
export PATH="$HOME/.cargo/bin:$PATH"
sudo apt install -y libfftw3-dev libexpat1-dev libgsf-1-dev liborc-0.4-dev libtiff5-dev ninja-build
- name: Build and install OpenSlide
run: |
export PATH="$HOME/.cargo/bin:$PATH"
git clone https:/openslide/openslide.git
cd openslide
meson setup builddir
Expand All @@ -32,7 +26,6 @@ jobs:
cd ..
- name: Build and install libvips
run: |
export PATH="$HOME/.cargo/bin:$PATH"
git clone https:/libvips/libvips.git
cd libvips
meson setup builddir --prefix=/usr/local
Expand All @@ -41,24 +34,35 @@ jobs:
sudo ldconfig
cd ..
- uses: actions/checkout@v4
- name: Set up Python 3.11
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.10"
- name: Clean up any existing installations
run: |
sudo rm -rf /usr/local/lib/python3.10/site-packages/dlup*
sudo rm -rf /opt/hostedtoolcache/Python/3.10.14/arm64/lib/python3.10/site-packages/dlup*
sudo rm -rf /opt/hostedtoolcache/Python/3.10.14/arm64/lib/python3.10/site-packages/_dlup_editable_loader.py
sudo rm -rf /opt/hostedtoolcache/Python/3.10.14/arm64/lib/python3.10/site-packages/easy-install.pth
sudo rm -rf dlup/build
sudo rm -rf /tmp/*
- name: Install environment
run: |
export PATH="$HOME/.cargo/bin:$PATH"
python -m pip install --upgrade pip
python -m pip install ninja meson meson-python>=0.15.0 numpy==1.26.4 Cython>=0.29 spin pybind11
python -m pip install tifffile>=2024.7.2 pyvips>=2.2.3 tqdm>=2.66.4 pillow>=10.3.0 openslide-python>=1.3.1 spin
python -m pip install opencv-python-headless>=4.9.0.80 shapely>=2.0.4 pybind11>=2.8.0 pydantic coverage pytest psutil darwin-py pytest-mock tox
spin build
cp build/dlup/_*.so dlup/
cp build/src/_*.so dlup/
python -m pip install .
python -m pip install tifffile>=2024.7.2 pyvips>=2.2.3 tqdm>=2.66.4 pillow>=10.3.0 openslide-python>=1.3.1
python -m pip install opencv-python-headless>=4.9.0.80 shapely>=2.0.4 pybind11>=2.8.0 pydantic coverage pytest psutil darwin-py pytest-mock
echo "Python executable: $(which python)"
echo "Python version: $(python --version)"
echo "Current directory: $PWD"
meson setup builddir
meson compile -C builddir
meson install -C builddir
- name: Run coverage
run: |
coverage run -m pytest || true
mv dlup _dlup # This is needed because otherwise it won't find the compiled libraries
export PYTHONPATH=$(python -c "import site; print(site.getsitepackages()[0])")
coverage run -m pytest
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mypy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
run: |
sudo apt update
sudo apt install -y meson libgl1-mesa-glx libcairo2-dev libgdk-pixbuf2.0-dev libglib2.0-dev libjpeg-dev libpng-dev libtiff5-dev libxml2-dev libopenjp2-7-dev libsqlite3-dev zlib1g-dev libzstd-dev
sudo apt install -y libfftw3-dev libexpat1-dev libgsf-1-dev liborc-0.4-dev libtiff5-dev libboost-all-dev libopencv-dev
sudo apt install -y libfftw3-dev libexpat1-dev libgsf-1-dev liborc-0.4-dev libtiff5-dev
- name: Build and install OpenSlide
run: |
git clone https:/openslide/openslide.git
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
run: |
sudo apt update
sudo apt install -y meson libgl1-mesa-glx libcairo2-dev libgdk-pixbuf2.0-dev libglib2.0-dev libjpeg-dev libpng-dev libtiff5-dev libxml2-dev libopenjp2-7-dev libsqlite3-dev zlib1g-dev libzstd-dev
sudo apt install -y libfftw3-dev libexpat1-dev libgsf-1-dev liborc-0.4-dev libtiff5-dev libboost-all-dev libopencv-dev
sudo apt install -y libfftw3-dev libexpat1-dev libgsf-1-dev liborc-0.4-dev libtiff5-dev
- name: Build and install OpenSlide
run: |
git clone https:/openslide/openslide.git
Expand Down
42 changes: 20 additions & 22 deletions .github/workflows/tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,16 @@ on:
jobs:
build:
runs-on: ubuntu-latest
env:
CODECOV_CI: true
steps:
- name: Install build dependencies
run: |
sudo apt update
sudo apt install -y meson libgl1-mesa-glx libcairo2-dev libgdk-pixbuf2.0-dev libglib2.0-dev libjpeg-dev libpng-dev libtiff5-dev libxml2-dev libopenjp2-7-dev libsqlite3-dev zlib1g-dev libzstd-dev
sudo apt install -y libfftw3-dev libexpat1-dev libgsf-1-dev liborc-0.4-dev libtiff5-dev ninja-build libboost-all-dev libopencv-dev
- name: Install Rust for pyhaloxml
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "Rust and Cargo installed in:"
echo $HOME/.cargo/bin
ls $HOME/.cargo/bin
export PATH="$HOME/.cargo/bin:$PATH"
sudo apt install -y libfftw3-dev libexpat1-dev libgsf-1-dev liborc-0.4-dev libtiff5-dev ninja-build
- name: Build and install OpenSlide
run: |
export PATH="$HOME/.cargo/bin:$PATH"
git clone https:/openslide/openslide.git
cd openslide
meson setup builddir
Expand All @@ -32,7 +26,6 @@ jobs:
cd ..
- name: Build and install libvips
run: |
export PATH="$HOME/.cargo/bin:$PATH"
git clone https:/libvips/libvips.git
cd libvips
meson setup builddir --prefix=/usr/local
Expand All @@ -41,23 +34,28 @@ jobs:
sudo ldconfig
cd ..
- uses: actions/checkout@v4
- name: Set up Python 3.11
- name: Set up Python 3.10
uses: actions/setup-python@v5
with:
python-version: "3.11"
python-version: "3.10"
- name: Clean up any existing installations
run: |
sudo rm -rf /usr/local/lib/python3.10/site-packages/dlup*
sudo rm -rf /opt/hostedtoolcache/Python/3.10.14/arm64/lib/python3.10/site-packages/dlup*
sudo rm -rf /opt/hostedtoolcache/Python/3.10.14/arm64/lib/python3.10/site-packages/_dlup_editable_loader.py
sudo rm -rf /opt/hostedtoolcache/Python/3.10.14/arm64/lib/python3.10/site-packages/easy-install.pth
sudo rm -rf dlup/build
sudo rm -rf /tmp/*
- name: Install environment
run: |
export PATH="$HOME/.cargo/bin:$PATH"
python -m pip install --upgrade pip
python -m pip install ninja meson meson-python>=0.15.0 numpy==1.26.4 Cython>=0.29 spin pybind11
python -m pip install tifffile>=2024.7.2 pyvips>=2.2.3 tqdm>=2.66.4 pillow>=10.3.0 openslide-python>=1.3.1 spin
python -m pip install opencv-python-headless>=4.9.0.80 shapely>=2.0.4 pybind11>=2.8.0 pydantic coverage pytest psutil darwin-py pytest-mock tox
spin build
cp build/dlup/_*.so dlup/
cp build/src/_*.so dlup/
python -m pip install .
python -m pip install tifffile>=2024.7.2 pyvips>=2.2.3 tqdm>=2.66.4 pillow>=10.3.0 openslide-python>=1.3.1
python -m pip install opencv-python-headless>=4.9.0.80 shapely>=2.0.4 pybind11>=2.8.0 pydantic coverage pytest psutil darwin-py pytest-mock
echo "Python executable: $(which python)"
echo "Python version: $(python --version)"
echo "Current directory: $PWD"
- name: Run tox
run: |
export GITHUB_ACTIONS=1
export PATH="$HOME/.cargo/bin:$PATH"
tox || true
python -m pip install tox
tox
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
_background.c
_background.cpp
_background.html
_background.cpython-*.so
_background.cpython-*-darwin.so
_libtiff_tiff_writer.cpython-*.so
_geometry.cython-*.so

# Output files
*.tif
Expand Down
78 changes: 14 additions & 64 deletions .spin/cmds.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import os
import subprocess
import webbrowser
from pathlib import Path

import click
from spin.cmds import meson


@click.group()
Expand All @@ -14,32 +12,11 @@ def cli():


@cli.command()
@click.option("-j", "--jobs", help="Number of parallel tasks to launch", type=int)
@click.option("--clean", is_flag=True, help="Clean build directory before build")
@click.option("-v", "--verbose", is_flag=True, help="Print all build output, even installation")
@click.argument("meson_args", nargs=-1)
@click.pass_context
def build(ctx, meson_args, jobs=None, clean=False, verbose=False, quiet=False, *args, **kwargs):
def build():
"""🔧 Build the project"""
build_dir = Path("build")
build_dir.mkdir(exist_ok=True)

# Use the current working directory + /dlup instead of site-packages
local_install_dir = os.path.join(os.getcwd(), "dlup")

meson_args = list(meson_args) + [
f"--prefix={local_install_dir}",
f"-Dpython.platlibdir={local_install_dir}",
f"-Dpython.purelibdir={local_install_dir}",
]

ctx.params["meson_args"] = meson_args
ctx.params["jobs"] = jobs
ctx.params["clean"] = clean
ctx.params["verbose"] = verbose
ctx.params["quiet"] = quiet

ctx.forward(meson.build)
subprocess.run(["meson", "setup", "builddir", "--prefix", str(Path.cwd())], check=True)
subprocess.run(["meson", "compile", "-C", "builddir"], check=True)
subprocess.run(["meson", "install", "-C", "builddir"], check=True)


@cli.command()
Expand All @@ -48,28 +25,11 @@ def build(ctx, meson_args, jobs=None, clean=False, verbose=False, quiet=False, *
def test(verbose, tests):
"""🔍 Run tests"""
cmd = ["pytest"]
if verbose:
cmd.append("-v")
if coverage:
cmd.extend(["--cov=dlup --cov=tests --cov-report=html --cov-report=term"])
if tests:
cmd.extend(tests)
subprocess.run(cmd, check=True)


@cli.command()
@click.option("-v", "--verbose", is_flag=True, help="Verbose output")
@click.argument("tests", nargs=-1)
def coverage(verbose, tests):
"""🧪 Run tests and generate coverage report"""
cmd = ["pytest", "--cov=dlup", "--cov=tests", "--cov-report=html", "--cov-report=term"]
if verbose:
cmd.append("-v")
if tests:
cmd.extend(tests)
subprocess.run(cmd, check=True)
coverage_path = Path.cwd() / "htmlcov" / "index.html"
webbrowser.open(f"file://{coverage_path.resolve()}")


@cli.command()
Expand Down Expand Up @@ -173,6 +133,16 @@ def clean():
path.unlink()


@cli.command()
def coverage():
"""🧪 Run tests and generate coverage report"""
subprocess.run(["coverage", "run", "--source", "dlup", "-m", "pytest"], check=True)
subprocess.run(["coverage", "report", "-m"], check=True)
subprocess.run(["coverage", "html"], check=True)
coverage_path = Path.cwd() / "htmlcov" / "index.html"
webbrowser.open(f"file://{coverage_path.resolve()}")


@cli.command()
def release():
"""📦 Package and upload a release"""
Expand All @@ -193,25 +163,5 @@ def dist():
subprocess.run(["ls", "-l", "dist"], check=True)


@cli.command()
def precommit():
"""🛠️ Run pre-commit hooks"""
subprocess.run(["pre-commit", "run", "--all-files"], check=True)


@cli.command()
def format():
"""🛠️ Run clang-format and black"""
# Run clang-format
subprocess.run(
"find src -name '*.cpp' -o -name '*.h' -o -name '*.hpp' | xargs clang-format -i",
shell=True,
check=True,
)

# Run black
subprocess.run(["black", "."], check=True)


if __name__ == "__main__":
cli()
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,3 @@ or the following plain bibliography:
```
Teuwen, J., Romor, L., Pai, A., Schirris, Y., Marcus E. (2024). DLUP: Deep Learning Utilities for Pathology (Version 0.7.0) [Computer software]. https:/NKI-AI/dlup
```

## Contributors
In alphabetic order:

## Contributors
In alphabetic order:

## Contributors
In alphabetic order:

| [<img src="https:/AjeyPaiK.png" width="50px;" style="border-radius:50%;"/><br /><sub><b>Ajey Pai Karkala</b></sub>](https:/AjeyPaiK) | [<img src="https:/EricMarcus-ai.png" width="50px;" style="border-radius:50%;"/><br /><sub><b>Eric Marcus</b></sub>](https:/EricMarcus-ai) | [<img src="https:/jonasteuwen.png" width="50px;" style="border-radius:50%;"/><br /><sub><b>Jonas Teuwen</b></sub>](https:/jonasteuwen) | [<img src="https:/lromor.png" width="50px;" style="border-radius:50%;"/><br /><sub><b>Leonardo Romor</b></sub>](https:/lromor) | [<img src="https:/rharkes.png" width="50px;" style="border-radius:50%;"/><br /><sub><b>Rolf Harkes</b></sub>](https:/rharkes) | [<img src="https:/YoniSchirris.png" width="50px;" style="border-radius:50%;"/><br /><sub><b>Yoni Schirris</b></sub>](https:/YoniSchirris) |
| :---: | :---: | :---: | :---: | :---: | :---: |
Loading

0 comments on commit 28d7b1e

Please sign in to comment.