[HDF Forum] [HSDS] How to issue requests to HSDS Lambda?
Glad it worked with the smaller selection! One problem with the Lambda implementation for HSDS is that it only supported JSON responses. For data selections, converting binary data to JSON adds a lot of overhead and memory usage. To improve this I pushed out an HSDS update yesterday that enables hex-encoded responses. You just need to add a header specifying "octet-stream". Here's an example event: { "method": "GET", "path": "/datasets/d-096b7930-5dc5b556-dbc8-00c5ad-8aca89/value", "headers": { "accept": "application/octet-stream" }, "params": { "domain": "/nrel/nsrdb/v3/nsrdb_2000.h5", "select": "[0:1000,0:1000]", "bucket": "nrel-pds-hsds" } } You'll still get a JSON response from Lambda, but the body key will have a hex-encoded value (i.e. it will use twice as many bytes as the binary equivalent). The above request took 6.3 seconds to run and consumed 268 MB of memory. I was hopefully that a larger selection would work as well, but with a [1000,1] selection I get an AWS error: "Response payload size exceeded maximum allowed payload size (6291556 bytes)." So it looks like there's no support yet for responses larger than 6MB. What would be nice would be if AWS Lambda supported true binary responses and HTTP streaming as discussed in my blog from last week: https://www.hdfgroup.org/2022/08/hsds-streaming/. Amazon has been adding new features to Lambda each year, so we can be hopeful! BTW, you can now use h5pyd with Lambda. You just need to setup your .hscfg like this: hs_endpoint = http+lambda://hslambda hs_username = hslambda hs_password = lambda hs_api_key = None Where the endpoint is "http+lambda://" plus the name of your lambda function ("hslambda" in my case). Other than that h5pyd programs should work the same as with a regular HSDS server (if not as fast). Anyway, would just setting up an HSDS server be the best approach in your case? In my view Lambda works best for moderately sized selections when there is a fairly large reduction in the amount of data returned vs. the number of chunks touched. E.g. with the NSRDB data above, if I have a selection of [1234, 0: 2018392] it hits 10 GB of chunk data to return a 4MB response. In this case, it's a big advantage to run Lambda in the same AWS region as the S3 store vs. having to move the entire 10 GB out of Amazon (say you were using the ros3 VFD on your laptop). --- [Visit Topic](https://forum.hdfgroup.org/t/how-to-issue-requests-to-hsds-lambda/10136/13) or reply to this email to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://forum.hdfgroup.org/email/unsubscribe/10c7ad5c80c22937d685e8d6bbb7488146b11f5ec19dff72f6ffc6195cff5ef6).
[HDF Forum] [HSDS] How to issue requests to HSDS Lambda?
To make a larger selection (about 1G data), I changed the max_request_size and client_max_body_size to a larger number. But after running the lambda, it gave an error of running out of memory (I set to 10G). How does reading 1G data run out of 10G memory? Is there anything I did wrong here? --- [Visit Topic](https://forum.hdfgroup.org/t/how-to-issue-requests-to-hsds-lambda/10136/12) or reply to this email to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://forum.hdfgroup.org/email/unsubscribe/aac0056b40d9b7f07a360b7e6d3f6aa6206b0c22cf8cb9d6d3e06c809d0e1193).
[HDF Forum] [HSDS] How to issue requests to HSDS Lambda?
I tested a smaller selection and it finally worked. --- [Visit Topic](https://forum.hdfgroup.org/t/how-to-issue-requests-to-hsds-lambda/10136/11) or reply to this email to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://forum.hdfgroup.org/email/unsubscribe/89ce52af32120b7908bea5735cc20b036fa559af171ca341a21641efca963f04).
[HDF Forum] [HSDS] How to issue requests to HSDS Lambda?
I looked the older logs. There is an error in handling request. >2022-08-29T14:12:29.869-04:00 Error handling request 2022-08-29T14:12:29.869-04:00 Traceback (most recent call last): 2022-08-29T14:12:29.869-04:00 File "/var/lang/lib/python3.8/site-packages/aiohttp/web_protocol.py", line 422, in _handle_request 2022-08-29T14:12:29.869-04:00 resp = await self._request_handler(request) 2022-08-29T14:12:29.869-04:00 File "/var/lang/lib/python3.8/site-packages/aiohttp/web_app.py", line 499, in _handle 2022-08-29T14:12:29.869-04:00 resp = await handler(request) 2022-08-29T14:12:29.869-04:00 File "/var/lang/lib/python3.8/site-packages/hsds/dset_dn.py", line 43, in GET_Dataset 2022-08-29T14:12:29.869-04:00 dset_json = await get_metadata_obj(app, dset_id, bucket=bucket) 2022-08-29T14:12:29.869-04:00 File "/var/lang/lib/python3.8/site-packages/hsds/datanode_lib.py", line 378, in get_metadata_obj 2022-08-29T14:12:29.869-04:00 obj_json = await getStorJSONObj(app, s3_key, bucket=bucket) 2022-08-29T14:12:29.869-04:00 File "/var/lang/lib/python3.8/site-packages/hsds/util/storUtil.py", line 217, in getStorJSONObj 2022-08-29T14:12:29.869-04:00 data = await client.get_object(key, bucket=bucket) 2022-08-29T14:12:29.869-04:00 File "/var/lang/lib/python3.8/site-packages/hsds/util/s3Client.py", line 257, in get_object 2022-08-29T14:12:29.869-04:00 async with session.create_client('s3', **kwargs) as _client: 2022-08-29T14:12:29.869-04:00 File "/var/lang/lib/python3.8/site-packages/aiobotocore/session.py", line 37, in __aenter__ 2022-08-29T14:12:29.869-04:00 self._client = await self._coro 2022-08-29T14:12:29.869-04:00 File "/var/lang/lib/python3.8/site-packages/aiobotocore/session.py", line 121, in _create_client 2022-08-29T14:12:29.869-04:00 client = await client_creator.create_client( 2022-08-29T14:12:29.869-04:00 File "/var/lang/lib/python3.8/site-packages/aiobotocore/client.py", line 46, in create_client 2022-08-29T14:12:29.869-04:00 self._register_lazy_block_unknown_fips_pseudo_regions(service_client) 2022-08-29T14:12:29.869-04:00 AttributeError: 'AioClientCreator' object has no attribute '_register_lazy_block_unknown_fips_pseudo_regions' It seems like the error from package aiobotocore. Is there any version problem here? --- [Visit Topic](https://forum.hdfgroup.org/t/how-to-issue-requests-to-hsds-lambda/10136/10) or reply to this email to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://forum.hdfgroup.org/email/unsubscribe/13c2cb83d7c8d001f3b6c604174940c5f854a423cb48ee7b60c53ed341912cfd).
[HDF Forum] [HSDS] How to issue requests to HSDS Lambda?
dn no longer has error but sn still has the same error with 500 code. >sn INFO> http_get status: 500 for req: >http://127.0.0.1/datasets/d-2f22962d-e0592840-e15c-625d94-9e4cbf sn ERROR> request to http://127.0.0.1/datasets/d-2f22962d-e0592840-e15c-625d94-9e4cbf failed with code: 500 --- [Visit Topic](https://forum.hdfgroup.org/t/how-to-issue-requests-to-hsds-lambda/10136/8) or reply to this email to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://forum.hdfgroup.org/email/unsubscribe/eb1bb3f9ad84d754ef1360f3748812a80e2a31e889c54095d278166e8e3ce3b9).
[HDF Forum] [HSDS] How to issue requests to HSDS Lambda?
I see. Let me take a try. --- [Visit Topic](https://forum.hdfgroup.org/t/how-to-issue-requests-to-hsds-lambda/10136/7) or reply to this email to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://forum.hdfgroup.org/email/unsubscribe/f2e025db7d75e43ad47e7ecca6086ba90b19a9a03126a80d67a9abd7e39d102d).
[HDF Forum] [HSDS] How to issue requests to HSDS Lambda?
There is one line: > dn1 ERROR> FileClient init: root_dir config not set --- [Visit Topic](https://forum.hdfgroup.org/t/how-to-issue-requests-to-hsds-lambda/10136/5) or reply to this email to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://forum.hdfgroup.org/email/unsubscribe/7bfe440ae9f60ae517cacc3e6f4790d13f14eec80775ba16fbbe1a5063f3db0c).
[HDF Forum] [HSDS] How to issue requests to HSDS Lambda?
Hi John, I replaced the "request" in json with "path" and changed the dataset name to its id as follows. Seems the request was parsed correctly but I still got a 500 status code. The log is also attached. >{ "method": "GET", "path": "/datasets/d-2f22962d-e0592840-e15c-625d94-9e4cbf/value", "params": { "domain": "/home/admin/hsds.hdf5", "select": "[0:100,0:100]", "bucket": "hsds-hyperslab-test" } } > REQ> GET: /datasets/d-2f22962d-e0592840-e15c-625d94-9e4cbf/value > [/home/admin/hsds.hdf5] sn INFO> getObjectJson d-2f22962d-e0592840-e15c-625d94-9e4cbf sn INFO> http_get('http+unix://%2Ftmp%2Fhs161b1acd%2Fdn_1.sock/datasets/d-2f22962d-e0592840-e15c-625d94-9e4cbf') sn INFO> Initiating UnixConnector with path: /tmp/hs161b1acd/dn_1.sock sn INFO> Socket Ready: /tmp/hs161b1acd/dn_1.sock sn INFO> http_get status: 500 for req: http://127.0.0.1/datasets/d-2f22962d-e0592840-e15c-625d94-9e4cbf sn ERROR> request to http://127.0.0.1/datasets/d-2f22962d-e0592840-e15c-625d94-9e4cbf failed with code: 500 INFO: hsds app stop at 1661538878.1163843 INFO: sending SIGINT to hsds-servicenode INFO: sending SIGINT to hsds-rangeget INFO: sending SIGINT to hsds-datanode --- [Visit Topic](https://forum.hdfgroup.org/t/how-to-issue-requests-to-hsds-lambda/10136/3) or reply to this email to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://forum.hdfgroup.org/email/unsubscribe/fd910026a0d68dcad1edb5303439954b736348d7f07fb236f8e565aa97df6da4).
[HDF Forum] [HSDS] How to issue requests to HSDS Lambda?
Hi, thanks for trying out HSDS lambda functions! For the lambda event, you'll need to provide a JSON that will tell the code how to fetch the data. The structure is basically what's documented here: https://github.com/HDFGroup/hdf-rest-api wrapped up in a json with keys: "method", "path", and "params". (the example in the docs are using an out-dated format that had "request" instead of "path"). method will be: "GET", "POST", "PUT", or "DELETE". (the standard http actions) path: is just the http path (i.e. the part after the service endpoint) params: are the query parameters for the request Also you can have a "body" key (for POST requests), and a "headers" key for any http headers (typically you don't need this). In the AWS Management Console for Lambda, it's convenient to setup some test events like this one: { "method": "GET", "path": "/datasets/d-d29fda32-85f3-11e7-bf89-0242ac110008/value", "params": { "domain": "/nrel/wtk-us.h5", "select": "[:5000,620,1401]", "bucket": "nrel-pds-hsds" } } With these you should get an output equivalent to the following h5pyd code: f = h5pyd.File("/nrel/wtk-us.h5", bucket="nrel-pds-hsds") dset = f["windspeed_80m"] data = dset[0:100,620,1401] print(data) Let me know if that works for you. In your example, I'm guessing that lambda code isn't able to find any relevant data. It should return a 404 (not found) or 403 (unauthorized), but instead is just returning the /about response. I'll look into this. --- [Visit Topic](https://forum.hdfgroup.org/t/how-to-issue-requests-to-hsds-lambda/10136/2) or reply to this email to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://forum.hdfgroup.org/email/unsubscribe/dd194c36a6dfcf257ddc2da3d52c80ec888ac7f6925da1e37512fc27941dada5).
[HDF Forum] [HSDS] How to issue requests to HSDS Lambda?
I successfully deployed the HSDS lambda function but have no idea about how to request it. I used the following example in Lambda test page. But it still returned the test response (e.g. welcome to hsds). { "method": "GET", "request": "/datasets/test/value", "params": { "domain": "/home/admin/test.h5", "select": "[0:100,620,1401]", "bucket": "test-bucket" } } --- [Visit Topic](https://forum.hdfgroup.org/t/how-to-issue-requests-to-hsds-lambda/10136/1) or reply to this email to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://forum.hdfgroup.org/email/unsubscribe/988a279c22d20f6c7a690c72b1e56f346edb74b43613fbc6a15d7697e897a343).