hi-ml/hi-ml-cpath
Anton Schwaighofer 2cc2511efd
ENH: Better commandline parsing of Enums (#861)
Enum values are now parsed without matching case. 
Also moved all parsing-related code out of `utils.py` into `argparsing.py`.
2023-04-03 10:23:41 +01:00
..
.vscode 💄 Add black styling and configuration 2023-03-23 14:32:03 +00:00
other/slide_image_loading ♻️ Style and fix mypy 2023-03-23 15:06:19 +00:00
src ENH: Better commandline parsing of Enums (#861) 2023-04-03 10:23:41 +01:00
testSSL ♻️ Style and fix mypy 2023-03-23 15:06:19 +00:00
testhisto ENH: Add diagnosis for Tiff Conversion (#862) 2023-03-31 15:10:16 +01:00
.flake8 💄 Add black styling and configuration 2023-03-23 14:32:03 +00:00
.mypy.ini ENH: Merge Main into Transfer Main (#653) 2022-11-10 18:36:40 +00:00
.pylintrc ENH: Rename histopathology folder to match overall naming scheme (#512) 2022-07-18 13:40:47 +01:00
Makefile 💄 Add black styling and configuration 2023-03-23 14:32:03 +00:00
README.md ENH: Update tiling script (#516) 2022-07-20 14:07:04 +02:00
amlt_singularity_cpath.yml ENH: Set additional tags to Amulet Jobs (#620) 2022-10-04 09:25:00 +01:00
environment.yml ENH: Use Latest Monai GridPatch to filter both threshold and count (#834) 2023-03-11 12:17:45 +00:00
primary_deps.yml MNT: Upgrade pytorch to 1.11 (#833) 2023-03-10 11:01:59 +00:00
pyrightconfig.json ENH: Rename histopathology folder to match overall naming scheme (#512) 2022-07-18 13:40:47 +01:00
pytest.ini MNT: Upgrade pytest (#813) 2023-02-23 14:31:15 +00:00
requirements_build.txt Bump wheel from 0.36.2 to 0.38.1 in /hi-ml-cpath (#713) 2023-01-03 14:57:09 +00:00
requirements_run.txt ENH: Use Latest Monai GridPatch to filter both threshold and count (#834) 2023-03-11 12:17:45 +00:00
requirements_test.txt MNT: Upgrade pytest (#813) 2023-02-23 14:31:15 +00:00
setup.py ♻️ Style and fix mypy 2023-03-23 15:06:19 +00:00

README.md

Histopathology Models and Workflows

Models on public data

This repository contains a set of models built on and for public datasets (PANDA, TCGA). Detailed instructions to on-board the datasets and run the models are provided on readthedocs.

Getting started

Setting up Python

For working on the histopathology folder, please create a separate Conda environment.

cd hi-ml-cpath
make env

You can then activate the environment via conda activate HimlHisto. Set VSCode to use this Conda environment, by choosing "Python: Select Interpreter" from the command palette.

If the dependencies need to be updated, please modify hi-ml-cpath/primary_deps.yml, and then run the script hi-ml-cpath/create_and_lock_environment.sh. This will create a full "locked" environment specification with pinned versions of all depdencies.

Setting up AzureML

In addition, please download an AzureML workspace configuration file for the workspace that you wish to use:

  • In the browser, navigate to the workspace in question
  • Click on the drop-down menu on upper right of the page, to the left of your account picture.
  • Select "Download config file".
  • Save that file into the the repository root.

Once that config file is in place, all Python runs that you start inside the hi-ml-cpath folder will automatically use this config file.

Running histopathology models

To test your setup, please execute in the hi-ml-cpath folder:

conda activate HimlHisto
python ../hi-ml/src/health_ml/runner.py --model health_cpath.TcgaCrckImageNetMIL  --cluster=training-nd24

This should start an AzureML job in the AzureML workspace that you configured above via config.json. You may need to adjust the name of the compute cluster (training-nd24 in the above example).

Conda environment

If you start your jobs in the hi-ml-cpath folder, they will automatically pick up the Conda environment file that is present in that folder. If you start your jobs in a different folder, you need to add the --conda_env option to point to the file <repo_root>/hi-ml-cpath/environment.yml.

Running histopathology tests

In the hi-ml-cpath folder, run

make call_pytest

Inside of VSCode, all tests in the repository should be picked up automatically. You can exclude the tests for the hi-ml and hi-ml-azure packages by modifying python.testing.pytestArgs in the VSCode .vscode/settings.json file.

Tests that require a GPU

The test pipeline for the histopathology folder contains a run of pytest on a machine with 2 GPUs. Only tests that are marked with the pytest mark gpu are executed on that GPU machine. Note that all tests that bear the gpu mark will also be executed when running on a CPU machine. You need to manually add a skipif flag for tests that are meant to exclusively run on GPU machines. This also helps to ensure that the test suite can pass when executed outside of the build agents.

  • Tests that run only on a CPU machine: Provide no pytest marks
def test_my_code() -> None:
    pass
  • Tests that run on both on a CPU and on a GPU machine: Add @pytest.mark.gpu
@pytest.mark.gpu
def test_my_code() -> None:
    pass
  • Tests that run only on a GPU machine:
from health_ml.utils.common_utils import is_gpu_available
no_gpu = not is_gpu_available()

@pytest.mark.skipif(no_gpu, reason="Test requires GPU")
@pytest.mark.gpu
def test_my_code() -> None:
    pass