Skip to content

Commit 78460f6

Browse files
committed
Add a console message for set environment variables
Signed-off-by: Samuel Monson <[email protected]>
1 parent 06f2bd3 commit 78460f6

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/guidellm/__main__.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,16 @@ def run(**kwargs):
416416
disable_console_interactive = (
417417
kwargs.pop("disable_console_interactive", False) or disable_console
418418
)
419+
console = Console() if not disable_console else None
420+
envs = cli_tools.list_set_env()
421+
if console and envs:
422+
console.print_update(
423+
title=(
424+
"Note: the following environment variables **may** affect configuration"
425+
),
426+
details=", ".join(envs),
427+
status="warning",
428+
)
419429

420430
try:
421431
args = BenchmarkGenerativeTextArgs.create(
@@ -439,7 +449,7 @@ def run(**kwargs):
439449
if not disable_console_interactive
440450
else None
441451
),
442-
console=Console() if not disable_console else None,
452+
console=console,
443453
)
444454
)
445455

src/guidellm/utils/cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,31 @@
11
import contextlib
22
import json
3+
import os
34
from typing import Any
45

56
import click
67

78
__all__ = [
89
"Union",
910
"format_list_arg",
11+
"list_set_env",
1012
"parse_json",
1113
"parse_list",
1214
"parse_list_floats",
1315
"set_if_not_default",
1416
]
1517

1618

19+
def list_set_env(prefix: str = "GUIDELLM_") -> list[str]:
20+
"""
21+
List all set environment variables prefixed with the given prefix.
22+
23+
:param prefix: The prefix to filter environment variables.
24+
:return: List of environment variable names that are set with the given prefix.
25+
"""
26+
return [key for key in os.environ if key.startswith(prefix)]
27+
28+
1729
def parse_list(ctx, param, value) -> list[str] | None:
1830
"""
1931
Click callback to parse the input value into a list of strings.

0 commit comments

Comments
 (0)