furiosa.common package

Subpackages

Submodules

furiosa.common.error module

exception furiosa.common.error.FuriosaError(message: str)

Bases: Exception

General exception caused by Furiosa Runtime

furiosa.common.error.is_err(err: c_int | int) bool
furiosa.common.error.is_ok(err: c_int | int) bool

furiosa.common.native module

class furiosa.common.native.LogLevel(value)

Bases: IntEnum

Python object correspondnig to nux_log_level_t in Nux C API

ERROR = 1
INFO = 3
OFF = 0
WARN = 2
furiosa.common.native.find_global_lib_path(libname: str)
furiosa.common.native.find_native_lib_path(libname: str) str | None

Finding a native library path according to the following priority 1. If the environment variable ‘LD_LIBRARY_PATH’ is set, this function tries to find native library found from LD_LIBRARY_PATH. 2. Otherwise, it tries find the native library from global library paths, such as /usr/lib, /usr/local/lib. 3. If the library still cannot be founded, it returns None.

furiosa.common.native.find_native_libs(libname: str, register_hook: ~typing.Callable = <function __register_common_capis>)

Finding a native library c interface according to the following priority 1. If the environment variable ‘LD_LIBRARY_PATH’ is set, this function tries to find native library found from LD_LIBRARY_PATH. 2. Otherwise, it tries to find the native library embedded in the python package. 3. If the embedded native library cannot be found, it tries find the native library from global library paths, such as /usr/lib, /usr/local/lib.

After loading C Library, it will call register_hook(ciface).

furiosa.common.native.find_user_lib_path(libname: str)

furiosa.common.thread module

furiosa.common.thread.asynchronous(f: Callable) Callable

Replace sync function to async using aysncio thread pool

furiosa.common.thread.synchronous(f: Callable) Callable

Run async function in place and return the result

furiosa.common.utils module

class furiosa.common.utils.FuriosaVersionInfo(version: Version)

Bases: object

furiosa.common.utils.eprint(*args, **kwargs)
furiosa.common.utils.get_sdk_version(module) FuriosaVersionInfo | None

Returns the git commit hash representing the current version of the application.

furiosa.common.utils.removeprefix(word: str, prefix: str) str

Python 3.9 removeprefix().

See https://docs.python.org/3/library/stdtypes.html#str.removeprefix

Module contents

Furiosa SDK common utilities

furiosa.common.get_sdk_version(module) FuriosaVersionInfo | None

Returns the git commit hash representing the current version of the application.