Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't write to H5T_ARRAY datasets #249

Open
mattjala opened this issue Aug 22, 2023 · 0 comments
Open

Can't write to H5T_ARRAY datasets #249

mattjala opened this issue Aug 22, 2023 · 0 comments
Assignees
Labels

Comments

@mattjala
Copy link
Contributor

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants