# helia_edge.utils.env

## Environment Utility API

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 |

## helia_edge.utils.env.setup_logger

`function` · `python`

```python
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**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| log_name | str | Required | Logger name |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
|  | logging.Logger | logging.Logger: Logger |

Source: `helia_edge/utils/env.py:21`

## helia_edge.utils.env.env_flag

`function` · `python`

```python
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**

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| env_var | str | Required | Environment variable name |
| default | bool | False | Default value. Defaults to False. |

**Returns**

| Name | Type | Description |
| --- | --- | --- |
| bool | bool | Value of environment variable |

Source: `helia_edge/utils/env.py:68`

## helia_edge.utils.env.silence_tensorflow

`function` · `python`

```python
silence_tensorflow()
```

Silence every unnecessary warning from tensorflow.

Source: `helia_edge/utils/env.py:94`

## helia_edge.utils.env.disable_tensorflow_gpu

`function` · `python`

```python
disable_tensorflow_gpu()
```

Disable TensorFlow GPU

Source: `helia_edge/utils/env.py:115`

## helia_edge.utils.env.suppress_os_stdio

`function` · `python`

```python
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.

:::note[Example]
with suppress_os_stdio():
    noisy_function()

:::

Source: `helia_edge/utils/env.py:123`
