Skip to content

Commit e8e54b8

Browse files
authored
Merge 53810a5 into 72374ef
2 parents 72374ef + 53810a5 commit e8e54b8

File tree

14 files changed

+130
-23
lines changed

14 files changed

+130
-23
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ dependencies = [
5353
"protobuf",
5454
"pydantic>=2.11.7",
5555
"pydantic-settings>=2.0.0",
56-
"pyhumps>=3.8.0",
5756
"pyyaml>=6.0.0",
5857
"rich",
5958
"transformers",

src/guidellm/benchmark/output.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from copy import deepcopy
12
import csv
23
import json
34
import math
@@ -6,7 +7,6 @@
67
from pathlib import Path
78
from typing import Any, Literal, Optional, Union
89

9-
import humps # type: ignore[import-not-found]
1010
import yaml
1111
from pydantic import Field
1212
from rich.console import Console
@@ -30,6 +30,8 @@
3030
from guidellm.presentation.injector import create_report
3131
from guidellm.scheduler import strategy_display_str
3232
from guidellm.utils import Colors, split_text_list_by_length
33+
from guidellm.utils.dict import recursive_key_update
34+
from guidellm.utils.text import camelize_str
3335

3436
__all__ = [
3537
"GenerativeBenchmarksConsole",
@@ -236,14 +238,14 @@ def save_html(self, path: Union[str, Path]) -> Path:
236238
:param path: The path to create the report at.
237239
:return: The path to the report.
238240
"""
239-
241+
240242
data_builder = UIDataBuilder(self.benchmarks)
241243
data = data_builder.to_dict()
242-
camel_data = humps.camelize(data)
244+
camel_data = recursive_key_update(deepcopy(data), camelize_str)
243245
ui_api_data = {}
244246
for k, v in camel_data.items():
245-
key = f"window.{humps.decamelize(k)} = {{}};"
246-
value = f"window.{humps.decamelize(k)} = {json.dumps(v, indent=2)};\n"
247+
key = f"window.{k} = {{}};"
248+
value = f"window.{k} = {json.dumps(v, indent=2)};\n"
247249
ui_api_data[key] = value
248250
return create_report(ui_api_data, path)
249251

src/guidellm/utils/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .colors import Colors
22
from .default_group import DefaultGroupHandler
3+
from .dict import recursive_key_update
34
from .hf_datasets import (
45
SUPPORTED_TYPES,
56
save_dataset_to_file,
@@ -10,6 +11,7 @@
1011
from .random import IntegerRangeSampler
1112
from .text import (
1213
EndlessTextCreator,
14+
camelize_str,
1315
clean_text,
1416
filter_text,
1517
is_puncutation,
@@ -24,11 +26,13 @@
2426
"DefaultGroupHandler",
2527
"EndlessTextCreator",
2628
"IntegerRangeSampler",
29+
"camelize_str",
2730
"check_load_processor",
2831
"clean_text",
2932
"filter_text",
3033
"is_puncutation",
3134
"load_text",
35+
"recursive_key_update",
3236
"save_dataset_to_file",
3337
"split_text",
3438
"split_text_list_by_length",

src/guidellm/utils/dict.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
def recursive_key_update(d, key_update_func):
2+
if not isinstance(d, dict) and not isinstance(d, list):
3+
return d
4+
5+
if isinstance(d, list):
6+
for item in d:
7+
recursive_key_update(item, key_update_func)
8+
return d
9+
10+
updated_key_pairs = []
11+
for key, _ in d.items():
12+
updated_key = key_update_func(key)
13+
if key != updated_key:
14+
updated_key_pairs.append((key, updated_key ))
15+
for key_pair in updated_key_pairs:
16+
old_key, updated_key = key_pair
17+
d[updated_key] = d[old_key]
18+
del d[old_key]
19+
for key, value in d.items():
20+
recursive_key_update(value, key_update_func)
21+
return d

src/guidellm/utils/text.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
__all__ = [
1616
"EndlessTextCreator",
17+
"camelize_str",
1718
"clean_text",
1819
"filter_text",
1920
"is_puncutation",
@@ -189,6 +190,10 @@ def is_puncutation(text: str) -> bool:
189190
return len(text) == 1 and not text.isalnum() and not text.isspace()
190191

191192

193+
def camelize_str(snake_case_string: str) -> str:
194+
return (words := snake_case_string.split('_'))[0].lower() + ''.join(word.capitalize() for word in words[1:])
195+
196+
192197
class EndlessTextCreator:
193198
def __init__(
194199
self,
@@ -213,4 +218,4 @@ def create_text(self, start: int, length: int) -> str:
213218

214219
text += add_word
215220

216-
return text
221+
return text

src/ui/app/layout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default function RootLayout({
3535
<script
3636
dangerouslySetInnerHTML={{
3737
__html:
38-
'window.run_info = {}; window.workload_details = {}; window.benchmarks = {};',
38+
'window.runInfo = {}; window.workloadDetails = {}; window.benchmarks = {};',
3939
}}
4040
/>
4141
);

src/ui/lib/store/runInfoWindowData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const runInfoScript = `window.run_info = {
1+
export const runInfoScript = `window.runInfo = {
22
"model": {
33
"name": "neuralmagic/Qwen2.5-7B-quantized.w8a8",
44
"size": 0

src/ui/lib/store/slices/runInfo/runInfo.api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RunInfo } from './runInfo.interfaces';
55
const USE_MOCK_API = process.env.NEXT_PUBLIC_USE_MOCK_API === 'true';
66

77
const fetchRunInfo = () => {
8-
return { data: window.run_info as RunInfo };
8+
return { data: window.runInfo as RunInfo };
99
};
1010

1111
export const runInfoApi = createApi({

src/ui/lib/store/slices/workloadDetails/workloadDetails.api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { WorkloadDetails } from './workloadDetails.interfaces';
55
const USE_MOCK_API = process.env.NEXT_PUBLIC_USE_MOCK_API === 'true';
66

77
const fetchWorkloadDetails = () => {
8-
return { data: window.workload_details as WorkloadDetails };
8+
return { data: window.workloadDetails as WorkloadDetails };
99
};
1010

1111
export const workloadDetailsApi = createApi({

src/ui/lib/store/workloadDetailsWindowData.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const workloadDetailsScript = `window.workload_details = {
1+
export const workloadDetailsScript = `window.workloadDetails = {
22
"prompts": {
33
"samples": [
44
"such a sacrifice to her advantage as years of gratitude cannot enough acknowledge. By this time she is actually with them! If such goodness does not make her miserable now, she will never deserve to be happy! What a meeting for her, when she first sees my aunt! We must endeavour to forget all that has passed on either side, said Jane I hope and trust they will yet be happy. His consenting to marry her is a proof, I will believe, that he is come to a right way of thinking. Their mutual affection will steady them; and I flatter myself they will settle so quietly, and live in so rational a manner",

0 commit comments

Comments
 (0)