[CI][RFC] Replace black-jupyter with ruff-format (#37210)

Co-authored-by: Alison Shao <a.shao@wustl.edu>
This commit is contained in:
Alex Nails
2026-09-02 19:46:08 -07:00
committed by GitHub
co-authored by Alison Shao
parent 2641e427be
commit 28262c20df
1411 changed files with 7766 additions and 8176 deletions
+3 -2
View File
@@ -590,8 +590,9 @@ class ResolveCommit(unittest.TestCase):
self.assertEqual(lsm.resolve_commit(None, "/nonexistent"), "deadbeef")
def test_unknown_when_no_git(self):
with tempfile.TemporaryDirectory() as tmp, mock.patch.dict(
os.environ, {}, clear=True
with (
tempfile.TemporaryDirectory() as tmp,
mock.patch.dict(os.environ, {}, clear=True),
):
self.assertEqual(lsm.resolve_commit(None, tmp), "unknown")
+2 -3
View File
@@ -95,7 +95,7 @@ def update_files(model, dry_run=False):
new_content = pattern.sub(rf"\g<1>{p90}\3", new_content)
changes.append((relpath, suite, old_val, p90))
print(
f" {relpath}: suite={suite!r} " f"est_time {old_val} -> {p90}",
f" {relpath}: suite={suite!r} est_time {old_val} -> {p90}",
file=sys.stderr,
)
break # one (file, suite) -> at most one register call
@@ -121,8 +121,7 @@ def write_summary(changes, summary_file):
lines = []
if sig:
lines.append(
f"### Significant est_time changes "
f"({len(sig)} of {len(changes)} updates)"
f"### Significant est_time changes ({len(sig)} of {len(changes)} updates)"
)
lines.append("")
lines.append("| File | Suite | Old (s) | New (s) | Δ |")
+3 -3
View File
@@ -34,9 +34,9 @@ from ci_register import CIRegistry, HWBackend, ut_parse_one_file
# (highest test volume historically), then accelerators that have been
# wired into the registry more recently (XPU, MUSA, MLX).
BACKEND_DISPLAY_ORDER = ("CUDA", "AMD", "NPU", "CPU", "XPU", "MUSA", "MLX")
assert set(BACKEND_DISPLAY_ORDER) == {
b.name for b in HWBackend
}, "BACKEND_DISPLAY_ORDER is out of sync with HWBackend"
assert set(BACKEND_DISPLAY_ORDER) == {b.name for b in HWBackend}, (
"BACKEND_DISPLAY_ORDER is out of sync with HWBackend"
)
# --------------------------------------------------------------------------- #
# multimodal_gen test coverage
@@ -198,7 +198,7 @@ def print_suite_summary(
)
for standalone_file in suite_info.missing_standalone_estimates:
print(f" - {standalone_file}")
print(f" Total estimated time: {total_time:.1f}s ({total_time/60:.1f} min)")
print(f" Total estimated time: {total_time:.1f}s ({total_time / 60:.1f} min)")
print(f" Selected partitions: {len(partitions)}")
print()
@@ -207,7 +207,7 @@ def print_suite_summary(
partition_time = sum(item.est_time for item in partition)
print(f" Partition {idx}:")
print(
f" Estimated time: {partition_time:.1f}s ({partition_time/60:.1f} min)"
f" Estimated time: {partition_time:.1f}s ({partition_time / 60:.1f} min)"
)
for item in partition:
fallback_suffix = (
@@ -304,9 +304,11 @@ def main():
sys.exit(1)
print("=== Diffusion Partition Computation ===")
print(f"Min partition time: {args.min_time}s ({args.min_time/60:.1f} min)")
print(f"Target partition time: {args.target_time}s ({args.target_time/60:.1f} min)")
print(f"Max partition time: {args.max_time}s ({args.max_time/60:.1f} min)")
print(f"Min partition time: {args.min_time}s ({args.min_time / 60:.1f} min)")
print(
f"Target partition time: {args.target_time}s ({args.target_time / 60:.1f} min)"
)
print(f"Max partition time: {args.max_time}s ({args.max_time / 60:.1f} min)")
print()
for suite_name, suite_info in suites.items():
@@ -273,7 +273,7 @@ def generate_dashboard(
if pct > REGRESSION_THRESHOLD:
regressions.append(
f"**{cid}** ({fw}): {prev:.2f}s -> {cur:.2f}s "
f"(+{pct*100:.1f}%)"
f"(+{pct * 100:.1f}%)"
)
if regressions:
+6 -6
View File
@@ -855,9 +855,9 @@ def _install_framework(fw_name: str, dry_run: bool = False) -> bool:
if dry_run:
print(f" [DRY-RUN] Would install: bash {INSTALL_SCRIPT} {fw_name}")
return True
print(f"\n{'='*60}")
print(f"\n{'=' * 60}")
print(f"Installing framework: {fw_name}")
print(f"{'='*60}")
print(f"{'=' * 60}")
ret = subprocess.run(
["bash", str(INSTALL_SCRIPT), fw_name],
timeout=600,
@@ -943,9 +943,9 @@ def run_comparison(
installed_fws.add(fw_name)
for case, fw_cfg in pairs:
print(f"\n{'='*60}")
print(f"\n{'=' * 60}")
print(f"Case: {case['id']} | Model: {case['model']} | Framework: {fw_name}")
print(f"{'='*60}")
print(f"{'=' * 60}")
if dry_run:
cmd = build_server_cmd(fw_name, case, fw_cfg, port)
@@ -982,9 +982,9 @@ def run_comparison(
print(f"\nResults written to {output}")
# Print summary table
print(f"\n{'='*60}")
print(f"\n{'=' * 60}")
print("SUMMARY")
print(f"{'='*60}")
print(f"{'=' * 60}")
for r in results:
lat = f"{r['latency_s']:.2f}s" if r["latency_s"] else r.get("error", "N/A")
print(f" {r['case_id']:30s} | {r['framework']:12s} | {lat}")
@@ -155,8 +155,7 @@ def print_missing_standalone_estimates_summary(
print("\n" + "=" * 60)
print(
"Add standalone estimate(s) to "
"python/sglang/multimodal_gen/test/run_suite.py"
"Add standalone estimate(s) to python/sglang/multimodal_gen/test/run_suite.py"
)
print("=" * 60)
print("The following standalone file(s) used fallback estimate 300.0s.")
-1
View File
@@ -311,7 +311,6 @@ def copy_trace_files(source_dir, target_base_path):
for root, dirs, files in os.walk(source_dir):
for file in files:
if file.endswith(".json.gz"):
# Only upload TP rank 0 traces to avoid duplicates across tensor parallel ranks
if "TP-" in file and "TP-0" not in file:
continue
+1 -1
View File
@@ -321,7 +321,7 @@ def fetch_all_jobs_snapshot(
for i, run in enumerate(unique_runs):
if (i + 1) % 20 == 0:
print(f"Processing run {i+1}/{total_runs}...", file=sys.stderr)
print(f"Processing run {i + 1}/{total_runs}...", file=sys.stderr)
workflow_name = run.get("_workflow", "-")
try:
+3 -4
View File
@@ -675,7 +675,7 @@ def resolve_test_file(file_part):
full_path = (
file_part
if file_part.startswith("python/")
else f"python/sglang/multimodal_gen/test/{file_part[len(prefix):]}"
else f"python/sglang/multimodal_gen/test/{file_part[len(prefix) :]}"
)
if not os.path.isfile(full_path):
return None, False, f"File not found: `{full_path}`"
@@ -1207,9 +1207,8 @@ def handle_rerun_test(
):
return False
if (
refresh_precision_baseline
and not _check_precision_baseline_refresh_permissions(gh_repo, pr, comment)
if refresh_precision_baseline and not _check_precision_baseline_refresh_permissions(
gh_repo, pr, comment
):
return False
+1 -1
View File
@@ -323,7 +323,7 @@ def fetch_all_jobs_snapshot(
for i, run in enumerate(unique_runs):
if (i + 1) % 20 == 0:
print(f"Processing run {i+1}/{total_runs}...", file=sys.stderr)
print(f"Processing run {i + 1}/{total_runs}...", file=sys.stderr)
workflow_name = run.get("_workflow", "-")
try:
+3 -3
View File
@@ -709,9 +709,9 @@ class SGLangFailuresAnalyzer:
runner_instance_key = f"{runner_labels_str}_{runner_id}"
runner_instance_stats[runner_instance_key]["total_jobs"] += 1
# Store runner name for reference
runner_instance_stats[runner_instance_key][
"runner_name"
] = runner_name
runner_instance_stats[runner_instance_key]["runner_name"] = (
runner_name
)
# Calculate queue time (time from created to started) per instance
created_at = job.get("created_at")
+3 -8
View File
@@ -157,9 +157,7 @@ def get_oss_repo(dry_run):
"""
gh_token = os.getenv("GH_TOKEN")
if not gh_token:
print(
"⚠️ Warning: GH_TOKEN environment variable not set. Skipping PR creation."
)
print("⚠️ Warning: GH_TOKEN environment variable not set. Skipping PR creation.")
if not dry_run:
return
@@ -361,9 +359,7 @@ def create_pull_request(oss_root, branch_name, title, body, dry_run):
"""Create a pull request in the OSS repo using the GitHub CLI."""
gh_token = os.getenv("GH_TOKEN")
if not gh_token:
print(
"⚠️ Warning: GH_TOKEN environment variable not set. Skipping PR creation."
)
print("⚠️ Warning: GH_TOKEN environment variable not set. Skipping PR creation.")
if not dry_run:
return
@@ -569,8 +565,7 @@ def main():
"Please check the CI logs for the full patch and conflict details."
)
pr_body_parts.append(
f"\n\n---\n\n"
f"*This is an automated PR created by scripts/copy_to_oss.py.*"
f"\n\n---\n\n*This is an automated PR created by scripts/copy_to_oss.py.*"
)
pr_body = "\n".join(pr_body_parts)
+2 -5
View File
@@ -120,14 +120,11 @@ def find_latest_oss_sync_commit(repo_root: Optional[str] = None) -> Optional[str
if m:
oss_commit = m.group(1)
print(
f"✅ Latest OSS sync commit found: {oss_commit} "
f"(from: {subject})"
f"✅ Latest OSS sync commit found: {oss_commit} (from: {subject})"
)
return oss_commit
print(
"⚠️ No '[Automated PR] Copy OSS code from commit ...' " "found in history."
)
print("⚠️ No '[Automated PR] Copy OSS code from commit ...' found in history.")
return None
except subprocess.CalledProcessError as e:
+1 -1
View File
@@ -237,7 +237,7 @@ def generate_perfetto_span(engine_root_spans, smg_otel_spans, thread_meta_data):
for thread_span in root_span["child"]:
pid = int(thread_span["attributes"]["pid"])
host_id = thread_span["attributes"]["host_id"]
thread_name = f'{thread_span["attributes"]["host_id"][:8]}:{thread_span["attributes"]["thread_label"]}'
thread_name = f"{thread_span['attributes']['host_id'][:8]}:{thread_span['attributes']['thread_label']}"
if "pp_rank" in thread_span["attributes"]:
thread_name += f"-PP{thread_span['attributes']['pp_rank']}"
if "dp_rank" in thread_span["attributes"]:
+1 -5
View File
@@ -156,11 +156,7 @@ def main() -> int:
"test silently never runs. Switch to the modern form:\n"
)
for f, suite in non_dispatchable:
print(
f" {f}\n"
f' suite="{suite}"'
f' -> stage="...", runner_config="..."'
)
print(f' {f}\n suite="{suite}" -> stage="...", runner_config="..."')
print()
exit_code = 1
if dead_tests:
+1 -1
View File
@@ -189,7 +189,7 @@ class TestMultiTenantRadixTree(unittest.TestCase):
for i in range(100):
for j, prefix in enumerate(prefixes):
random_suffix = "".join(random.choices(string.ascii_letters, k=10))
self.tree.insert(prefix + random_suffix, f"tenant{j+1}")
self.tree.insert(prefix + random_suffix, f"tenant{j + 1}")
sizes_before = self.tree.get_used_size_per_tenant()
print(sizes_before)
+1 -1
View File
@@ -84,7 +84,7 @@ def update_others_index(
return False
index_dir.mkdir(parents=True, exist_ok=True)
updated = f"{OTHERS_HEADER}{entry}{content[len(OTHERS_HEADER):]}"
updated = f"{OTHERS_HEADER}{entry}{content[len(OTHERS_HEADER) :]}"
index_path.write_text(updated, encoding="utf-8")
return True