env
env
Environment variable and .env file helpers.
Loading is always explicit: importing :mod:qrt.env does not modify the process environment. Runtime inspection helpers describe the operating system, storage, and compute accelerators available to qrt.
Classes
| Name | Description |
|---|---|
| AcceleratorInfo | A compute accelerator available to the installed PyTorch runtime. |
| DiskInfo | Filesystem capacity containing a requested path, in bytes. |
| EnvironmentInfo | Snapshot of the environment in which qrt is running. |
| EnvironmentRequirementError | Raised when the runtime does not satisfy environment requirements. |
| OSInfo | Operating-system details for the current runtime. |
AcceleratorInfo
env.AcceleratorInfo(index, backend, vendor, name, memory_total=None)A compute accelerator available to the installed PyTorch runtime.
DiskInfo
env.DiskInfo(path, total, used, free)Filesystem capacity containing a requested path, in bytes.
EnvironmentInfo
env.EnvironmentInfo(
operating_system,
disk,
accelerators,
device,
cpu_count=None,
)Snapshot of the environment in which qrt is running.
Methods
| Name | Description |
|---|---|
| as_dict | Return a JSON-serializable representation of the snapshot. |
as_dict
env.EnvironmentInfo.as_dict()Return a JSON-serializable representation of the snapshot.
EnvironmentRequirementError
env.EnvironmentRequirementError(failures)Raised when the runtime does not satisfy environment requirements.
OSInfo
env.OSInfo(name, release, version, machine)Operating-system details for the current runtime.
Functions
| Name | Description |
|---|---|
| accelerators | Return compute accelerators usable by the installed PyTorch runtime. |
| cpu_count | Return the number of logical CPUs available to the current process. |
| device | Return the preferred PyTorch device for the current environment. |
| disk | Return capacity for the filesystem containing path. |
| get | Return an environment variable, or default when it is unset. |
| info | Return a snapshot of qrt’s current runtime environment. |
| load | Load variables from a .env file into the process environment. |
| operating_system | Return details about the operating system running qrt. |
| report | Print a Rich environment summary and return its structured snapshot. |
| require | Require one variable or validate a runtime requirements file. |
| values | Read a .env file without modifying the process environment. |
accelerators
env.accelerators()Return compute accelerators usable by the installed PyTorch runtime.
PyTorch exposes AMD ROCm devices through its torch.cuda API, so torch.version.hip is used to distinguish AMD from NVIDIA devices.
cpu_count
env.cpu_count()Return the number of logical CPUs available to the current process.
device
env.device()Return the preferred PyTorch device for the current environment.
disk
env.disk(path='.')Return capacity for the filesystem containing path.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| path | str | Path | Path whose filesystem should be inspected. If it does not exist, its nearest existing parent is used to query filesystem capacity. | '.' |
get
env.get(name, default=None)Return an environment variable, or default when it is unset.
info
env.info(path='.')Return a snapshot of qrt’s current runtime environment.
load
env.load(path=None, *, override=False, **kwargs)Load variables from a .env file into the process environment.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| path | str | Path | None | File to load. If omitted, python-dotenv searches upward for a .env file. |
None |
| override | bool | Whether loaded values replace variables already present in the process environment. | False |
| **kwargs | Any | Additional options passed to :func:dotenv.load_dotenv. |
{} |
Returns
| Name | Type | Description |
|---|---|---|
| bool | True when at least one variable was loaded, otherwise False. |
operating_system
env.operating_system()Return details about the operating system running qrt.
report
env.report(path='.')Print a Rich environment summary and return its structured snapshot.
require
env.require(name)Require one variable or validate a runtime requirements file.
Dispatch is based on the argument:
- A string ending in
.ymlor.yamlvalidates that requirements file and returns an :class:EnvironmentInfosnapshot. - Any :class:
~pathlib.Pathvalidates that requirements file, regardless of its suffix. - Any other string is looked up in the process environment and its value is returned.
Raises
| Name | Type | Description |
|---|---|---|
| KeyError | If a requested variable is not set. | |
| ValueError | If a requirements file has an invalid schema. | |
| EnvironmentRequirementError | If runtime requirements are not met. |
values
env.values(path=None, **kwargs)Read a .env file without modifying the process environment.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| path | str | Path | None | File to read. If omitted, python-dotenv searches upward for a .env file. |
None |
| **kwargs | Any | Additional options passed to :func:dotenv.dotenv_values. |
{} |
Returns
| Name | Type | Description |
|---|---|---|
| dict[str, str | None] | Parsed variable names and values. |