HDFGroup / HDFGroup/hsds

Can't write to H5T_ARRAY datasets

Open
#249 2 comments 0 reactions 1 assignee Assigned to @mattjala View on GitHub
bug
Dominant language
Python
Stars
157
Forks
60
Avg merge
1d 5h
Merged PRs (30d)
15

Description

Test code attempting to create and write to an H5T_ARRAY dataset (originally written in `value_test.py`):

```
def testPutArray(self):
headers = helper.getRequestHeaders(domain=self.base_domain)
req = self.endpoint + "/"

# Get root uuid
rsp = self.session.get(req, headers=headers)
self.assertEqual(rsp.status_code, 200)
rspJson = json.loads(rsp.text)
root_uuid = rspJson["root"]
helper.validateId(root_uuid)

datatype = {
"class": "H5T_ARRAY",
"base": {
"class": "H5T_INTEGER",
"base": "H5T_STD_I32LE"
},
"dims": [6]
}

payload = {
"type": datatype,
"shape": 1,
}

req = self.endpoint + "/datasets"
rsp = self.session.post(req, data=json.dumps(payload), headers=headers)
self.assertEqual(rsp.status_code, 201) # create dataset

rspJson = json.loads(rsp.text)
array_dset_uuid = rspJson["id"]
self.assertTrue(helper.validateId(array_dset_uuid))

# verify the shape of the dataset
req = self.endpoint + "/datasets/" + array_dset_uuid
rsp = self.session.get(req, headers=headers)
self.assertEqual(rsp.status_code, 200) # get dataset
rspJson = json.loads(rsp.text)
shape = rspJson["shape"]
self.assertEqual(shape["class"], "H5S_SIMPLE")

# link new dataset as 'array_type_dset'
name = "array_type_dset"
req = self.endpoint + "/groups/" + root_uuid + "/links/" + name
payload = {"id": array_dset_uuid}
rsp = self.session.put(req, data=json.dumps(payload), headers=headers)
self.assertEqual(rsp.status_code, 201)

# read initial values
req = self.endpoint + "/datasets/" + array_dset_uuid + "/value"
rsp = self.session.get(req, headers=headers)
self.assertEqual(rsp.status_code, 200)
rspJson = json.loads(rsp.text)
self.assertTrue("value" in rspJson)
self.assertTrue(np.array_equal(rspJson["value"][0], np.zeros(6)))

# write to the array
value = [[1, 2, 3, 4, 5, 6]]
payload = {"value": value}
req = self.endpoint + "/datasets/" + array_dset_uuid + "/value"
rsp = self.session.put(req, data=json.dumps(payload), headers=headers)
self.assertEqual(rsp.status_code, 200) # write value

# read back the value
rsp = self.session.get(req, headers=headers)
self.assertEqual(rsp.status_code, 200)
rspJson = json.loads(rsp.text)
self.assertTrue("value" in rspJson)
self.assertTrue(np.array_equal(rspJson["value"], value))
```

This fails at the 200 response code assert after trying to write to the dataset with `AssertionError: 400 != 200`.

Log output from the service node:
```
REQ> PUT: /datasets/d-5b64a0fe-22b9a690-5c8a-aeba16-834c57/value [/home/test_user1/hsds_test/valuetest/20230822T165739_378063Z]
DEBUG> num tasks: 4 active tasks: 4
DEBUG> validateUserPassword username: test_user1
DEBUG> looking up username: test_user1
DEBUG> user password validated
DEBUG> PUT value - request_type is json
INFO> getObjectJson d-5b64a0fe-22b9a690-5c8a-aeba16-834c57
DEBUG> found d-5b64a0fe-22b9a690-5c8a-aeba16-834c57 in meta_cache
DEBUG> PUT Value selection: (slice(0, 1, 1),)
DEBUG> selection shape: [1]
DEBUG> selection num elements: 1
WARN> input data doesn't match selection
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.