Decouple deterministic smoke from GPU quota
Browse files
tests/test_app_gpu_boundary.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import ast
|
| 2 |
+
from pathlib import Path
|
| 3 |
+
|
| 4 |
+
|
| 5 |
+
def test_deterministic_export_bypasses_gpu_wrapper(tmp_path):
|
| 6 |
+
source = (Path(tmp_path) / "app.py").read_text(encoding="utf-8") if (Path(tmp_path) / "app.py").exists() else Path("app.py").read_text(encoding="utf-8")
|
| 7 |
+
tree = ast.parse(source)
|
| 8 |
+
functions = {node.name: node for node in tree.body if isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef))}
|
| 9 |
+
assert "_generate_impl" in functions
|
| 10 |
+
assert "_generate_gpu" in functions
|
| 11 |
+
assert "generate" in functions
|
| 12 |
+
gpu = functions["_generate_gpu"]
|
| 13 |
+
assert any(isinstance(dec, ast.Name) and dec.id == "GPU_FUNCTION" for dec in gpu.decorator_list)
|
| 14 |
+
public = functions["generate"]
|
| 15 |
+
assert any(isinstance(node, ast.If) and isinstance(node.test, ast.Name) and node.test.id == "demo_mode" for node in public.body)
|