Skip to content

Commit

Permalink
Parse metadata of committed datatypes with h5grove
Browse files Browse the repository at this point in the history
  • Loading branch information
axelboc committed Sep 13, 2024
1 parent 18f038a commit e21939c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
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';
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

0 comments on commit e21939c

Please sign in to comment.