Skip to content

Commit 61c58ec

Browse files
[GuideLLM Refactor] Complete CSV output (#378)
## Summary This PR gets the CSV output to a state comparable to pre-refactor. ## Details Implements the functions to export the required data to the CSV format. The goal is to include the required information in the CSV without cluttering it, but also without creating too much of a burden to the future maintainers resulting from referencing specific schema elements. The following columns are new: - Profile (an entire JSON dump of the profile) - Backend (the entire JSON dump of the internal data structure) - Generator Data You can view these files in the attached output generated by the following test: `guidellm benchmark run --output-path result_7.csv --max-seconds 2 --target=http://localhost:8000 --data "prompt_tokens=256,output_tokens=128" --rate-type constant --rate 1 --output-formats csv` [result_7.csv](https://github.com/user-attachments/files/22222220/result_7.csv) ## Test Plan Run GuideLLM with the following additional args: `--output-path result.csv --output-formats csv` The generated file should have all info required. ## Related Issues This is a part of the scheduler refactor. --- - [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 46b5e87 + 80df98b commit 61c58ec

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

src/guidellm/benchmark/output.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,13 @@ async def finalize(self, report: GenerativeBenchmarksReport) -> Path:
567567
benchmark_headers: list[str] = []
568568
benchmark_values: list[str | float | list[float]] = []
569569

570+
# Add basic run description info
571+
desc_headers, desc_values = (
572+
self._get_benchmark_desc_headers_and_values(benchmark)
573+
)
574+
benchmark_headers.extend(desc_headers)
575+
benchmark_values.extend(desc_values)
576+
570577
# Add status-based metrics
571578
for status in StatusDistributionSummary.model_fields:
572579
status_headers, status_values = (
@@ -672,6 +679,21 @@ def _get_benchmark_status_metrics_stats(
672679
]
673680
return headers, values
674681

682+
def _get_benchmark_extras_headers_and_values(
683+
self, benchmark: GenerativeBenchmark,
684+
) -> tuple[list[str], list[str]]:
685+
headers = ["Profile", "Backend", "Generator Data"]
686+
values: list[str] = [
687+
benchmark.benchmarker.profile.model_dump_json(),
688+
json.dumps(benchmark.benchmarker.backend),
689+
json.dumps(benchmark.benchmarker.requests["attributes"]["data"]),
690+
]
691+
692+
if len(headers) != len(values):
693+
raise ValueError("Headers and values length mismatch.")
694+
695+
return headers, values
696+
675697

676698
@GenerativeBenchmarkerOutput.register("html")
677699
class GenerativeBenchmarkerHTML(GenerativeBenchmarkerOutput):

tests/unit/benchmark/test_output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ def test_file_yaml():
8080

8181
mock_path.unlink()
8282

83-
@pytest.mark.skip(reason="CSV fix not merged yet")
8483
@pytest.mark.asyncio
8584
async def test_file_csv():
8685
mock_benchmark = mock_generative_benchmark()
@@ -96,6 +95,7 @@ async def test_file_csv():
9695
rows = list(reader)
9796

9897
assert "Type" in headers
98+
assert "Profile" in headers
9999
assert len(rows) == 1
100100

101101
mock_path.unlink()

tests/unit/mock_benchmark.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ def mock_generative_benchmark() -> GenerativeBenchmark:
7676
),
7777
benchmarker=BenchmarkerDict(
7878
profile=SynchronousProfile.create("synchronous", rate=None),
79-
requests={},
79+
requests={
80+
"attributes": {
81+
"data": "prompt_tokens=256,output_tokens=128",
82+
},
83+
},
8084
backend={},
8185
environment={},
8286
aggregators={},

0 commit comments

Comments
 (0)