Skip to content

Commit

Permalink
fix failing test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
markurtz committed Aug 2, 2024
1 parent 8ba7a0f commit 7a4bb5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
25 changes: 13 additions & 12 deletions src/guidellm/core/serializable.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,22 @@ def save_file(
if isinstance(path, str):
path = Path(path)

if path.is_dir():
if path.suffix:
# is a file
ext = path.suffix[1:].upper()
if ext not in SerializableFileType.__members__:
raise ValueError(
f"Unsupported file extension: {ext}. "
f"Expected one of {', '.join(SerializableFileType.__members__)}) "
f"for {path}"
)
type_ = SerializableFileType[ext]
else:
# is a directory
file_name = f"{self.__class__.__name__.lower()}.{type_.value.lower()}"
path = path / file_name
elif path.is_file():
type_ = SerializableFileType(path.suffix[1:].upper())
else:
raise ValueError(f"Invalid path: {path}")

if type_.name not in SerializableFileType.__members__:
raise ValueError(
f"Unsupported file format: {type_} "
f"(expected 'yaml' or 'json') for {path}"
)

path.mkdir(parents=True, exist_ok=True)
path.parent.mkdir(parents=True, exist_ok=True)

with path.open("w") as file:
if type_ == SerializableFileType.YAML:
Expand Down
2 changes: 1 addition & 1 deletion src/guidellm/scheduler/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async def _run_async(self) -> TextGenerationBenchmark:

if (
self._max_requests is not None
and requests_counter >= self._max_requests
and requests_counter >= self._max_requests - 1
):
break

Expand Down

0 comments on commit 7a4bb5e

Please sign in to comment.