How to use the h5pyd._hl.objectid.DatasetID function in h5pyd

To help you get started, we’ve selected a few h5pyd examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github HDFGroup / h5pyd / h5pyd / _hl / dims.py View on Github external
if not ref_id:
                    continue
                if not ref_id.startswith("datasets/"):
                    msg = "unexpected ref_id: {}".format(ref_id)
                    raise IOError(msg)
                    continue
                dset_id =  ref_id[len("datasets/"):]
                attr_json = self._getAttributeJson('NAME', objid=dset_id)
                if attr_json["value"] == item:
                    # found it!
                    dset_scale_id = dset_id
                    break
        if not dset_scale_id:
            raise KeyError('No dimension scale with name"{}" found'.format(item))
        dscale_json = self._getDatasetJson(dset_scale_id)
        dscale = Dataset(DatasetID(parent=None, item=dscale_json, http_conn=self._id.http_conn))
        return dscale
github HDFGroup / h5pyd / h5pyd / _hl / group.py View on Github external
else:
                # will need to get JSON from server
                req = "/" + collection_type + "/" + uuid
                # make server request
                obj_json = self.GET(req)

            if collection_type == 'groups':
                tgt = Group(GroupID(self, obj_json))
            elif collection_type == 'datatypes':
                tgt = Datatype(TypeID(self, obj_json))
            elif collection_type == 'datasets':
                # create a Table if the daset is one dimensional and compound
                shape_json = obj_json["shape"]
                dtype_json = obj_json["type"]
                if "dims" in shape_json and len(shape_json["dims"]) == 1 and dtype_json["class"] == 'H5T_COMPOUND':
                    tgt = Table(DatasetID(self, obj_json))
                else:
                    tgt = Dataset(DatasetID(self, obj_json))
            else:
                raise IOError("Unexpecrted collection_type: {}".format(collection_type))

            return tgt
github HDFGroup / h5pyd / h5pyd / _hl / dataset.py View on Github external
json_rep['id'] = rsp['id']

    req = '/datasets/' + rsp['id']
    rsp = parent.GET(req)

    json_rep['shape'] = rsp['shape']
    json_rep['type'] = rsp['type']
    json_rep['lastModified'] = rsp['lastModified']
    if 'creationProperties' in rsp:
        json_rep['creationProperties'] = rsp['creationProperties']
    else:
        json_rep['creationProperties'] = {}
    if "layout" in rsp:
        json_rep['layout'] = rsp['layout']

    dset_id = DatasetID(parent, json_rep)

    return dset_id
github HDFGroup / h5pyd / h5pyd / _hl / attrs.py View on Github external
def __init__(self, parent):
        """ Private constructor.
        """
        self._parent = parent

        if isinstance(parent.id, GroupID):
            self._req_prefix = "/groups/" + parent.id.uuid + "/attributes/"
        elif isinstance(parent.id, TypeID):
            self._req_prefix = "/datatypes/" + parent.id.uuid + "/attributes/"
        elif isinstance(parent.id, DatasetID):
            self._req_prefix = "/datasets/" + parent.id.uuid + "/attributes/"
        else:
            # "unknown id"
            self._req_prefix = ""
        objdb = self._parent.id.http_conn.getObjDb()
        if objdb:
            # _objdb is meta-data pulled from the domain on open.
            # see if we can extract the link json from there
            objid = self._parent.id.uuid
            if objid not in objdb:
                raise IOError("Expected to find {} in objdb".format(objid))
            obj_json = objdb[objid]
            self._objdb_attributes = obj_json["attributes"]
        else:
            self._objdb_attributes = None
github HDFGroup / h5pyd / h5pyd / _hl / dataset.py View on Github external
def __init__(self, bind):
        """ Create a new Dataset object by binding to a low-level DatasetID.
        """

        if not isinstance(bind, DatasetID):
            raise ValueError("%s is not a DatasetID" % bind)
        HLObject.__init__(self, bind)

        self._dcpl = self.id.dcpl_json
        self._filters = filters.get_filters(self._dcpl)

        self._local = None  # local()

        # make a numpy dtype out of the type json
        self._dtype = createDataType(self.id.type_json)
        self._item_size = getItemSize(self.id.type_json)

        self._shape = self.get_shape()

        self._num_chunks = None  # aditional state we'll get when requested
        self._allocated_size = None # as above
github HDFGroup / h5pyd / h5pyd / _hl / group.py View on Github external
req = "/" + collection_type + "/" + uuid
                # make server request
                obj_json = self.GET(req)

            if collection_type == 'groups':
                tgt = Group(GroupID(self, obj_json))
            elif collection_type == 'datatypes':
                tgt = Datatype(TypeID(self, obj_json))
            elif collection_type == 'datasets':
                # create a Table if the daset is one dimensional and compound
                shape_json = obj_json["shape"]
                dtype_json = obj_json["type"]
                if "dims" in shape_json and len(shape_json["dims"]) == 1 and dtype_json["class"] == 'H5T_COMPOUND':
                    tgt = Table(DatasetID(self, obj_json))
                else:
                    tgt = Dataset(DatasetID(self, obj_json))
            else:
                raise IOError("Unexpecrted collection_type: {}".format(collection_type))

            return tgt