From 74352717dd230b2e0536ff80745ac51eb1fd1886 Mon Sep 17 00:00:00 2001 From: Jakub Kaczmarzyk Date: Fri, 14 Jul 2023 10:58:56 -0400 Subject: [PATCH] Use functools.lru_cache instead of functools.cache (for python 3.8) and add github actions CI (#7) * use functools.lru_cache to please python 3.8 fixes #6 * ignore mypy huggingface-hub * add basic tests for ci * limit click versions to please mypy related to https://github.com/pallets/click/issues/2558 --- .github/workflows/ci.yml | 34 ++++++++++++++++++++++++++++++++++ setup.cfg | 6 +++++- wsinfer_zoo/client.py | 2 +- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e37a7c8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,34 @@ +name: ci + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + - name: Install wsinfer-zoo + run: python -m pip install -e .[dev] + - name: Check style (flake8) + run: python -m flake8 wsinfer_zoo/ + - name: Check style (black) + run: python -m black --check wsinfer_zoo/ + - name: Check types + run: python -m mypy --install-types --non-interactive wsinfer_zoo/ + - name: Run the command line + run: | + wsinfer-zoo --help + wsinfer-zoo ls + - name: Attempt to download a model + run: wsinfer-zoo get prostate-tumor-resnet34.tcga-prad diff --git a/setup.cfg b/setup.cfg index ad2983a..af3a044 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,7 +31,7 @@ classifiers = packages = find: python_requires = >= 3.7 install_requires = - click>=8.0,<9 + click>=8.0,<9,!=8.1.4,!=8.1.5 huggingface_hub jsonschema tabulate @@ -58,6 +58,10 @@ max-line-length = 88 extend-ignore = E203 exclude = wsinfer_zoo/_version.py +[mypy] +[mypy-huggingface_hub] +ignore_missing_imports = True + [versioneer] VCS = git style = pep440 diff --git a/wsinfer_zoo/client.py b/wsinfer_zoo/client.py index b00d618..dab4df9 100644 --- a/wsinfer_zoo/client.py +++ b/wsinfer_zoo/client.py @@ -285,7 +285,7 @@ def from_dict(cls, config: Dict) -> "ModelRegistry": return cls(models=models) -@functools.cache +@functools.lru_cache() def load_registry(registry_file: Optional[Union[str, Path]] = None) -> ModelRegistry: """Load model registry.