Proof of concept of validation tools for NGFF RFC-8 collections based on JSON Schemas - see https://ngff.openmicroscopy.org/rfc/8/index.html.
Schema files are available in the schemas folder.
Notes:
- This is not a canonical definition of what may be part of the schemas, but a proof of concept of how such schemas may look like.
- Schemas for the HCS metadata are not yet included.
- The main node schema needs to discriminate between various subschemas according to the
typefield. The most natural approach would be using theoneOfkeyword, but this solution tends to produce a large number of misleading errors (referring to branches which don't match the specifiedtype). For this reason we produced an equivalent schema using a combination ofallOfandif/thenkeywords - which resulted in a reduction of the number of errors. The same logic has been applied to collection schema and multiscale schema to handle thenodes/pathswitch.
The ngff-rfc8 Python package contains the static JSON Schema files, and it exposes a simple validation function and a command-line interface.
A library-usage example looks like
from ngff_rfc8.validate import validate_collection
data = {
"ome": {
"version": "0.x",
"type": "collection",
"name": "My Collection",
"id": "some-collection-id",
"attributes": {},
"nodes": [],
}
}
validate_collection(data)while a command-line-interface example looks like
ngff-rfc-8-validate /some/collection.json(from a Python environment where the package is installed).
To include the JavaScript package in other projects, install the library from the release artifacts:
npm install https://github.com/fractal-analytics-platform/ngff-rfc8-validator/releases/download/v0.0.1/ngff-rfc8-validator-v0.0.1.tgzStarting from npm 12, you will also need to specify the flag
--allow-remote=all, to allow npm installing from an URL. If you are installing from a package.json file you can use--allow-remote=rootinstead. See https://docs.npmjs.com/cli/v12/using-npm/config#allow-remote
Then, import the validate function:
import { validate } from '@fractal-analytics-platform/ngff-rfc8-validator';
validate(data);Python:
# Init
uv venv
uv sync --all-groups
# Run tests
uv run pytest python/tests
# Serve documentation on http://localhost:8000
uv run zensical serve
# Generate single-file JSON Schema
uv run python3 python/scripts/build_single_schema.py > ngff-rfc8.jsonJavaScript:
# Init
cd javascript
npm ci
npm run build
# Run tests
npm run testThis project is developed by the BioVisionCenter at the University of Zurich, who contracts eXact lab s.r.l. for software engineering and development support.
Unless otherwise specified, all components are released under the BSD 3-Clause License, and copyright is with the BioVisionCenter at the University of Zurich.
Issues and PRs for the project are welcome. Be aware that this project is in a proof of concept phase and we don't commit to its API stability. Given that RFC-8 may still evolve, we expect to adapt new RFC-8 changes as they come and break existing functionality when needed.