Skip to content

Commit

Permalink
Restore py3.8 compatibility
Browse files Browse the repository at this point in the history
- use importlib_resources backport
- pin scipy to ~1.10.0
  • Loading branch information
mittagessen committed Jan 16, 2024
1 parent 3577eb8 commit 7a56d55
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9, '3.10', '3.11']
python-version: [3.8, 3.9, '3.10', '3.11']

steps:
- uses: actions/checkout@v3
Expand Down
5 changes: 3 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ dependencies:
- click>=8.1
- numpy~=1.23.0
- pillow~=9.2.0
- scipy~=1.11.0
- scipy~=1.10.0
- jinja2~=3.0
- conda-forge::torchvision-cpu>=0.5.0
- conda-forge::pytorch-cpu>=1.11,<1.14
- jsonschema
- scikit-learn~=1.2.1
- scikit-image~=0.21.0
- scikit-image~=0.22.0
- shapely~=1.8.5
- pyvips
- imagemagick>=7.1.0
- pyarrow
- importlib-resources>=1.3.0
- conda-forge::pytorch-lightning~=2.0.0
- conda-forge::torchmetrics>=1.1.0
- conda-forge::threadpoolctl~=3.2
Expand Down
5 changes: 3 additions & 2 deletions environment_cuda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ dependencies:
- click>=8.1
- numpy~=1.23
- pillow>=9.2.0
- scipy~=1.11.0
- scipy~=1.10.0
- jinja2~=3.0
- conda-forge::torchvision
- conda-forge::pytorch>=1.11,<1.14
- cudatoolkit>=9.2
- jsonschema
- scikit-learn~=1.2.1
- scikit-image~=0.21.0
- scikit-image~=0.22.0
- shapely~=1.8.5
- pyvips
- imagemagick>=7.1.0
- pyarrow
- importlib-resources>=1.3.0
- conda-forge::pytorch-lightning~=2.0.0
- conda-forge::torchmetrics>=1.1.0
- conda-forge::threadpoolctl~=3.2
Expand Down
4 changes: 2 additions & 2 deletions kraken/blla.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import torch
import logging
import numpy as np
import importlib.resources
import importlib_resources
import shapely.geometry as geom
import torch.nn.functional as F
import torchvision.transforms as tf
Expand Down Expand Up @@ -310,7 +310,7 @@ def segment(im: PIL.Image.Image,
"""
if model is None:
logger.info('No segmentation model given. Loading default model.')
model = vgsl.TorchVGSLModel.load_model(importlib.resources.files(__name__).joinpath('blla.mlmodel'))
model = vgsl.TorchVGSLModel.load_model(importlib_resources.files(__name__).joinpath('blla.mlmodel'))

if isinstance(model, vgsl.TorchVGSLModel):
model = [model]
Expand Down
4 changes: 2 additions & 2 deletions kraken/ketos/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def publish(ctx, metadata, access_token, private, model):
Publishes a model on the zenodo model repository.
"""
import json
import importlib.resources
import importlib_resources

from jsonschema import validate
from jsonschema.exceptions import ValidationError
Expand All @@ -52,7 +52,7 @@ def publish(ctx, metadata, access_token, private, model):
from kraken.lib import models
from kraken.lib.progress import KrakenDownloadProgressBar

ref = importlib.resources.files('kraken').joinpath('metadata.schema.json')
ref = importlib_resources.files('kraken').joinpath('metadata.schema.json')
with open(ref, 'rb') as fp:
schema = json.load(fp)

Expand Down
4 changes: 2 additions & 2 deletions kraken/kraken.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import warnings
import logging
import dataclasses
import importlib.resources
import importlib_resources

from PIL import Image
from pathlib import Path
Expand All @@ -45,7 +45,7 @@
install(suppress=[click])

APP_NAME = 'kraken'
SEGMENTATION_DEFAULT_MODEL = importlib.resources.files(APP_NAME).joinpath('blla.mlmodel')
SEGMENTATION_DEFAULT_MODEL = importlib_resources.files(APP_NAME).joinpath('blla.mlmodel')
DEFAULT_MODEL = ['en_best.mlmodel']

# raise default max image size to 20k * 20k pixels
Expand Down
4 changes: 2 additions & 2 deletions kraken/lib/dataset/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import json
import torch
import numbers
import importlib.resources
import importlib_resources
import torch.nn.functional as F

from functools import partial
Expand Down Expand Up @@ -320,7 +320,7 @@ def compute_confusions(algn1: Sequence[str], algn2: Sequence[str]):
script substitutions.
"""
counts: Dict[Tuple[str, str], int] = Counter()
ref = importlib.resources.files(__name__).joinpath('scripts.json')
ref = importlib_resources.files(__name__).joinpath('scripts.json')
with ref.open('rb') as fp:
script_map = json.load(fp)

Expand Down
8 changes: 5 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ classifier =
Intended Audience :: Science/Research
License :: OSI Approved :: Apache Software License
Operating System :: POSIX
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Expand All @@ -37,7 +38,7 @@ max_line_length = 160
exclude = tests/*

[options]
python_requires = >=3.9,<=3.11.99
python_requires = >=3.8,<=3.11.99
install_requires =
jsonschema
lxml
Expand All @@ -46,20 +47,21 @@ install_requires =
numpy~=1.23.0
Pillow>=9.2.0
regex
scipy~=1.11.0
scipy~=1.10.0 # bump up to latest release with py3.8 EOL
protobuf>=3.0.0
coremltools~=6.0
jinja2~=3.0
python-bidi
torchvision>=0.5.0
torch~=2.0.1
scikit-learn~=1.2.1
scikit-image~=0.21.0
scikit-image~=0.22.0
shapely~=1.8.5
pyarrow
pytorch-lightning~=2.0.0
torchmetrics>=1.1.0
threadpoolctl~=3.2.0
importlib-resources>=1.3.0
rich

[options.extras_require]
Expand Down

0 comments on commit 7a56d55

Please sign in to comment.