Skip to content

Commit b1af9bc

Browse files
committed
modularize dataset creation args processing
1 parent ef746d0 commit b1af9bc

File tree

9 files changed

+1569
-1210
lines changed

9 files changed

+1569
-1210
lines changed

hsds/dset_sn.py

Lines changed: 111 additions & 625 deletions
Large diffs are not rendered by default.

hsds/post_crawl.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ async def create(self, index):
149149
kwargs["obj_id"] = item["obj_id"]
150150
if "type" in item:
151151
kwargs["type"] = item["type"]
152+
if "shape" in item:
153+
kwargs["shape"] = item["shape"]
152154
if "layout" in item:
153155
kwargs["layout"] = item["layout"]
154156
if "creation_props" in item:
@@ -231,7 +233,7 @@ async def createGroups(app, items: list, root_id=None, bucket=None):
231233

232234

233235
async def createDatatypeObjs(app, items: list, root_id=None, bucket=None):
234-
""" create an datatype objects based on parameters in items list """
236+
""" create datatype objects based on parameters in items list """
235237

236238
if not root_id:
237239
msg = "no root_id given for createDatatypeObjs"
@@ -256,3 +258,30 @@ async def createDatatypeObjs(app, items: list, root_id=None, bucket=None):
256258

257259
rsp_json = await _createObjects(app, items=items, root_id=root_id, bucket=bucket)
258260
return rsp_json
261+
262+
async def createDatasets(app, items: list, root_id=None, bucket=None):
263+
""" create dataset objects based on parameters in items list """
264+
265+
if not root_id:
266+
msg = "no root_id given for createDatatypeObjs"
267+
log.warn(msg)
268+
raise HTTPBadRequest(reason=msg)
269+
270+
for item in items:
271+
if not isinstance(item, dict):
272+
msg = "expected list of dictionary objects for multi-object create"
273+
log.warn(msg)
274+
raise HTTPBadRequest(reason=msg)
275+
if "type" not in item:
276+
msg = "type key not provided for multi-dataset create"
277+
log.warn(msg)
278+
raise HTTPBadRequest(reason=msg)
279+
if "shape" not in item:
280+
msg = "shape key not provided for multi-dataset create"
281+
log.warn(msg)
282+
raise HTTPBadRequest(reason=msg)
283+
284+
log.info(f"createDatasets with {len(items)} items, root_id: {root_id}")
285+
286+
rsp_json = await _createObjects(app, items=items, root_id=root_id, bucket=bucket)
287+
return rsp_json

0 commit comments

Comments
 (0)