Git Product home page Git Product logo

Comments (8)

loichuder avatar loichuder commented on June 12, 2024 1

Thank you for giving additional information ! We are not using these features ourselves so it was hard to gain insight on how to solve the problem.

I will have a second look at this

from jupyterlab-h5web.

cherbon1 avatar cherbon1 commented on June 12, 2024 1

Thank you for the update and for looking into this! I tested it and it to work fine.
I agree that converting to string isn't ideal, but it's a good enough fix for now for preventing crashes.
Thanks again!

from jupyterlab-h5web.

loichuder avatar loichuder commented on June 12, 2024

Thanks for the report ! This is a back-end issue but we can do something about it.

I did not use RegionReference myself so I would need a bit more info.

Would you want the attribute value to be visible ? If so, what should it show ?
Or, would it be acceptable to skip completely the attribute ?

from jupyterlab-h5web.

planetmarshall avatar planetmarshall commented on June 12, 2024

I think ideally the attribute should show the referenced value, so for example

with h5py.File("region_bug.h5", "w") as h5:
    data = h5.create_dataset("data", data=np.array([1, 2, 42]))
    h5.attrs["answer"] = data.regionref[2]

Should be displayed as

answer 42

Though it should probably also indicate that it's a reference - the output of

h5dump region_bug.h5

is

HDF5 "region_bug.h5" {
GROUP "/" {
   ATTRIBUTE "answer" {
      DATATYPE  H5T_REFERENCE { H5T_STD_REF_DSETREG }
      DATASPACE  SCALAR
      DATA {
      (0): DATASET /data {(2)-(2)}
      }
   }
   DATASET "data" {
      DATATYPE  H5T_STD_I64LE
      DATASPACE  SIMPLE { ( 3 ) / ( 3 ) }
      DATA {
      (0): 1, 2, 42
      }
   }
}
}

So maybe

answer (ref /data {(2)-(2)}) 42

from jupyterlab-h5web.

t20100 avatar t20100 commented on June 12, 2024

Since the region reference can refer to any slicing in a dataset, displaying the values in the "Inspect" tab can be problematic.

from jupyterlab-h5web.

cherbon1 avatar cherbon1 commented on June 12, 2024

This issue affects h5py.Reference as well as h5py.RegionReference. I encountered this when using HDF5 documents that make use of the scales feature, which implements some references between datasets. Here's a short script to reproduce the error:

from jupyterlab_h5web import H5Web
import h5py
import numpy as np

# Generate data
x = np.linspace(-1, 1, 11)
y = np.linspace(-1.5, 1.5, 31)
xx, yy = np.meshgrid(x, y, indexing='ij')
mydata = np.exp(-np.sqrt(xx**2 + yy**2))

filename = 'Test.h5'
with h5py.File(filename, 'w') as f:
    # Add datasets to file
    data_dset = f.create_dataset(name='mydata', data=mydata)
    x_dset = f.create_dataset(name='x', data=x)
    y_dset = f.create_dataset(name='y', data=y)
    
    # Make x and y into scales
    x_dset.make_scale(name='x')
    y_dset.make_scale(name='y')
    
    # Attach scales to dataset
    data_dset.dims[0].attach_scale(x_dset)
    data_dset.dims[1].attach_scale(y_dset)

H5Web(filename)

Running this generates the following error:

TypeError: Type is not JSON serializable: h5py.h5r.Reference

In the meantime, one can modify AttributeHandler.get_content() to ignore the problematic entries, but I think a more general solution would be appropriate

from jupyterlab-h5web.

loichuder avatar loichuder commented on June 12, 2024

v0.0.12 of the extension makes it compatible with h5grove latest version v0.0.11 (the package serving HDF5 contents). This version no longer crash on Reference but converts them as strings.

You can try by updating the extension. This should install h5grove latest version (this can be ensured by running pip install -U h5grove afterwards).

I concur that converting references as strings does not give much useful info so I will try later to implement something more involved to at least give the name of the dataset it refers to.

from jupyterlab-h5web.

loichuder avatar loichuder commented on June 12, 2024

I concur that converting references as strings does not give much useful info so I will try later to implement something more involved to at least give the name of the dataset it refers to.

I remember investigating this a while ago and it did not amount of anything because the reference needs outside information to be resolved. It was some weird stuff like it needs to have the file id of the entity it points to, which I don't know how to deduce consistently.

I am afraid we will have to do with strings for now.

from jupyterlab-h5web.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.