Skip to content

Commit 9e7b7ce

Browse files
Nick  VaccarelloNick  Vaccarello
authored andcommitted
chore(cli): add Rich progress UI to sanity suite; keep fast-fail and filters
1 parent 0885fb5 commit 9e7b7ce

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

medical_diagnosis_model/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ uvicorn>=0.30.0
1818
pytest>=7.4.0
1919
requests>=2.31.0
2020
PyJWT[crypto]>=2.8.0
21+
rich>=13.7.0
2122

2223
# Optional: For advanced neural network features (future)
2324
# tensorflow>=2.12.0

medical_diagnosis_model/tools/sanity.py

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
from typing import Optional
3030

3131
import requests
32+
from rich.console import Console
33+
from rich.progress import Progress, SpinnerColumn, TextColumn
3234

3335

3436
ROOT = Path(__file__).resolve().parents[2] # repo root
@@ -215,6 +217,7 @@ def cmd_adaptive(args: argparse.Namespace) -> None:
215217

216218

217219
def cmd_suite(args: argparse.Namespace) -> None:
220+
console = Console()
218221
statuses = {
219222
"data": None,
220223
"tests": None,
@@ -231,18 +234,35 @@ def _safe(run_fn, key):
231234
except SystemExit:
232235
statuses[key] = False
233236

234-
# Always run data + tests
235-
_safe(cmd_data, "data")
236-
_safe(cmd_tests, "tests")
237-
# Optionally run API-related checks
237+
tasks = [
238+
("data", cmd_data),
239+
("tests", cmd_tests),
240+
]
238241
if args.with_api:
239-
_safe(cmd_api, "api")
242+
tasks.append(("api", cmd_api))
240243
if args.with_export:
241-
_safe(cmd_export, "export")
244+
tasks.append(("export", cmd_export))
242245
if args.with_rate:
243-
_safe(cmd_rate, "rate")
246+
tasks.append(("rate", cmd_rate))
244247
if args.with_adaptive:
245-
_safe(cmd_adaptive, "adaptive")
248+
tasks.append(("adaptive", cmd_adaptive))
249+
250+
with Progress(
251+
SpinnerColumn(),
252+
TextColumn("[bold blue]{task.description}"),
253+
TextColumn("[dim]{task.fields[status]}"),
254+
console=console,
255+
transient=False,
256+
) as progress:
257+
task_ids = {}
258+
for name, _ in tasks:
259+
task_ids[name] = progress.add_task(f"{name}", status="queued")
260+
for name, fn in tasks:
261+
progress.update(task_ids[name], status="running")
262+
_safe(fn, name)
263+
final = "ok" if statuses[name] else "fail"
264+
color = "green" if statuses[name] else "red"
265+
progress.update(task_ids[name], status=f"[{color}]{final}")
246266

247267
# Optional JSON report
248268
if getattr(args, "report_json", None):
@@ -260,7 +280,7 @@ def _safe(run_fn, key):
260280
out_path = Path(args.report_json)
261281
out_path.parent.mkdir(parents=True, exist_ok=True)
262282
out_path.write_text(json.dumps(report, indent=2), encoding="utf-8")
263-
print(f"Wrote sanity report to {out_path}")
283+
console.print(f"[dim]Wrote sanity report to {out_path}")
264284

265285
# Exit non-zero if any selected check failed
266286
failures = [k for k, v in statuses.items() if v is False]

0 commit comments

Comments
 (0)