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

Verify spec #35

Merged
merged 29 commits into from
Nov 27, 2020
Merged

Verify spec #35

merged 29 commits into from
Nov 27, 2020

Conversation

FynnBe
Copy link
Member

@FynnBe FynnBe commented Oct 29, 2020

also contains:

  • changes to adhere to format version 0.3.0, which is not yet finalized.
  • draft of a runner for scikit-learn models (we are not planning to officially support sklearn models at this point)

@oeway
Copy link
Contributor

oeway commented Oct 30, 2020

Nice, we should also add this verification to the compilation script and generate a report for each model (e.g. highlight as an error icon on the model card if error detected).

@oeway
Copy link
Contributor

oeway commented Oct 30, 2020

@FynnBe Can you generate an error report after verification, not only throw error but output details about the error?

@FynnBe
Copy link
Member Author

FynnBe commented Oct 30, 2020

@FynnBe Can you generate an error report after verification, not only throw error but output details about the error?

example from travis:

$ git clone --depth=50 https://github.com/ilastik/bioimage-io-models.git ilastik/bioimage-io-models
0.01s0.01s$ source ~/virtualenv/python3.7/bin/activate
$ python --version
Python 3.7.1
$ pip --version
pip 20.1.1 from /home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/pip (python 3.7)
install
12.57s$ pip install git+https://github.com/bioimage-io/python-bioimage-io.git@verify_spec
2.01s$ python -m pybio.spec verify-bioimageio-manifest manifest.bioimage.io.yaml
invalid model: https://raw.githubusercontent.com/bioimage-io/pytorch-bioimage-io/v0.1.1/specs/models/unet2d/nuclei_broad/UNet2DNucleiBroad.model.yaml
{'inputs': {0: {'description': ['Missing data for required field.']}},
 'optional_kwargs': ['Unknown field.'],
 'outputs': {0: {'description': ['Missing data for required field.']}},
 'prediction': ['Unknown field.'],
 'test_input': ['Unknown field.'],
 'test_output': ['Unknown field.'],
 'training': ['Unknown field.'],
 'weights': ['Missing data for required field.'],
 'weights_format': ['Missing data for required field.']}
invalid model: https://raw.githubusercontent.com/wolny/pytorch-3dunet/37f186c80f4d64b1dab5d165d8c2aae15b5aede1/bioimage-io/UNet3DArabidopsisOvules.model/UNet3DArabidopsisOvules.model.yaml
{'inputs': {0: {'description': ['Missing data for required field.']}},
 'optional_kwargs': ['Unknown field.'],
 'outputs': {0: {'description': ['Missing data for required field.']}},
 'prediction': ['Unknown field.'],
 'test_input': ['Unknown field.'],
 'test_output': ['Unknown field.'],
 'weights': ['Missing data for required field.'],
 'weights_format': ['Missing data for required field.']}
invalid model: https://raw.githubusercontent.com/platybrowser/platybrowser/3711f1c26e5db8c38c3faff4cccb3110560e3c67/segmentation/cells/UNet3DPlatyCellProbs.model/UNet3DPlatyCellProbs.model.yaml
{'inputs': {0: {'description': ['Missing data for required field.']}},
 'optional_kwargs': ['Unknown field.'],
 'outputs': {0: {'description': ['Missing data for required field.']}},
 'prediction': ['Unknown field.'],
 'test_input': ['Unknown field.'],
 'test_output': ['Unknown field.'],
 'weights': ['Missing data for required field.'],
 'weights_format': ['Missing data for required field.']}
invalid model: https://raw.githubusercontent.com/subeeshvasu/hbp-DL-seg-codes/0.1.2/UNetDA.model.yaml
{'inputs': {0: {'description': ['Missing data for required field.']}},
 'optional_kwargs': ['Unknown field.'],
 'outputs': {0: {'description': ['Missing data for required field.']}},
 'prediction': ['Unknown field.'],
 'test_input': ['Unknown field.'],
 'test_output': ['Unknown field.'],
 'weights': ['Missing data for required field.'],
 'weights_format': ['Missing data for required field.']}
invalid model: https://raw.githubusercontent.com/subeeshvasu/hbp-DL-seg-codes/0.1.2/2sUNetDA.model.yaml
{'inputs': {0: {'description': ['Missing data for required field.']}},
 'optional_kwargs': ['Unknown field.'],
 'outputs': {0: {'description': ['Missing data for required field.']}},
 'prediction': ['Unknown field.'],
 'test_input': ['Unknown field.'],
 'test_output': ['Unknown field.'],
 'weights': ['Missing data for required field.'],
 'weights_format': ['Missing data for required field.']}
The command "python -m pybio.spec verify-bioimageio-manifest manifest.bioimage.io.yaml" exited with 1.
Done. Your build exited with 1.

coded together with Maksim Novikov
@oeway
Copy link
Contributor

oeway commented Oct 30, 2020

This looks great!

@constantinpape
Copy link
Contributor

The checker works for my most current v3 spec:
https://github.com/hci-unihd/batchlib/blob/master/misc/models/torch/bioimageio/UNetCovidIf.model.yaml

What's left to do before merging?

@constantinpape constantinpape mentioned this pull request Nov 27, 2020
@FynnBe
Copy link
Member Author

FynnBe commented Nov 27, 2020

What's left to do before merging?

get the tests to pass...

@@ -0,0 +1,34 @@
import collections
from typing import Dict, Optional, OrderedDict, Sequence, Tuple
Copy link
Contributor

Choose a reason for hiding this comment

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

Use Dict instead of OrderedDict

Copy link
Member Author

Choose a reason for hiding this comment

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

I went with MutableMapping instead, but seem to have forgotten it here... I'll fix it

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if MutableMapping implies ordering, while python Dict does.

@FynnBe FynnBe changed the title [WIP] Verify spec Verify spec Nov 27, 2020
@FynnBe
Copy link
Member Author

FynnBe commented Nov 27, 2020

I am a bit puzzled why this fails:

self = PosixPath('/home/travis/build/bioimage-io/python-bioimage-io/tests/conftest.py/../../specs/models/sklearn/RandomForestClassifier_v0_1.model.yaml')
name = '/home/travis/build/bioimage-io/python-bioimage-io/tests/conftest.py/../../specs/models/sklearn/RandomForestClassifier_v0_1.model.yaml'
flags = 524288, mode = 438
    def _opener(self, name, flags, mode=0o666):
        # A stub for the opener argument to built-in open()
>       return self._accessor.open(self, flags, mode)
E       NotADirectoryError: [Errno 20] Not a directory: '/home/travis/build/bioimage-io/python-bioimage-io/tests/conftest.py/../../specs/models/sklearn/RandomForestClassifier_v0_1.model.yaml'

@FynnBe
Copy link
Member Author

FynnBe commented Nov 27, 2020

I am a bit puzzled why this fails:

for PosixPaths this does not seem legal: posix_path/a_file.ext/../elsewhere

@FynnBe FynnBe merged commit 6597e7c into master Nov 27, 2020
@FynnBe FynnBe deleted the verify_spec branch November 27, 2020 14:03
@FynnBe FynnBe restored the verify_spec branch December 18, 2020 10:01
@FynnBe FynnBe deleted the verify_spec branch December 18, 2020 10:01
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.

4 participants