Skip to content

Commit 23ee5b6

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

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/guidellm/__main__.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,17 @@ 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 "
425+
"are set and **may** affect configuration"
426+
),
427+
details=", ".join(envs),
428+
status="warning",
429+
)
419430

420431
try:
421432
args = BenchmarkGenerativeTextArgs.create(
@@ -439,7 +450,7 @@ def run(**kwargs):
439450
if not disable_console_interactive
440451
else None
441452
),
442-
console=Console() if not disable_console else None,
453+
console=console,
443454
)
444455
)
445456

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)