Skip to content

Commit 3486e0d

Browse files
refactor: decouple Gradio input order from WebuiParams field order
1 parent cb1a63b commit 3486e0d

File tree

2 files changed

+4
-12
lines changed

2 files changed

+4
-12
lines changed

webui/app.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,9 @@ def toggle_partition_params(method):
608608
)
609609

610610
submit_btn.click(
611-
lambda *args: run_graphgen(WebuiParams.from_list(args)),
611+
lambda *args: run_graphgen(
612+
WebuiParams(**dict(zip(WebuiParams.__annotations__, args)))
613+
),
612614
inputs=[
613615
if_trainee_model,
614616
upload_file,

webui/base.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dataclasses import dataclass, fields
1+
from dataclasses import dataclass
22
from typing import Any
33

44

@@ -35,13 +35,3 @@ class WebuiParams:
3535
rpm: int
3636
tpm: int
3737
token_counter: Any
38-
39-
@classmethod
40-
def from_list(cls, args):
41-
"""
42-
args: a list/tuple of values corresponding to the fields in order.
43-
"""
44-
field_names = [f.name for f in fields(cls)]
45-
if len(args) != len(field_names):
46-
raise ValueError(f"Expected {len(field_names)} arguments, got {len(args)}")
47-
return cls(**dict(zip(field_names, args)))

0 commit comments

Comments
 (0)