Skip to content
heliaEDGE
Reference
HELIA

env

This module provides utility functions to interact with the environment.

Functions

Name Description
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

Machine-readable model

  • setup_loggerfunctionSetup logger with Rich
  • env_flagfunctionReturn the specified environment variable coerced to a bool, as follows: - When the variable is unset, or set to the empty string, return default.
  • silence_tensorflowfunctionSilence every unnecessary warning from tensorflow.
  • disable_tensorflow_gpufunctionDisable TensorFlow GPU
  • suppress_os_stdiofunctionRedirects the OS stdout (fd=1) and stderr (fd=2) to /dev/null, then restores them on exit.
function

Setup logger with Rich

helia_edge/utils/env.py:21

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 of setup_logger
NameTypeDefaultDescription
log_namestrRequiredLogger name
Returns of setup_logger
TypeDescription
logging.Loggerlogging.Logger: Logger
function

env_flag

Python

Return the specified environment variable coerced to a bool, as follows: - When the variable is unset, or set to the empty string, return default.

helia_edge/utils/env.py:68

env_flag(env_var: str, default: bool = False) -> bool

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 of env_flag
NameTypeDefaultDescription
env_varstrRequiredEnvironment variable name
defaultboolFalseDefault value. Defaults to False.
Returns of env_flag
ValueTypeDescription
boolboolValue of environment variable
function

Redirects the OS stdout (fd=1) and stderr (fd=2) to /dev/null, then restores them on exit.

helia_edge/utils/env.py:123

suppress_os_stdio()

Redirects the OS stdout (fd=1) and stderr (fd=2) to /dev/null, then restores them on exit. Suppresses all output unless an exception is raised, in which case it will be logged.