Skip to content

Commit

Permalink
missing server_metrics in metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Bslabe123 committed Nov 12, 2024
1 parent 2aa34bf commit b02e109
Showing 1 changed file with 16 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,15 @@ class BenchmarkConfig(TypedDict):

class MetricSummary(TypedDict, total=False):
json_field_name: Optional[str]
name: str
description: str
mean: float
median: Optional[float]
sd: Optional[float]
min: Optional[float]
max: Optional[float]
p90: Optional[float]
p99: Optional[float]
name: str
description: str
mean: float
median: Optional[float]
sd: Optional[float]
min: Optional[float]
max: Optional[float]
p90: Optional[float]
p99: Optional[float]

class BenchmarkingStepReport(TypedDict):
"""Result for one step"""
Expand Down Expand Up @@ -621,6 +621,7 @@ def to_text_reports(self, write_to_files: bool = False) -> List[str]:

# The output is a a single json summary of all steps
def to_json_report(self, write_to_file: bool = False) -> Dict:
print(self.steps[0]["local_metrics"])
output = {
"config": {
**self.config,
Expand All @@ -634,7 +635,7 @@ def to_json_report(self, write_to_file: bool = False) -> Dict:
"stats": [
{
"request_rate": step["request_rate"],
**{metric["json_field_name"]: metric for metric in step["local_metrics"] if "json_field_name" in metric},
**{(metric["json_field_name"] if "json_field_name" in metric else metric["name"]): metric for metric in step["local_metrics"]},
"model_server_metrics": [
{"name": server_metric["name"], **server_metric}
for server_metric in step["server_metrics"]
Expand All @@ -657,14 +658,17 @@ def to_json_report(self, write_to_file: bool = False) -> Dict:
"num_prompts_attempted": self.steps[0]['num_prompts_attempted'],
"num_prompts_succeeded": len(self.steps[0]['latencies']),
"request_rate": self.steps[0]['request_rate'],

**{
f"{stat}_{metric['name']}": value
for metric in self.steps[0]["local_metrics"]
if "json_field_name" in metric
for stat, value in metric.items()
if stat not in ["name", "description", "json_field_name"] and value is not None
}
},
"server_metrics": [
{"name": server_metric["name"], **server_metric}
for server_metric in step["server_metrics"]
] if self.steps[0]["server_metrics"] is not None else []
} if len(self.steps) == 1 else None
}

Expand Down

0 comments on commit b02e109

Please sign in to comment.