-
Notifications
You must be signed in to change notification settings - Fork 195
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
feat(zarr): Flatten zarr module, remove XML-parsing #1462
Conversation
const tileSize = guessTileSize(data[0]); | ||
const labels = options.labels ?? guessLabels(rootAttrs); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no labels are provided, they are inferred (if possible) from the rootAttrs
. For now, guessLabels
only infers if OME-Zarr.
const grp = await openGroup(store, path); | ||
const rootAttrs = await grp.attrs.asObject() as RootAttrs; | ||
|
||
if (!Array.isArray(rootAttrs.multiscales)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checks that multiscales extension is implemented in rootAttrs (generic across Zarr datasets)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is OME the only possible Zarr extension? Otherwise should we in the future make a more general interface for working with Zarr extensions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A Zarr store is organized into a hierarchy of nodes. Each node can either be a group
or an array
, and only a group
may contain other nodes. The multiscales extension is not OME-Zarr -specific (although it was spearheaded by OME folks working on zarr).
The mutiscales extension adds a "multiscales"
key-value to group
metadata that ultimately provides the relative paths to other array sub-resolutions saved in the store. OME-Zarr chooses to also store additional metadata in the same group but under a different key (omero
). This function reads the multiscales metadata (to initialize the pixel-sources), but simply returns the complete root metadata ({ multiscales, omero }
for Ome-Zarr) back to the end-user to choose what to do with it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late addition, but there has been off and on discussion of moving the multiscales to a "super-interface" of OME-Zarr, i.e. a more generalized pyramidal image spec.
"version": "0.1" | ||
} | ||
], | ||
"omero": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OME metadata in root attrs. Used to distinguish multiscale dataset is OME-Zarr.
Should be ready for review. I consolidated the handling of different Zarr formats in |
The tests are failing in the browser:
The issue seems to be with |
dd9698d
to
21094a6
Compare
Rebased again on master. I commented out the browser tests for zarr due to the issue with |
modules/zarr/package.json
Outdated
@@ -1,6 +1,6 @@ | |||
{ | |||
"name": "@loaders.gl/zarr", | |||
"version": "3.0.0-alpha.21", | |||
"version": "3.0.0-alpha.18", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think other modules are up to .21
now?
loaders.gl/modules/core/package.json
Line 3 in ba44020
"version": "3.0.0-alpha.21", |
modules/zarr/src/lib/storage.ts
Outdated
@@ -0,0 +1,38 @@ | |||
import {fetchFile} from '@loaders.gl/core'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You removed @loaders.gl/core
from the package.json
...
modules/zarr/src/lib/storage.ts
Outdated
|
||
async getItem(key: string, options?: RequestInit): Promise<ArrayBuffer> { | ||
const filepath = joinUrlParts(this.root, key); | ||
const response = await fetchFile(filepath, options); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you just use fetch
here instead of fetchFile
? For Node we expect users to import @loaders.gl/polyfills
which polyfills fetch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The zarr.HTTPStore
does exactly this ( uses fetch
internally and expects a polyfil in node).
I guess the question is if loadZarr
is given a string source, we need to pick the correct store to initialize FileFetchStore
vs HTTPStore
depending on the URL (one for a local store with node and the latter for a remote store), correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still running into issues here. How can do I resolve the alias for a fixture path to either a path or URL? e.g.
const path = '@loaders.gl/zarr/test/data/multiscale.zarr';
// /Users/..../zarr/test/data/multiscale.zarr
// or
// https://localhost:5001/zarr/test/data/multiscale.zarr
Am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This alias doesn't work?
Line 61 in 24e3e60
'@loaders.gl/zarr/test': path.resolve(basename, '../modules/zarr/test'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm missing something conceptually with how these aliases are resolved. For the following path:
const path = '@loaders.gl/zarr/test/data/multiscale.zarr';
How can I resolve this to the HTTP endpoint the file is served from (http://localhost:5000/modules/zarr/test/multiscale.zarr
) for use with the fetch
API? Calling resolvePath(path)
returns /modules/zarr/test/multiscale.zarr
)
Hmm, fetch('/modules/zarr/test/multiscale.zarr/.zgroup')
responds with a 404 in the browser. I'm having trouble figuring out why this file isn't served.
const grp = await openGroup(store, path); | ||
const rootAttrs = await grp.attrs.asObject() as RootAttrs; | ||
|
||
if (!Array.isArray(rootAttrs.multiscales)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is OME the only possible Zarr extension? Otherwise should we in the future make a more general interface for working with Zarr extensions?
There is still an issue with I have disabled the browser tests, like geotiff, in favor of merging this PR sooner rather than later to avoid having this PR go stale. We can follow up in subsequent PR to fix both issues (geotiff + zarr). |
Applies changes from #1446 to
master