Skip to content

Commit

Permalink
Shorten filename parsing
Browse files Browse the repository at this point in the history
Run pre-commit hooks
  • Loading branch information
dyastremsky committed Jul 29, 2024
1 parent 48b3328 commit 06a601c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ def __init__(self, config: ExporterConfig):
self._args = config.args

def export(self) -> None:
filename = str(self._args.profile_export_file)
if filename.endswith(".json"):
filename = filename[:-5]
filename += "_genai_perf.csv"
filename = (
self._output_dir / f"{self._args.profile_export_file.stem}_genai_perf.csv"
)
logger.info(f"Generating {filename}")

with open(filename, mode="w", newline="") as f:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@


import json
import os
from enum import Enum
from typing import Dict

Expand All @@ -50,10 +51,10 @@ def __init__(self, config: ExporterConfig):
self._merge_stats_and_args()

def export(self) -> None:
filename = str(self._args["profile_export_file"])
if filename.endswith(".json"):
filename = filename[:-5]
filename += "_genai_perf.json"
prefix = os.path.splitext(os.path.basename(self._args["profile_export_file"]))[
0
]
filename = self._output_dir / f"{prefix}_genai_perf.json"
logger.info(f"Generating {filename}")
with open(str(filename), "w") as f:
f.write(json.dumps(self._stats_and_args, indent=2))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def test_nonstreaming_llm_csv_output(
"""
artifacts_dir = "artifacts/model_name-openai-chat-concurrency1"

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable artifacts_dir is not used.
custom_filename = "custom_export.json"
expected_filename = f"{artifacts_dir}/custom_export_genai_perf.csv"
expected_filename = f"custom_export_genai_perf.csv"
argv = [
"genai-perf",
"profile",
Expand Down

0 comments on commit 06a601c

Please sign in to comment.