Skip to content

Rewrite HSDS provider - #2061

Draft
axelboc wants to merge 1 commit into
mainfrom
improve-hsds
Draft

axelboc wants to merge 1 commit into
mainfrom
improve-hsds

Conversation

@axelboc

@axelboc axelboc commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

I'm rewriting hsds-api.ts from the ground up using the latest API endpoints documented at https://github.com/HDFGroup/hsds/blob/v1.0.1/openapi.yml

Batching

The screenshots below show the number of requests going from 64 to only 2 requests when opening the sample-hsds.h5 sample file:

image image

This is thanks to the following endpoints and features:

  • GET / with h5path, include_links and include_attrs query params — this combines fetching the domain, then the root group, then the attributes of the group, and then the links of the group into a single request
  • POST /withparent_idandinclude_attrsquery params, and{ h5paths : string[] }` request body — this allows us to fetch the metadata of all the children of a group in a single request
  • GET /{collection}/{id}/attributes with IncludeData — this allows getting the values of all the attributes of an entity in a single request

Typed arrays

GET /datasets/{id}/value supports the Accept: application/octet-stream header to request a binary response instead of JSON. So we replicate the getValue logic from h5grove-api.ts to return typed arrays when possible.

The screenshots below show that we now get true Infinty and NaN values instead of strings, and typed arrays for opaque datasets:

image image image

Opening as draft, as I'd like to keep testing with other HDF5 files, notably soft/external links, NeXux attributes, binary images, etc.

@axelboc
axelboc marked this pull request as draft September 17, 2026 13:32
interface Props {
url: string;
filepath: string;
domain: string;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Using the HSDS lingo is less confusing I think. The domain is still exposed as filepath through the DataContext, though.

domain: string;
resetKeys?: unknown[];
fetcher: Fetcher;
fetcher?: Fetcher;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The API works with a default basic fetcher, without authentication. This allows testing with the internal HSDS support server instead of Bosquet.


const response = await fetch(`${url}?${queryParams.toString()}`, {
...fetchOpts,
...moreFetchOpts,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This lets me pass other options like method: 'POST' and headers with each request.

} from './utils';

export class HsdsApi extends DataProviderApi {
private readonly entities = new Map<string, HsdsEntity<ProvidedEntity>>();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

GET / with the h5path query param allows fetching the metadata of an entity at a given path. We don't need to walk the entire tree from the root any more, so we don't need to cache the entities along the way either.

path: '/',
name: this.filepath,
});
if (response.class === 'group') {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This block handles groups specifically as we need to fetch the metadata of the children. GET /?h5path= with include_links=true gives us the links of the group but doesn't resolve them.

this.fetchAttributeWithValue(collection, id, attr.name),
);

const attrsWithValues = await Promise.all(attrsPromises);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We used to make one value request per attribute!

This branch has not been deployed

No deployments
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.

1 participant