-
Notifications
You must be signed in to change notification settings - Fork 4
feat: generate viewer links dynamically for Zarr datasets #307
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
base: main
Are you sure you want to change the base?
Changes from all commits
5f1a624
d0bf67c
6620486
24e030e
9f5d1eb
28173ea
3fd00d7
9160eb4
ecf1b62
7698348
69ae1b6
3e15ae7
4292cdf
d545e28
d5c24e9
e6e1cd4
be8bbd5
58d163d
5ae87ae
4b6db2e
fef30cd
82b9cfb
d2a4e84
b0e97a3
8b2af82
1ebfb3e
5cacb67
7ec34ec
30f0853
bc867c8
83dd34f
da8dd86
10bafa7
cd05c36
d892ca1
d5261a5
05957ba
0fce05c
4ab4fe6
d7ea968
c104803
0bd1731
2f86cab
9c629d2
f4e7f51
3080e8a
06c0ab1
7e46003
1a3dff9
77502ae
f024930
67ed39a
69b09d0
774a1ac
6805035
e9f9649
59d64ac
a1324c5
a9deb49
27c0d81
d4572bf
b31e918
144446e
d5f05dc
10ab39e
5b91435
da940a1
1314821
08a6691
45cfc05
13642a7
032708a
7c1c291
5210181
44821b9
4b22473
6c60026
02de8bc
3b9373c
7b3ecbe
e6c78f7
a3fdadf
3c99031
0c9494a
3abd410
3c9bdc3
1c23561
6bf9c9d
0c6effb
b9a32b3
f4d333f
36e9f05
1979ddf
78eca39
100d403
ab32fdb
1926883
29d8782
1e46b40
f8d9ebb
a6b9926
6c49862
2c0d7e1
87acbe5
7befac8
1f3b7e5
dccbcf7
e8f2951
be00fdd
b441c56
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| # Viewers Configuration Guide | ||
|
|
||
| Fileglancer supports dynamic configuration of OME-Zarr viewers. This allows administrators to customize which viewers are available in their deployment, override viewer URLs, and control how compatibility is determined. | ||
|
|
||
| ## Overview | ||
|
|
||
| The viewer system is built on capability manifests: | ||
|
|
||
| - **`viewers.config.yaml`**: Configuration file listing viewers and their manifest URLs | ||
| - **Capability manifest files**: YAML files describing each viewer's name, URL template, and capabilities | ||
| - **`@bioimagetools/capability-manifest`**: Library that loads manifests and checks dataset compatibility | ||
| - **`ViewersContext`**: React context that provides viewer information to the application | ||
|
|
||
| Each viewer is defined by a **capability manifest** hosted at a URL. The configuration file simply lists manifest URLs and optional overrides. At runtime, the manifests are fetched, and the `@bioimagetools/capability-manifest` library determines which viewers are compatible with a given dataset based on the manifest's declared capabilities. | ||
|
|
||
| ## Customize Viewers | ||
|
|
||
| **Note:** No configuration is required to use the default viewers defined in `frontend/src/config/viewers.config.yaml`. | ||
|
|
||
| 1. Copy the default config: `cp frontend/src/config/viewers.config.yaml frontend/viewers.config.yaml` | ||
| 2. Edit `frontend/viewers.config.yaml` to customize viewers | ||
| 3. Rebuild the application: `pixi run node-build` | ||
|
|
||
| ## Runtime Configuration (System Deployments) | ||
|
|
||
| For deployments where Fileglancer is installed from PyPI and the frontend is pre-built, you can override the viewers configuration at runtime without rebuilding. | ||
|
|
||
| Set the `FGC_VIEWERS_CONFIG` environment variable (or `viewers_config` in `config.yaml`) to the absolute path of a `viewers.config.yaml` file on disk: | ||
|
|
||
| ```env | ||
| FGC_VIEWERS_CONFIG=/opt/deploy/viewers.config.yaml | ||
| ``` | ||
|
|
||
| Or in `config.yaml`: | ||
|
|
||
| ```yaml | ||
| viewers_config: /opt/deploy/viewers.config.yaml | ||
| ``` | ||
|
|
||
| When set, the application serves this file via the API and the frontend uses it instead of the bundled config. The file follows the same format as the build-time `viewers.config.yaml`. | ||
|
|
||
| ### Precedence | ||
|
|
||
| The viewers configuration is resolved in the following order (highest priority first): | ||
|
|
||
| 1. **Runtime API config** — served from the path in `FGC_VIEWERS_CONFIG` (no rebuild required) | ||
| 2. **Build-time override** — `frontend/viewers.config.yaml` (requires rebuild) | ||
| 3. **Build-time default** — `frontend/src/config/viewers.config.yaml` (requires rebuild) | ||
|
|
||
| ## Configuration File | ||
|
|
||
| ### Location | ||
|
|
||
| There are three config locations, resolved in order of precedence: | ||
|
|
||
| | Location | Purpose | | ||
| | -------- | ------- | | ||
| | Path in `FGC_VIEWERS_CONFIG` | **Runtime override** — served via API, no rebuild required; ideal for system deployments | | ||
| | `frontend/viewers.config.yaml` | **Build-time override** — gitignored, safe to customize without merge conflicts | | ||
| | `frontend/src/config/viewers.config.yaml` | **Default config** — committed source file, used when no override exists | | ||
|
|
||
| Copy `frontend/src/config/viewers.config.yaml` to `frontend/viewers.config.yaml` to create a local override. This file is listed in `.gitignore` so your customizations will not conflict with upstream updates. | ||
|
|
||
| **Important:** The build-time configs are bundled at build time and changes require rebuilding the application. Runtime config via `FGC_VIEWERS_CONFIG` does **not** require rebuilding. | ||
|
|
||
| ### Structure | ||
|
|
||
| The configuration file has a single top-level key, `viewers`, containing a list of viewer entries. Each entry requires a `manifest_url` and supports optional overrides. | ||
|
|
||
| #### Viewer Entry Fields | ||
|
|
||
| | Field | Required | Description | | ||
| | ----------------------- | -------- | -------------------------------------------------------------------------------- | | ||
| | `manifest_url` | Yes | URL to a capability manifest YAML file | | ||
| | `instance_template_url` | No | Override the viewer's `template_url` from the manifest | | ||
| | `label` | No | Custom tooltip text (defaults to "View in {Name}") | | ||
|
|
||
| ### Default Configuration | ||
|
|
||
| The default `viewers.config.yaml` configures four viewers: | ||
|
|
||
| ```yaml | ||
| viewers: | ||
| - manifest_url: "https://raw.githubusercontent.com/BioImageTools/capability-manifest/host-manifests-and-docs/manifests/neuroglancer.yaml" | ||
|
|
||
| - manifest_url: "https://raw.githubusercontent.com/BioImageTools/capability-manifest/host-manifests-and-docs/manifests/avivator.yaml" | ||
|
|
||
| - manifest_url: "https://raw.githubusercontent.com/BioImageTools/capability-manifest/host-manifests-and-docs/manifests/validator.yaml" | ||
|
|
||
| - manifest_url: "https://raw.githubusercontent.com/BioImageTools/capability-manifest/host-manifests-and-docs/manifests/vole.yaml" | ||
| ``` | ||
|
|
||
| ## Capability Manifest Files | ||
|
|
||
| Manifest files describe a viewer's identity and capabilities. The default manifests are hosted in the [`@bioimagetools/capability-manifest`](https://github.com/BioImageTools/capability-manifest) repository. You can host your own manifest files anywhere accessible via URL. See the [`@bioimagetools/capability-manifest`](https://github.com/BioImageTools/capability-manifest) repository for information on how to format a viewer manifest. | ||
|
|
||
| ## Configuration Examples | ||
|
|
||
| ### Minimal: single viewer | ||
|
|
||
| ```yaml | ||
| viewers: | ||
| - manifest_url: "https://raw.githubusercontent.com/BioImageTools/capability-manifest/host-manifests-and-docs/manifests/neuroglancer.yaml" | ||
| ``` | ||
|
|
||
| ### Override a viewer's URL | ||
|
|
||
| Use `instance_template_url` to point to a custom deployment of a viewer while still using its manifest for capability matching: | ||
|
|
||
| ```yaml | ||
| viewers: | ||
| - manifest_url: "https://raw.githubusercontent.com/BioImageTools/capability-manifest/host-manifests-and-docs/manifests/avivator.yaml" | ||
| instance_template_url: "https://my-avivator-instance.example.com/?image_url={dataLink}" | ||
|
|
||
| ``` | ||
|
|
||
| ### Add a custom viewer | ||
|
|
||
| To add a new viewer, create a capability manifest YAML file, host it at a URL, and reference it in the config: | ||
|
|
||
| 1. Create a manifest file (e.g., `my-viewer.yaml`). Follow the format guidelines in the [`@bioimagetools/capability-manifest`](https://github.com/BioImageTools/capability-manifest) repository. | ||
|
|
||
| 2. Host the manifest at an accessible URL (e.g., on GitHub or any web server). | ||
|
|
||
| 3. Reference it in `viewers.config.yaml`: | ||
|
|
||
| ```yaml | ||
| viewers: | ||
| - manifest_url: "https://example.com/manifests/my-viewer.yaml" | ||
| label: "Open in My Viewer" | ||
| ``` | ||
|
|
||
| ## How Compatibility Works | ||
|
|
||
| The `@bioimagetools/capability-manifest` library handles all compatibility checking. When a user views an OME-Zarr dataset: | ||
|
|
||
| 1. The application reads the dataset's metadata (OME-Zarr version, axes, codecs, etc.) | ||
| 2. For each registered viewer, the library's `validateViewer()` function compares the dataset metadata against the manifest's declared capabilities | ||
| 3. Only viewers whose capabilities match the dataset are shown to the user | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to distinguish at least two different "levels" of capabilities, e.g.:
Generally speaking, these capabilities are about compatibility: ome_zarr_versions, compression_codecs, rfcs_supported. The rest are about support. Another way to think about this is like the NGFF viewer feature matrix. There is an additional dimension of information (color) which describes how the viewer behaves when presented with the data. Incompatible viewers should not be shown, but viewers which incompletely support the data should be shown, and their warnings logged or made accessible somewhere. For example, if a viewer doesn't support zarrv3, then OME-Zarrs with NGFF version >=0.5 should not be shown. But if a viewer does not support, say, omero_metadata, the viewer should still be shown.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See BioImageTools/capability-manifest@0594032#diff-a54261af011358e447a9f3ef717ee8e5d5bb4258f8d95e246b39cf3666244f1f. For now, ome_zarr_versions and compression_codecs are the only two that result in dataCompatible = false, and therefore the viewer isn't shown. Otherwise, a warning is logged to the console. I wasn't sure how to implement the check for rfcs_supported. Would I create an image metadata check to correspond to each RFC? For example, RFC 2 => check if the image is Zarr version 3. If so, then supporting this RFC is required to display the viewer. |
||
| 4. Incompatibility reasons (e.g., "Viewer does not support OME-Zarr v3") are logged to the browser console for debugging | ||
|
|
||
| This replaces the previous system where `valid_ome_zarr_versions` was a global config setting and custom viewers used simple version matching. Now all compatibility logic is driven by the detailed capabilities declared in each viewer's manifest. | ||
|
|
||
| ## Viewer Logos | ||
|
|
||
| Viewer logos are managed by the `@bioimagetools/capability-manifest` library. Logo resolution follows this order: | ||
|
|
||
| 1. **Override**: If the manifest includes a `viewer.logo` field, that URL is used directly | ||
| 2. **Convention-based**: Otherwise, the logo URL is derived from the viewer name (lowercased, spaces replaced with hyphens, e.g. "OME-Zarr Validator" → `ome-zarr-validator.png`) and hosted alongside the manifests | ||
| 3. **Fallback**: If the logo fails to load at runtime, a bundled fallback image is shown | ||
|
|
||
| ## Development | ||
|
|
||
| When developing with custom configurations: | ||
|
|
||
| 1. Copy the default config: `cp frontend/src/config/viewers.config.yaml frontend/viewers.config.yaml` | ||
| 2. Edit `frontend/viewers.config.yaml` | ||
| 3. Rebuild frontend: `pixi run node-build` or use watch mode: `pixi run dev-watch` | ||
| 4. Check the browser console for viewer initialization messages | ||
|
|
||
| ### Validation | ||
|
|
||
| The configuration is validated at build time using Zod schemas (see `frontend/src/config/viewersConfig.ts`). Validation enforces: | ||
|
|
||
| - The `viewers` array must contain at least one entry | ||
| - Each entry must have a valid `manifest_url` (a properly formed URL) | ||
| - Optional fields (`instance_template_url`, `label`) must be strings if present | ||
|
|
||
| At runtime, manifests that fail to load are skipped with a warning. If a viewer has no `template_url` (neither from its manifest nor from `instance_template_url` in the config), it is also skipped. | ||
|
|
||
| ## Copy URL Tool | ||
|
|
||
| The "Copy data URL" tool is always available when a data URL exists, regardless of viewer configuration. | ||
Uh oh!
There was an error while loading. Please reload this page.