mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-05-07 02:03:55 -05:00
Align the MLSys·im code, docs, paper, website, workflows, and lab wheel for the 0.1.1 release. This also fixes runtime/API issues found during release review and prepares the paper PDF plus archive package.
36 lines
927 B
Python
36 lines
927 B
Python
import json
|
|
from pathlib import Path
|
|
|
|
from typer.testing import CliRunner
|
|
|
|
from mlsysim.cli.main import app
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
runner = CliRunner()
|
|
|
|
|
|
def test_eval_json_sla_failure_is_single_json_object():
|
|
result = runner.invoke(
|
|
app,
|
|
["--output", "json", "eval", str(ROOT / "examples/yaml/test_assert_plan.yaml")],
|
|
)
|
|
|
|
assert result.exit_code == 3
|
|
payload = json.loads(result.stdout)
|
|
assert payload["status"] == "sla_failed"
|
|
assert payload["violations"]
|
|
assert "m_tco_usd" in payload
|
|
|
|
|
|
def test_optimize_parallelism_json_is_serializable():
|
|
result = runner.invoke(
|
|
app,
|
|
["--output", "json", "optimize", "parallelism", str(ROOT / "examples/yaml/test_fleet_plan.yaml")],
|
|
)
|
|
|
|
assert result.exit_code == 0
|
|
payload = json.loads(result.stdout)
|
|
assert payload["best_config"]
|
|
assert isinstance(payload["top_candidates"], list)
|