Skip to content
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

Parse metadata of committed datatypes with h5grove #1710

Merged
merged 1 commit into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions packages/app/src/providers/h5grove/models.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type {
AttributeValues,
EntityKind,
Filter,
} from '@h5web/shared/hdf5-models';
import type { AttributeValues, Filter } from '@h5web/shared/hdf5-models';

export type H5GroveEntityResponse = H5GroveEntity;
export type H5GroveDataResponse = unknown;
Expand All @@ -16,6 +12,7 @@ export interface H5GroveErrorResponse {
export type H5GroveEntity =
| H5GroveGroup
| H5GroveDataset
| H5GroveDatatype
| H5GroveSoftLink
| H5GroveExternalLink;

Expand All @@ -25,20 +22,26 @@ export interface H5GroveBaseEntity {
}

export interface H5GroveGroup extends H5GroveBaseEntity {
kind: EntityKind.Group;
kind: 'group';
loichuder marked this conversation as resolved.
Show resolved Hide resolved
children?: H5GroveEntity[];
attributes: H5GroveAttribute[];
}

export interface H5GroveDataset extends H5GroveBaseEntity {
kind: EntityKind.Dataset;
kind: 'dataset';
shape: number[];
type: H5GroveType;
chunks: number[] | null;
filters: Filter[] | null;
attributes: H5GroveAttribute[];
}

export interface H5GroveDatatype extends H5GroveBaseEntity {
kind: 'datatype';
type: H5GroveType;
attributes: H5GroveAttribute[];
}

export interface H5GroveSoftLink extends H5GroveBaseEntity {
kind: 'soft_link';
target_path: string;
Expand Down
15 changes: 13 additions & 2 deletions packages/app/src/providers/h5grove/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export function parseEntity(
const { name } = h5gEntity;
const baseEntity = { name, path };

if (h5gEntity.kind === EntityKind.Group) {
if (h5gEntity.kind === 'group') {
const { children = [], attributes: attrsMetadata } = h5gEntity;
const attributes = parseAttributes(attrsMetadata);
const baseGroup: Group = {
Expand All @@ -74,7 +74,7 @@ export function parseEntity(
};
}

if (h5gEntity.kind === EntityKind.Dataset) {
if (h5gEntity.kind === 'dataset') {
const {
attributes: attrsMetadata,
type,
Expand All @@ -94,6 +94,17 @@ export function parseEntity(
};
}

if (h5gEntity.kind === 'datatype') {
const { attributes: attrsMetadata, type } = h5gEntity;
return {
...baseEntity,
kind: EntityKind.Datatype,
type: parseDType(type),
rawType: type,
attributes: parseAttributes(attrsMetadata),
};
}

if (h5gEntity.kind === 'soft_link') {
const { target_path } = h5gEntity;
return {
Expand Down