HDFGroup / h5serv

Reference service implementation of the HDF5 REST API
Other
168 stars 35 forks source link

External link to subgroup of domain #109

Open znarthur opened 7 years ago

znarthur commented 7 years ago

I am trying to repackage individual groups (of nexus entries) stored under separate domains into one hdf5 file. I have already created an external database of searchable metadata from within the individual scans, and want to be able to download (using the exporth5.py or a modifed version) the contents of this temporary domain (which is just a series of links of similiar scans from across the h5server database) . To this end I started by creating a temporary domain, temp.sgm.clsi.ca, and started adding external links to the desired groups. It turns out that the generated external link e.g.
links": [ { "target": "http://localhost:5000/#h5path(/entry1)?host=Cu_mesh_scan.zarthur.sgm.clsi.ca", "h5path": "/entry1", "title": "entry1", "h5domain": "Cu_mesh_scan.zarthur.sgm.clsi.ca", "href": "http://localhost:5000/groups/8ad1657e-0e78-11e7-b869-080027f91ab0/links/entry1?host=temp.sgm.clsi.ca", "class": "H5L_TYPE_EXTERNAL" } ] .. doesn't actually refer to anything and is redirected to the base uri for the h5serv. In fact, even the root of the domain isn't accessible using this href construct. I created the external link using the python requests library:

payload {'h5domain': 'Cu_mesh_scan.zarthur.sgm.clsi.ca', 'h5path': '/entry1'} string 'http://localhost:5000/groups/8ad1657e-0e78-11e7-b869-080027f91ab0/links/entry1' rsg = requests.put(string, data = json.dumps(payload), headers={'host':'temp.sgm.clsi.ca'})

Additionaly, no matter how I construct the GET request using h5path and h5domain parameters I can't seem to get the desired response from getUUIDByPath coming out of hdf5db either. In summary, it seems like the external linking is not functioning the way one would hope, and I am unsure of how best to remedy or work around this problem.

jreadey commented 7 years ago

I'm not surprised you've ran into some issues with external links. Even with the HDF5 lib, it's not exactly defined how the client should deal with the filename and path values returned (e.g. what happens to a relative path if the file is moved to a different directory?).

Anyway, I did use external links for the TOC (table of contents) functionality in h5serv. If you go to: https://data.hdfgroup.org:7258/groups/65a37100-45a3-11e6-9008-0242ac110003/links and look at some of the external links, you'll see how the h5domain and h5keys work. (you may want to install a JSON plugin for your browser to make this easier to see).

Clicking on "target" key in an external link jumps you to that domain/path (though it doesn't seem any of these are using any other path than '/').

Does that help? If this is a bug rather than a usage issue, can you submit a PR with a h5serv/test/integ/linktest.py test that illustrates the problem?

znarthur commented 7 years ago

I didn't end up looking too much into this. I instead just used a little visititems from h5pyd to copy the contents under /entry# and write it to a local file. I will see if I can reproduce the original problem and submit a PR next week.

jreadey commented 7 years ago

Ok, that will be great.