release: freeze Nexus One AI 1.0.0-rc1
This commit is contained in:
1 parent
63acefd890
commit
4f1419ca93
152 files changed
+9445
-828
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import hashlib
|
||||
import importlib.util
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
MODULE_PATH = Path(__file__).parents[2] / "autoinstall/offline/validate-python-runtime-profile.py"
|
||||
SPEC = importlib.util.spec_from_file_location("validate_python_runtime_profile", MODULE_PATH)
|
||||
MODULE = importlib.util.module_from_spec(SPEC)
|
||||
assert SPEC.loader
|
||||
SPEC.loader.exec_module(MODULE)
|
||||
|
||||
|
||||
class PythonRuntimeProfileTests(unittest.TestCase):
|
||||
def test_accepts_required_wheel_with_matching_digest(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
wheel = Path(directory) / "torch-cpu.whl"
|
||||
wheel.write_bytes(b"cpu")
|
||||
contract = {"profiles": {"cpu-only": {
|
||||
"required": {wheel.name: hashlib.sha256(b"cpu").hexdigest()},
|
||||
"forbidden_filename_patterns": ["cu12"],
|
||||
}}}
|
||||
self.assertEqual(MODULE.validate(contract, "cpu-only", Path(directory)), [])
|
||||
|
||||
def test_rejects_forbidden_gpu_wheel_and_digest_mismatch(self):
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
root = Path(directory)
|
||||
(root / "torch-cpu.whl").write_bytes(b"changed")
|
||||
(root / "nvidia_cuda_cu12.whl").write_bytes(b"gpu")
|
||||
contract = {"profiles": {"cpu-only": {
|
||||
"required": {"torch-cpu.whl": hashlib.sha256(b"cpu").hexdigest()},
|
||||
"forbidden_filename_patterns": ["nvidia_", "cu12"],
|
||||
}}}
|
||||
errors = MODULE.validate(contract, "cpu-only", root)
|
||||
self.assertTrue(any("forbidden pattern" in error for error in errors))
|
||||
self.assertIn("digest mismatch: torch-cpu.whl", errors)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user