From a989f43cb5c344b29d2615db087a1fa5ade17874 Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Thu, 7 Mar 2024 16:46:31 +0100 Subject: [PATCH 1/3] Fix error fallback position --- packages/app/src/App.module.css | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/app/src/App.module.css b/packages/app/src/App.module.css index 334e9e3c6..27fb42a5d 100644 --- a/packages/app/src/App.module.css +++ b/packages/app/src/App.module.css @@ -148,6 +148,7 @@ .error { composes: error from global; + grid-area: vis; } .error > span { From dc92faa8a452e74ee47ea227bd1dd430c9bd42f6 Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Thu, 7 Mar 2024 16:47:24 +0100 Subject: [PATCH 2/3] Improve display of `UInt8Array` values in Raw vis --- packages/lib/src/vis/raw/RawVis.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/lib/src/vis/raw/RawVis.tsx b/packages/lib/src/vis/raw/RawVis.tsx index 0eed23456..a00757fec 100644 --- a/packages/lib/src/vis/raw/RawVis.tsx +++ b/packages/lib/src/vis/raw/RawVis.tsx @@ -8,7 +8,11 @@ interface Props { function RawVis(props: Props) { const { value } = props; - const valueAsStr = JSON.stringify(value, null, 2); + + const valueAsStr = + value instanceof Uint8Array + ? `Uint8Array [ ${value.toString()} ]` + : JSON.stringify(value, null, 2); return (
From c407d319dbe4ff5f8092efedd5e371e2495ffbeb Mon Sep 17 00:00:00 2001 From: Axel Bocciarelli Date: Thu, 7 Mar 2024 16:48:43 +0100 Subject: [PATCH 3/3] Fetch opaque datasets with h5grove as binary --- .../__snapshots__/h5grove-api.test.ts.snap | 36 +++++++++++++++---- .../app/src/providers/h5grove/h5grove-api.ts | 10 ++++-- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/packages/app/src/providers/h5grove/__snapshots__/h5grove-api.test.ts.snap b/packages/app/src/providers/h5grove/__snapshots__/h5grove-api.test.ts.snap index 8098df706..5cfee01cc 100644 --- a/packages/app/src/providers/h5grove/__snapshots__/h5grove-api.test.ts.snap +++ b/packages/app/src/providers/h5grove/__snapshots__/h5grove-api.test.ts.snap @@ -796,7 +796,11 @@ exports[`test file matches snapshot 1`] = ` "class": "Opaque", "tag": "", }, - "value": """, + "value": Uint8Array [ + 0, + 17, + 34, + ], }, { "name": "byte_string_1D", @@ -813,10 +817,10 @@ exports[`test file matches snapshot 1`] = ` "class": "Opaque", "tag": "", }, - "value": [ - "", - "", - """, + "value": Uint8Array [ + 0, + 17, + 34, ], }, { @@ -832,7 +836,16 @@ exports[`test file matches snapshot 1`] = ` "class": "Opaque", "tag": "", }, - "value": [AxiosError: Request failed with status code 500], + "value": Uint8Array [ + 150, + 177, + 135, + 93, + 0, + 0, + 0, + 0, + ], }, { "name": "datetime64_not-a-time_scalar", @@ -847,7 +860,16 @@ exports[`test file matches snapshot 1`] = ` "class": "Opaque", "tag": "", }, - "value": [AxiosError: Request failed with status code 500], + "value": Uint8Array [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 128, + ], }, { "name": "complex64_scalar", diff --git a/packages/app/src/providers/h5grove/h5grove-api.ts b/packages/app/src/providers/h5grove/h5grove-api.ts index 5e77beebf..0e166939e 100644 --- a/packages/app/src/providers/h5grove/h5grove-api.ts +++ b/packages/app/src/providers/h5grove/h5grove-api.ts @@ -7,6 +7,7 @@ import type { ProvidedEntity, Value, } from '@h5web/shared/hdf5-models'; +import { DTypeClass } from '@h5web/shared/hdf5-models'; import type { AxiosRequestConfig } from 'axios'; import { DataProviderApi } from '../api'; @@ -45,9 +46,13 @@ export class H5GroveApi extends DataProviderApi { ): Promise { const { dataset } = params; + if (dataset.type.class === DTypeClass.Opaque) { + return new Uint8Array(await this.fetchBinaryData(params)); + } + const DTypedArray = h5groveTypedArrayFromDType(dataset.type); if (DTypedArray) { - const buffer = await this.fetchBinaryData(params); + const buffer = await this.fetchBinaryData(params, true); const array = new DTypedArray(buffer); return hasScalarShape(dataset) ? array[0] : array; } @@ -149,6 +154,7 @@ export class H5GroveApi extends DataProviderApi { private async fetchBinaryData( params: ValuesStoreParams, + safe = false, ): Promise { const { data } = await this.cancellableFetchValue( '/data/', @@ -157,7 +163,7 @@ export class H5GroveApi extends DataProviderApi { path: params.dataset.path, selection: params.selection, format: 'bin', - dtype: 'safe', + dtype: safe ? 'safe' : undefined, }, 'arraybuffer', );