@@ -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
233235async 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