Skip to content

Commit 3abb712

Browse files
authored
Fix container overriding output-dir/outputs (#486)
## Summary <!-- Include a short paragraph of the changes introduced in this PR. If this PR requires additional context or rationale, explain why the changes are necessary. --> Ensure we are setting `GUIDELLM_OUTPUT_DIR` rather than `GUIDELLM_OUTPUT_PATH` in the container to allow `--output-dir` and `--outputs` to function. Additionally add a warning when environment variable are set. ## Details <!-- Provide a detailed list of all changes introduced in this pull request. --> The container image sets `GUIDELLM_OUTPUT_PATH=/results`. Due to the way output-path interacts with the new output-dir and outputs options, output-path overrules their settings. ## Test Plan <!-- List the steps needed to test this PR. --> - Run container with `--output-dir /test/path --outputs test.json,test.csv` ## Related Issues <!-- Link any relevant issues that this PR addresses. --> - Resolves # --- - [x] "I certify that all code in this PR is my own, except as noted below." ## Use of AI - [ ] Includes AI-assisted code completion - [ ] Includes code generated by an AI application - [ ] Includes AI-generated tests (NOTE: AI written tests should have a docstring that includes `## WRITTEN BY AI ##`)
2 parents fce8858 + 9f39a2f commit 3abb712

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

Containerfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# TODO: Update to official python-3.13-minimal image when available
21
ARG BASE_IMAGE=quay.io/fedora/python-313-minimal:latest
32

43
# Use a multi-stage build to create a lightweight production image
@@ -51,7 +50,7 @@ USER 1001:0
5150
# Add guidellm bin to PATH
5251
# Argument defaults can be set with GUIDELLM_<ARG>
5352
ENV HOME="/home/guidellm" \
54-
GUIDELLM_OUTPUT_PATH="/results/benchmarks.json"
53+
GUIDELLM_OUTPUT_DIR="/results"
5554

5655
# Create the user home dir
5756
WORKDIR $HOME

src/guidellm/__main__.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,8 @@ def run(**kwargs):
402402

403403
# Handle output path remapping
404404
if (output_path := kwargs.pop("output_path", None)) is not None:
405+
if kwargs.get("outputs_dir", None) is not None:
406+
raise click.BadParameter("Cannot use --output-path with --output-dir.")
405407
path = Path(output_path)
406408
if path.is_dir():
407409
kwargs["output_dir"] = path
@@ -414,6 +416,17 @@ def run(**kwargs):
414416
disable_console_interactive = (
415417
kwargs.pop("disable_console_interactive", False) or disable_console
416418
)
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+
)
417430

418431
try:
419432
args = BenchmarkGenerativeTextArgs.create(
@@ -437,7 +450,7 @@ def run(**kwargs):
437450
if not disable_console_interactive
438451
else None
439452
),
440-
console=Console() if not disable_console else None,
453+
console=console,
441454
)
442455
)
443456

@@ -523,8 +536,8 @@ def preprocess():
523536
"PreprocessDatasetConfig as JSON string, key=value pairs, "
524537
"or file path (.json, .yaml, .yml, .config). "
525538
"Example: 'prompt_tokens=100,output_tokens=50,prefix_tokens_max=10'"
526-
" or '{\"prompt_tokens\": 100, \"output_tokens\": 50, "
527-
"\"prefix_tokens_max\": 10}'"
539+
' or \'{"prompt_tokens": 100, "output_tokens": 50, '
540+
'"prefix_tokens_max": 10}\''
528541
),
529542
)
530543
@click.option(

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)