How to use the redisai.utils function in redisai

To help you get started, we’ve selected a few redisai 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 RedisAI / redisai-py / redisai / client.py View on Github external
meta_only : bool
            If True, only the meta data will be fetched, not the script itself

        Returns
        -------
        dict
            Dictionary of script details which includes the script at the key ``source``

        Example
        -------
        >>> con.scriptget('ket', meta_only=True)
        {'device': 'cpu'}
        """
        args = builder.scriptget(key, meta_only)
        ret = self.execute_command(*args)
        return utils.list2dict(ret)
github RedisAI / redisai-py / redisai / postprocessor.py View on Github external
def modelget(res):
        resdict = utils.list2dict(res)
        utils.recursive_bytetransform(resdict['inputs'], lambda x: x.decode())
        utils.recursive_bytetransform(resdict['outputs'], lambda x: x.decode())
        return resdict
github RedisAI / redisai-py / redisai / client.py View on Github external
currently experimental and might remove or change in the future without warning

        Returns
        -------
        List[List[AnyStr]]
            List of list of scripts and tags for each script if they existed

        Example
        -------
        >>> con.scriptscan()
        [['ket1', 'v1.0'], ['ket2', '']]
        """
        warnings.warn("Experimental: Script List API is experimental and might change "
                      "in the future without any notice", UserWarning)
        args = builder.scriptscan()
        return utils.recursive_bytetransform(self.execute_command(*args), lambda x: x.decode())
github RedisAI / redisai-py / redisai / postprocessor.py View on Github external
def modelscan(res):
        return utils.recursive_bytetransform(res, lambda x: x.decode())
github RedisAI / redisai-py / redisai / command_builder.py View on Github external
def scriptset(name: AnyStr, device: str, script: str, tag: AnyStr = None) -> Sequence:
    if device.upper() not in utils.allowed_devices:
        raise ValueError(f"Device not allowed. Use any from {utils.allowed_devices}")
    args = ['AI.SCRIPTSET', name, device]
    if tag:
        args += ['TAG', tag]
    args.append("SOURCE")
    args.append(script)
    return args
github RedisAI / redisai-py / redisai / command_builder.py View on Github external
def modelset(name: AnyStr, backend: str, device: str, data: ByteString,
             batch: int, minbatch: int, tag: AnyStr,
             inputs: Union[AnyStr, List[AnyStr]],
             outputs: Union[AnyStr, List[AnyStr]]) -> Sequence:
    if device.upper() not in utils.allowed_devices:
        raise ValueError(f"Device not allowed. Use any from {utils.allowed_devices}")
    if backend.upper() not in utils.allowed_backends:
        raise ValueError(f"Backend not allowed. Use any from {utils.allowed_backends}")
    args = ['AI.MODELSET', name, backend, device]

    if batch is not None:
        args += ['BATCHSIZE', batch]
    if minbatch is not None:
        args += ['MINBATCHSIZE', minbatch]
    if tag is not None:
        args += ['TAG', tag]

    if backend.upper() == 'TF':
        if not(all((inputs, outputs))):
            raise ValueError(
                'Require keyword arguments input and output for TF models')
github RedisAI / redisai-py / redisai / client.py View on Github external
def tensorget(self,
                  key: AnyStr, as_numpy: bool = True,
                  meta_only: bool = False) -> Any:
        args = builder.tensorget(key, as_numpy, meta_only)
        self.commands.extend(args)
        self.commands.append("|>")
        self.result_processors.append(partial(utils.tensorget_postprocessor,
                                              as_numpy,
                                              meta_only))
        return self