from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def test_requirements_are_compatible_with_gradio_631_and_zerogpu_runtime(): requirements = (ROOT / "requirements.txt").read_text(encoding="utf-8").lower() assert "transformers==5.22.0" in requirements assert "huggingface-hub>=1.31.0,<2.0" in requirements assert "torch" not in [line.split("=")[0].strip() for line in requirements.splitlines() if line and not line.startswith("#")] assert "gradio" not in [line.split("=")[0].strip() for line in requirements.splitlines() if line and not line.startswith("#")] assert "spaces" not in [line.split("=")[0].strip() for line in requirements.splitlines() if line and not line.startswith("#")] assert "download.pytorch.org/whl/cpu" not in requirements assert "transformers==4.57.1" not in requirements def test_space_metadata_matches_current_runtime_and_supported_python(): readme = (ROOT / "README.md").read_text(encoding="utf-8") frontmatter = readme.split("---", 2)[1] assert "sdk: gradio" in frontmatter assert 'sdk_version: "6.31.0"' in frontmatter assert 'python_version: "3.12.12"' in frontmatter assert "app_file: app.py" in frontmatter def test_app_uses_zero_gpu_and_does_not_mask_cuda(): app = (ROOT / "app.py").read_text(encoding="utf-8") assert "import spaces" in app assert app.index("import spaces") < app.index("import torch") assert "@spaces.GPU(duration=_estimate_gpu_duration)" in app assert "model.to(MODEL_DEVICE)" in app assert "CUDA_VISIBLE_DEVICES" not in app assert "torch.float16" in app assert "dtype=MODEL_DTYPE" in app assert "torch_dtype=MODEL_DTYPE" not in app def test_app_uses_full_whisper_large_v3_and_accuracy_first_decoding(): app = (ROOT / "app.py").read_text(encoding="utf-8") assert 'MODEL_ID = "openai/whisper-large-v3"' in app assert '"max_new_tokens": 448' in app assert '"num_beams": 1' in app assert '"temperature": (0.0, 0.2, 0.4, 0.6, 0.8, 1.0)' in app assert '"compression_ratio_threshold": 1.35' in app assert '"no_speech_threshold": 0.6' in app assert 'chunk_length_s=30' not in app assert "accuracy-first sequential long-form" in app assert "transcript_coverage" in app assert "completeness repair" in app assert "WHISPER-MEDIUM" not in app