Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Exception fixes and bounds checking #34

Merged
merged 4 commits into from
Jul 24, 2023

Conversation

tbirdso
Copy link
Collaborator

@tbirdso tbirdso commented Jul 22, 2023

Changes:

  • Replace assert messages with itkAssertOrThrowMacro to emit itk::ExceptionObjects on failure, which are handled in ITKOMEZarrNGFF unit tests and provide line references with error output in ITK Python.

  • Clarifies file read errors. Previous messages indicated JSON failure rather than missing file
    Previous behavior:

RuntimeError: [json.exception.out_of_range.403] key 'multiscales' not found

Updated behavior:

RuntimeError: D:\repos\ITKIOOMEZarrNGFF\src\itkOMEZarrNGFFImageIO.cxx:374:
ITK ERROR: Failed to read from C:/bad/path/.zgroup
  • Resolves handling where requested index is equal to the size of available datasets and thus out of bounds.
    Previous behavior:
RuntimeError: D:\a\im\src\itkOMEZarrNGFFImageIO.cxx:395:
ITK ERROR: OMEZarrNGFFImageIO(000001A91BDBD060): OME-NGFF v0.4 requires `coordinateTransformations` for each resolution level.

Updated behavior:

ITK ERROR: OMEZarrNGFFImageIO(0000015D06528500): Requested DatasetIndex of 4 is greater than number of datasets (4) which exist in OME-NGFF store

Replaces `assert` statements with `itkAssertOrThrowMacro` for better ITK
exception handling. Addresses issue where opaque JSON parse errors were
thrown in testing that could not be handled as ITK exceptions.
Updates error message for metadata read failure where required OME-Zarr
NGFF metadata files `.zattrs` and `.zgroup` are not present in the
specified directory.

Under previous behavior the JSON read status was not examined, so it
appeared that metadata was read in successfully with missing keys.
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good.

src/itkOMEZarrNGFFImageIO.cxx Outdated Show resolved Hide resolved
Updates dataset index bounds check to reflect zero indexed dataset list.
Under previous logic an index equivalent to the number of datasets would
succeed with apparent missing JSON keys.

Updates associated error message for clarity.
Resolve GitHub Actions error:

```
CMake Warning (dev) at /home/runner/work/ITKIOOMEZarrNGFF/ITKIOOMEZarrNGFF/dashboard.cmake:18 (set):
  Syntax error in cmake code at

    /home/runner/work/ITKIOOMEZarrNGFF/ITKIOOMEZarrNGFF/dashboard.cmake:28

  when parsing string

    _deps[/\].+-src[/\]

  Invalid escape sequence \]
```
@tbirdso tbirdso merged commit 222fa8e into InsightSoftwareConsortium:master Jul 24, 2023
18 checks passed
@tbirdso tbirdso deleted the exception-fixes branch July 25, 2023 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants