[CI][RFC] Replace black-jupyter with ruff-format (#37210)
Co-authored-by: Alison Shao <a.shao@wustl.edu>
This commit is contained in:
co-authored by
Alison Shao
parent
2641e427be
commit
28262c20df
@@ -29,7 +29,6 @@ TORCH_DTYPES = [torch.float16]
|
||||
|
||||
|
||||
class TestClipModels(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
mp.set_start_method("spawn", force=True)
|
||||
@@ -61,12 +60,12 @@ class TestClipModels(unittest.TestCase):
|
||||
)
|
||||
print("text similarity diff", abs(text_similarity - 1))
|
||||
print("image similarity diff", abs(image_similarity - 1))
|
||||
assert torch.all(
|
||||
abs(text_similarity - 1) < prefill_tolerance
|
||||
), "embeddings are not all close"
|
||||
assert torch.all(
|
||||
abs(image_similarity - 1) < prefill_tolerance
|
||||
), "embeddings are not all close"
|
||||
assert torch.all(abs(text_similarity - 1) < prefill_tolerance), (
|
||||
"embeddings are not all close"
|
||||
)
|
||||
assert torch.all(abs(image_similarity - 1) < prefill_tolerance), (
|
||||
"embeddings are not all close"
|
||||
)
|
||||
|
||||
def test_accuracy(self):
|
||||
for model, prefill_tolerance in MODELS:
|
||||
|
||||
@@ -64,16 +64,16 @@ class TestQmeQwenModels(CustomTestCase):
|
||||
hf_text_embeddings.embed_logits[0], srt_text_embeddings.embed_logits[0]
|
||||
)
|
||||
print("texts similarity diff", abs(similarity - 1))
|
||||
assert torch.all(
|
||||
abs(similarity - 1) < prefill_tolerance
|
||||
), "embeddings are not all close"
|
||||
assert torch.all(abs(similarity - 1) < prefill_tolerance), (
|
||||
"embeddings are not all close"
|
||||
)
|
||||
similarity = get_similarities(
|
||||
hf_image_embeddings.embed_logits[0], srt_image_embeddings.embed_logits[0]
|
||||
)
|
||||
print("images similarity diff", abs(similarity - 1))
|
||||
assert torch.all(
|
||||
abs(similarity - 1) < prefill_tolerance
|
||||
), "embeddings are not all close"
|
||||
assert torch.all(abs(similarity - 1) < prefill_tolerance), (
|
||||
"embeddings are not all close"
|
||||
)
|
||||
|
||||
def test_accuracy(self):
|
||||
for model, prefill_tolerance in MODELS:
|
||||
|
||||
@@ -61,7 +61,7 @@ class TestKimiK2Thinking(CustomTestCase):
|
||||
|
||||
if is_in_ci():
|
||||
write_github_step_summary(
|
||||
f"### test_gsm8k (Kimi-K2-Thinking)\n" f'{metrics["score"]=:.3f}\n'
|
||||
f'### test_gsm8k (Kimi-K2-Thinking)\n{metrics["score"]=:.3f}\n'
|
||||
)
|
||||
self.assertGreater(metrics["score"], 0.95)
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ class TestMistralLarge3Basic(CustomTestCase):
|
||||
|
||||
if is_in_ci():
|
||||
write_github_step_summary(
|
||||
f"### test_gsm8k (mistral-large-3)\n" f'{metrics["score"]=:.3f}\n'
|
||||
f'### test_gsm8k (mistral-large-3)\n{metrics["score"]=:.3f}\n'
|
||||
)
|
||||
self.assertGreater(metrics["score"], 0.90)
|
||||
|
||||
@@ -79,7 +79,7 @@ class TestMistralLarge3Basic(CustomTestCase):
|
||||
|
||||
if is_in_ci():
|
||||
write_github_step_summary(
|
||||
f"### test_bs_1_speed (mistral-large-3)\n" f"{speed=:.2f} token/s\n"
|
||||
f"### test_bs_1_speed (mistral-large-3)\n{speed=:.2f} token/s\n"
|
||||
)
|
||||
self.assertGreater(speed, 50)
|
||||
|
||||
|
||||
@@ -156,9 +156,9 @@ async def _stream_websocket_async(
|
||||
|
||||
async with websockets.connect(websocket_url) as websocket:
|
||||
created = json.loads(await websocket.recv())
|
||||
assert (
|
||||
created.get("type") == "session.created"
|
||||
), f"expected session.created, got {created!r}"
|
||||
assert created.get("type") == "session.created", (
|
||||
f"expected session.created, got {created!r}"
|
||||
)
|
||||
session_id = created["session"]["id"]
|
||||
|
||||
transcription_cfg = {"model": "qwen3-asr"}
|
||||
@@ -200,9 +200,9 @@ async def _stream_websocket_async(
|
||||
if t == "conversation.item.input_audio_transcription.delta":
|
||||
deltas.append(resp["delta"])
|
||||
elif t == "conversation.item.input_audio_transcription.completed":
|
||||
assert (
|
||||
"usage" in resp
|
||||
), f"transcription.completed missing required usage field: {resp!r}"
|
||||
assert "usage" in resp, (
|
||||
f"transcription.completed missing required usage field: {resp!r}"
|
||||
)
|
||||
assert resp["usage"].get("type") == "duration", resp["usage"]
|
||||
completed_msg.update(resp)
|
||||
return
|
||||
@@ -317,7 +317,7 @@ class TestQwen3ASRTranscription(CustomTestCase):
|
||||
self.assertEqual(
|
||||
results[0],
|
||||
results[i],
|
||||
f"Request {i+1} differs from first request",
|
||||
f"Request {i + 1} differs from first request",
|
||||
)
|
||||
print(f"[Consistency] All 3 requests match: {results[0][:80]}...")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user