From 63bcd9acc872e5d5cddd042778c54b84681b3a6e Mon Sep 17 00:00:00 2001 From: Bastian Eichenberger Date: Tue, 1 Nov 2022 14:28:53 +0100 Subject: [PATCH 1/4] :pencil: Improved error handling for non-standard tif files --- deepblink/cli/_argparse.py | 2 +- deepblink/util.py | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/deepblink/cli/_argparse.py b/deepblink/cli/_argparse.py index 75c2251..0d8edd4 100644 --- a/deepblink/cli/_argparse.py +++ b/deepblink/cli/_argparse.py @@ -161,7 +161,7 @@ def _parse_args_create( "If given, will convert all labels to pixel coordinates. " "Can be a single value or a tuple of two values for x and y, respectively. " "If only one value is given, it will be used for both x and y. " - "[default: 1]" + "[default: None]" ), ) group2.add_argument( diff --git a/deepblink/util.py b/deepblink/util.py index 5f58b8b..84a3f34 100755 --- a/deepblink/util.py +++ b/deepblink/util.py @@ -6,6 +6,7 @@ import random from PIL import Image +from PIL import UnidentifiedImageError from PIL.TiffTags import TAGS import numpy as np import pandas as pd @@ -139,8 +140,16 @@ def predict_pixel_size(fname: Union[str, "os.PathLike[str]"]) -> Tuple[float, fl raise ValueError(f"{fname} is not a tif file.") if not os.path.isfile(fname): raise ValueError(f"{fname} does not exist.") + if not os.path.getsize(fname): + raise ValueError(f"{fname} does not contain any data.") - image = Image.open(fname) + try: + image = Image.open(fname) + except UnidentifiedImageError as err: + raise ValueError( + f"{fname} could not be read by PIL. " + f"Check the format or pass a pixel-size directly." + ) from err if len(image.size) != 2: raise ValueError(f"Image {fname} has more than 2 dimensions.") From acbc0855a851808d44c65422a4630151c6ca0d66 Mon Sep 17 00:00:00 2001 From: Bastian Eichenberger Date: Tue, 1 Nov 2022 14:40:10 +0100 Subject: [PATCH 2/4] :green_heart: Change versions for python suport --- .github/workflows/main.yaml | 50 ++++++++++++++++++------------------- tox.ini | 2 +- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index aa3880a..5a4ec54 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -10,37 +10,37 @@ jobs: unittest: strategy: matrix: - python-version: ["3.6", "3.7", "3.8"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] os: [windows-latest, ubuntu-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: ${{ matrix.python-version }} - - name: install tox - run: python -m pip install --upgrade tox virtualenv setuptools pip codecov - - name: run tox - run: tox -e py - - name: upload coverage reports to Codecov - run: codecov - env: - super_secret: ${{ secrets.CODECOV_TOKEN }} + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: install tox + run: python -m pip install --upgrade tox virtualenv setuptools pip codecov + - name: run tox + run: tox -e py + - name: upload coverage reports to Codecov + run: codecov + env: + super_secret: ${{ secrets.CODECOV_TOKEN }} # Important checks but not reliant on different versions check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-python@v2 - with: - python-version: "3.8" - - name: install tox - run: python -m pip install --upgrade tox virtualenv setuptools pip - - name: run tox deploy - run: tox -e deploy - - name: run tox safety - run: tox -e safety - - name: run tox style - run: tox -e style + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: install tox + run: python -m pip install --upgrade tox virtualenv setuptools pip + - name: run tox deploy + run: tox -e deploy + - name: run tox safety + run: tox -e safety + - name: run tox style + run: tox -e style diff --git a/tox.ini b/tox.ini index 0ad1d85..ae5f435 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] envlist = - py{36,37,38}, + py{37,38,39,310,311}, deploy, safety, style From ab4d5e9c66e6ca60a477bf7eed2141802f9a6442 Mon Sep 17 00:00:00 2001 From: Bastian Eichenberger Date: Tue, 1 Nov 2022 14:44:50 +0100 Subject: [PATCH 3/4] :gem: Bumpversion to 0.1.4 --- .bumpversion.cfg | 2 +- conda/meta.yaml | 4 ++-- deepblink/__init__.py | 2 +- deepblink/cli/_parseutil.py | 2 +- docs/conf.py | 2 +- setup.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 6ffaa47..1306b54 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 0.1.3 +current_version = 0.1.4 commit = False tag = True diff --git a/conda/meta.yaml b/conda/meta.yaml index 2ef36d2..8034322 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -1,6 +1,6 @@ package: name: "deepblink" - version: 0.1.3 + version: 0.1.4 source: path: .. @@ -17,7 +17,7 @@ requirements: - pip - setuptools run: - - python>=3.6,<3.9 + - python>=3.7,<=3.11 - matplotlib>=3.0.0 - requests>=2.0.0 - numpy>=1.17.0 diff --git a/deepblink/__init__.py b/deepblink/__init__.py index 98e1df4..1936ef7 100644 --- a/deepblink/__init__.py +++ b/deepblink/__init__.py @@ -16,7 +16,7 @@ - util: Basic utility functions not fitting into a category. """ -__version__ = "0.1.3" +__version__ = "0.1.4" from . import augment from . import cli diff --git a/deepblink/cli/_parseutil.py b/deepblink/cli/_parseutil.py index e94eb37..6d7269f 100644 --- a/deepblink/cli/_parseutil.py +++ b/deepblink/cli/_parseutil.py @@ -172,7 +172,7 @@ def _add_utils(parser: argparse.ArgumentParser): "-V", "--version", action="version", - version="%(prog)s 0.1.3", + version="%(prog)s 0.1.4", help="Show %(prog)s's version number.", ) group.add_argument( diff --git a/docs/conf.py b/docs/conf.py index faacc27..4121d93 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -37,7 +37,7 @@ year = "2020" author = "Bastian Eichenberger" copyright = f"{year}, {author}" -version = release = "0.1.3" +version = release = "0.1.4" pygments_style = "trac" templates_path = ["."] diff --git a/setup.py b/setup.py index 63a56cd..3142f8c 100755 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setup( # Description name="deepblink", - version="0.1.3", + version="0.1.4", license="MIT", description="Threshold independent detection and localization of diffraction-limited spots.", long_description_content_type="text/plain", From 42798aea5253d0a754b6cccee509594ac1dcde2e Mon Sep 17 00:00:00 2001 From: Bastian Eichenberger Date: Tue, 1 Nov 2022 14:51:12 +0100 Subject: [PATCH 4/4] :arrow_down: Remove 3.11 to accomodate tensorflow --- .github/workflows/main.yaml | 2 +- conda/meta.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 5a4ec54..46f5d65 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -10,7 +10,7 @@ jobs: unittest: strategy: matrix: - python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.7", "3.8", "3.9", "3.10"] os: [windows-latest, ubuntu-latest] runs-on: ${{ matrix.os }} diff --git a/conda/meta.yaml b/conda/meta.yaml index 8034322..f61a739 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -17,7 +17,7 @@ requirements: - pip - setuptools run: - - python>=3.7,<=3.11 + - python>=3.7,<3.11 - matplotlib>=3.0.0 - requests>=2.0.0 - numpy>=1.17.0