Skip to content

Repository files navigation

NGFF RFC-8 collection validator

Proof of concept of validation tools for NGFF RFC-8 collections based on JSON Schemas - see https://ngff.openmicroscopy.org/rfc/8/index.html.

⚠️ WARNING: This project is a proof of concept. It is experimental, unstable, and not intended for production use. Its functionality will evolve with RFC-8 progress.

JSON Schemas

Schema files are available in the schemas folder.

Notes:

  1. 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.
  2. Schemas for the HCS metadata are not yet included.
  3. The main node schema needs to discriminate between various subschemas according to the type field. The most natural approach would be using the oneOf keyword, but this solution tends to produce a large number of misleading errors (referring to branches which don't match the specified type). For this reason we produced an equivalent schema using a combination of allOf and if/then keywords - which resulted in a reduction of the number of errors. The same logic has been applied to collection schema and multiscale schema to handle the nodes/path switch.

Python package

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).

JavaScript package

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.tgz

Starting 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=root instead. 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);

Development

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.json

JavaScript:

# Init
cd javascript
npm ci
npm run build

# Run tests
npm run test

Contributors and license

This 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.

Releases

Packages

Used by

Contributors

Languages