env
Environment Utility API
This module provides utility functions to interact with the environment.
Functions:
-
setup_logger
–Setup logger with Rich
-
env_flag
–Return the specified environment variable coerced to a bool
-
silence_tensorflow
–Silence every unnecessary warning from tensorflow
-
disable_tensorflow_gpu
–Disable TensorFlow GPU
Functions
setup_logger
setup_logger(log_name: str, level: int | None = None, recursive: bool = True, file_path: os.PathLike | None = None) -> logging.Logger
Setup logger with Rich
Parameters:
-
log_name
(str
) –Logger name
Returns:
-
Logger
–logging.Logger: Logger
Source code in neuralspot_edge/utils/env.py
env_flag
Return the specified environment variable coerced to a bool, as follows:
- When the variable is unset, or set to the empty string, return default
.
- When the variable is set to a truthy value, returns True
.
These are the truthy values:
- 1
- true, yes, on
- When the variable is set to the anything else, returns False.
Example falsy values:
- 0
- no
- Ignore case and leading/trailing whitespace.
Parameters:
-
env_var
(str
) –Environment variable name
-
default
(bool
, default:False
) –Default value. Defaults to False.
Returns:
-
bool
(bool
) –Value of environment variable
Source code in neuralspot_edge/utils/env.py
silence_tensorflow
Silence every unnecessary warning from tensorflow.