diff --git a/.github/workflows/multimodal-pr.yml b/.github/workflows/multimodal-pr.yml index 5bab655c2..d2601eb6c 100644 --- a/.github/workflows/multimodal-pr.yml +++ b/.github/workflows/multimodal-pr.yml @@ -13,7 +13,7 @@ on: - cron: "0 4 * * *" # every day at 4 AM UTC env: - pythonVersion: 3.7 + pythonVersion: "3.10" folder: hi-ml-multimodal HIML_TENANT_ID: ${{ secrets.HIML_TENANT_ID }} HIML_RESOURCE_GROUP: ${{ secrets.HIML_RESOURCE_GROUP }} diff --git a/hi-ml-multimodal/.mypy.ini b/hi-ml-multimodal/.mypy.ini index b3cf78687..aa664619d 100644 --- a/hi-ml-multimodal/.mypy.ini +++ b/hi-ml-multimodal/.mypy.ini @@ -1,5 +1,5 @@ [mypy] -python_version=3.7 +python_version=3.10 scripts_are_modules=True namespace_packages=True show_traceback=True diff --git a/hi-ml-multimodal/MANIFEST.in b/hi-ml-multimodal/MANIFEST.in index 035be0b8e..c1a7121c1 100644 --- a/hi-ml-multimodal/MANIFEST.in +++ b/hi-ml-multimodal/MANIFEST.in @@ -1,3 +1,2 @@ include LICENSE -include requirements_run.txt include README.md diff --git a/hi-ml-multimodal/Makefile b/hi-ml-multimodal/Makefile index 1635442f8..90bdadf28 100644 --- a/hi-ml-multimodal/Makefile +++ b/hi-ml-multimodal/Makefile @@ -1,22 +1,16 @@ ## Package management -# Create a Conda environment for this folder only -env: - conda env create --file environment.yml - pip install -r requirements_test.txt - pip install -r requirements_build.txt - # pip upgrade pip_upgrade: python -m pip install --upgrade pip # pip upgrade and install build requirements pip_build: pip_upgrade - pip install -r requirements_build.txt + pip install .[build] # pip upgrade and install test requirements pip_test: pip_upgrade - pip install -r requirements_test.txt + pip install .[test] pip_publish: pip_upgrade pip install --upgrade build twine @@ -26,7 +20,8 @@ pip_local: pip install -e . # pip install everything for local development and testing -pip: pip_build pip_test pip_local +pip: + pip install -e .[dev] ## Actions @@ -48,7 +43,6 @@ flake8: # run mypy, assuming test requirements already installed mypy: - mypy --install-types --show-error-codes --non-interactive setup.py mypy --install-types --show-error-codes --non-interactive src mypy --install-types --show-error-codes --non-interactive test_multimodal diff --git a/hi-ml-multimodal/README.md b/hi-ml-multimodal/README.md index 94344fe28..25e2bbb34 100644 --- a/hi-ml-multimodal/README.md +++ b/hi-ml-multimodal/README.md @@ -6,7 +6,7 @@ The code is available on [GitHub][1] and [Hugging Face 🤗][6]. ## Getting started The best way to get started is by running the [phrase grounding notebook][2]. -All the dependencies will be installed upon execution, so Python 3.7 and [Jupyter][3] are the only requirements to get started. +All the dependencies will be installed upon execution, so [Jupyter][3] is the only requirements to get started. The notebook can also be run on [Binder][4], without the need to download any code or install any libraries: diff --git a/hi-ml-multimodal/environment.yml b/hi-ml-multimodal/environment.yml deleted file mode 100644 index 1750632d0..000000000 --- a/hi-ml-multimodal/environment.yml +++ /dev/null @@ -1,14 +0,0 @@ -name: multimodal -channels: - - defaults - - conda-forge - - pytorch -dependencies: - - pip=20.1.1 - - python=3.7.3 - - cudatoolkit=11.1 - - pytorch=1.9.0 - - torchvision=0.10.0 - - pip: - - -r requirements_run.txt - - -r requirements_test.txt diff --git a/hi-ml-multimodal/pyproject.toml b/hi-ml-multimodal/pyproject.toml new file mode 100644 index 000000000..31f14ba9b --- /dev/null +++ b/hi-ml-multimodal/pyproject.toml @@ -0,0 +1,5 @@ +[build-system] +requires = [ + "setuptools>=42", +] +build-backend = "setuptools.build_meta" diff --git a/hi-ml-multimodal/requirements_build.txt b/hi-ml-multimodal/requirements_build.txt deleted file mode 100644 index bdf1f1aa6..000000000 --- a/hi-ml-multimodal/requirements_build.txt +++ /dev/null @@ -1,9 +0,0 @@ -docutils==0.16 -myst-parser==0.15.2 -setuptools==65.5.1 -sphinx==4.1.2 -sphinx-autodoc-typehints==1.12.0 -sphinx-automodapi==0.13 -sphinx-rtd-theme==1.0.0 -twine==3.3.0 -wheel==0.38.1 diff --git a/hi-ml-multimodal/requirements_run.txt b/hi-ml-multimodal/requirements_run.txt deleted file mode 100644 index 87030a342..000000000 --- a/hi-ml-multimodal/requirements_run.txt +++ /dev/null @@ -1,8 +0,0 @@ -huggingface-hub==0.6.0 -pillow==9.3.0 -pydicom==2.2.2 -scikit-image==0.18.1 -SimpleITK==2.1.1 -torch==1.9.0 -torchvision>0.9,<=0.10.0 -transformers==4.17.0 diff --git a/hi-ml-multimodal/requirements_test.txt b/hi-ml-multimodal/requirements_test.txt deleted file mode 100644 index 7b29988d0..000000000 --- a/hi-ml-multimodal/requirements_test.txt +++ /dev/null @@ -1,13 +0,0 @@ -bump2version==1.0.1 -coverage==6.3.2 -flake8==5.0.2 -ipykernel==6.15.0 -ipython==7.34.0 -mypy==0.931 -papermill==2.3.4 -pycobertura==2.0.1 -pytest==6.2.2 -pytest-cov==2.11.1 -pytest-rerunfailures==10.2 -pytest-timeout==2.0.1 -setuptools==65.5.1 diff --git a/hi-ml-multimodal/setup.cfg b/hi-ml-multimodal/setup.cfg new file mode 100644 index 000000000..9b69b2374 --- /dev/null +++ b/hi-ml-multimodal/setup.cfg @@ -0,0 +1,74 @@ +[metadata] +name = hi-ml-multimodal +version = 0.1.2 +author = Biomedical Imaging Team @ Microsoft Health Futures +author_email = innereyedev@microsoft.com +url = https://github.com/microsoft/hi-ml +description = Microsoft Health Futures package to work with multi-modal health data +long_description = file: README.md +long_description_content_type = text/markdown +license_file = MIT License +platforms = OS Independent +classifiers = + Intended Audience :: Science/Research + Natural Language :: English + Operating System :: OS Independent + Programming Language :: Python + Programming Language :: Python :: 3 + Programming Language :: Python :: 3 :: Only + Programming Language :: Python :: 3.10 + Topic :: Scientific/Engineering + Topic :: Scientific/Engineering :: Artificial Intelligence + Topic :: Scientific/Engineering :: Image Processing + Topic :: Scientific/Engineering :: Medical Science Apps. + Typing :: Typed + Development Status :: 3 - Alpha + License :: OSI Approved :: MIT License + +[options] +install_requires = + huggingface-hub + matplotlib + pillow + pydicom + scikit-image + SimpleITK + torch + torchvision + transformers +python_requires = >=3.10,<3.11 +include_package_data = True +zip_safe = False + +[options.packages.find] +where = src + +[options.extras_require] +dev = + %(build)s + %(test)s + bump2version + pre-commit +build = + docutils + myst-parser + sphinx + sphinx-autodoc-typehints + sphinx-automodapi + sphinx-rtd-theme + twine +test = + coverage + flake8 + ipykernel + ipython + mypy + papermill + pycobertura + pytest + pytest-cov + pytest-rerunfailures + pytest-timeout + +[bdist_wheel] +universal = 1 diff --git a/hi-ml-multimodal/test_multimodal/vlp/test_zero_shot_classification.py b/hi-ml-multimodal/test_multimodal/vlp/test_zero_shot_classification.py index a5dd54d1e..25dc33ee1 100644 --- a/hi-ml-multimodal/test_multimodal/vlp/test_zero_shot_classification.py +++ b/hi-ml-multimodal/test_multimodal/vlp/test_zero_shot_classification.py @@ -1,7 +1,7 @@ import tempfile from enum import Enum, unique from pathlib import Path -from typing import List, Tuple, Union +from typing import List, Optional, Tuple, Union import requests from torchvision.datasets.utils import check_integrity @@ -46,7 +46,7 @@ def _get_default_text_prompts_for_pneumonia() -> Tuple[List, List]: return pos_query, neg_query -def save_img_from_url(image_url: str, local_path: Union[str, Path], md5: str = None) -> None: +def save_img_from_url(image_url: str, local_path: Union[str, Path], md5: Optional[str] = None) -> None: """ Pull an image from a URL and save it to a local path """ diff --git a/readthedocs_requirements.txt b/readthedocs_requirements.txt index cdf27b6c8..0890ded92 100644 --- a/readthedocs_requirements.txt +++ b/readthedocs_requirements.txt @@ -1,4 +1,4 @@ -r build_requirements.txt -r hi-ml/run_requirements.txt -r hi-ml-azure/run_requirements.txt --r hi-ml-multimodal/requirements_run.txt +./hi-ml-multimodal