Skip to content

Commit a9e7804

Browse files
committed
mypy fixes
1 parent 35b96dc commit a9e7804

File tree

5 files changed

+12
-8
lines changed

5 files changed

+12
-8
lines changed

examples/api/basic_usage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
# Get metrics
3434
print("\nRetrieving metrics...")
3535
metrics = client.get_metrics(job_id)
36-
if metrics.metrics:
36+
if isinstance(metrics.metrics, dict):
3737
for key, value in metrics.metrics.items():
3838
print(f"- {key}: {value}")
3939

vec_inf/cli/_cli.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from rich.console import Console
88
from rich.live import Live
99

10-
import vec_inf.client._utils as utils
1110
from vec_inf.cli._helper import (
1211
LaunchResponseFormatter,
1312
ListCmdDisplay,
@@ -129,7 +128,7 @@ def cli() -> None:
129128
)
130129
def launch(
131130
model_name: str,
132-
**cli_kwargs: Optional[Union[str, int, bool]],
131+
**cli_kwargs: Optional[Union[str, int, float, bool]],
133132
) -> None:
134133
"""Launch a model on the cluster."""
135134
try:
@@ -194,8 +193,12 @@ def status(
194193
@click.argument("slurm_job_id", type=int, nargs=1)
195194
def shutdown(slurm_job_id: int) -> None:
196195
"""Shutdown a running model on the cluster."""
197-
utils.shutdown_model(slurm_job_id)
198-
click.echo(f"Shutting down model with Slurm Job ID: {slurm_job_id}")
196+
try:
197+
client = VecInfClient()
198+
client.shutdown_model(slurm_job_id)
199+
click.echo(f"Shutting down model with Slurm Job ID: {slurm_job_id}")
200+
except Exception as e:
201+
raise click.ClickException(f"Shutdown failed: {str(e)}") from e
199202

200203

201204
@cli.command("list")

vec_inf/cli/_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def output_table(self) -> Table:
105105
class MetricsResponseFormatter:
106106
"""CLI Helper class for formatting MetricsResponse."""
107107

108-
def __init__(self, metrics: dict[str, float]):
108+
def __init__(self, metrics: Union[dict[str, float], str]):
109109
self.metrics = metrics
110110
self.table = utils.create_table("Metric", "Value")
111111
self.enabled_prefix_caching = self._check_prefix_caching()

vec_inf/client/_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ def _process_running_state(self) -> None:
294294
if server_status == "RUNNING":
295295
self._check_model_health()
296296
else:
297-
self.status_info.server_status = server_status
297+
self.status_info.server_status = cast(ModelStatus, server_status)
298298

299299
def _process_pending_state(self) -> None:
300300
"""Process PENDING job state."""

vec_inf/client/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""
66

77
import time
8-
from typing import Any, Optional
8+
from typing import Any, Optional, Union
99

1010
from vec_inf.client._config import ModelConfig
1111
from vec_inf.client._exceptions import (
@@ -147,6 +147,7 @@ def get_metrics(
147147
slurm_job_id, log_dir
148148
)
149149

150+
metrics: Union[str, dict[str, float]] = None
150151
if not performance_metrics_collector.metrics_url.startswith("http"):
151152
metrics = performance_metrics_collector.metrics_url
152153
else:

0 commit comments

Comments
 (0)