test_data_integrity.py python
57 lines 2.3 KB
Raw
sha256:2313b6a6353294a0ca08ff579624198da250b99163a86215aed31a905912e360 Land Scooling Lab T0/T2 training contract and seven-tier tests Human minor ⚠ breaking 43 days ago
1 """Data-integrity tier tests for stable Scooling Lab evidence and hashes."""
2
3 from __future__ import annotations
4
5 import tempfile
6 import unittest
7 from pathlib import Path
8
9 from scooling_lab_helpers import PROJECT_ROOT, valid_payload
10
11 from scooling_lab.fake_worker import fixture_dataset_hash
12 from scooling_lab.service import TrainingApiService
13 from scooling_lab.store import TrainingJobStore
14
15
16 EXPECTED_UNSLOTH_NOTICE = (
17 "Files under unsloth/*, tests/*, scripts/* are Apache 2.0 licensed.\n"
18 "Files under studio/*, unsloth_cli/* which is optional to install are AGPLv3 licensed."
19 )
20
21
22 class ScoolingLabDataIntegrityTests(unittest.TestCase):
23 """Data-integrity tests for retries, restarts, and license evidence."""
24
25 def test_data_integrity_job_and_artifact_hashes_survive_restart(self) -> None:
26 """Job id, dataset hash, and artifact hash are stable after reload."""
27
28 with tempfile.TemporaryDirectory() as directory:
29 persistence_path = Path(directory) / "jobs.json"
30 service = TrainingApiService(TrainingJobStore(persistence_path))
31 created = service.create_training_job(valid_payload("restart"))
32 job_id = str(created["id"])
33 artifact = service.list_artifacts(job_id)["artifacts"][0]
34 artifact_hash = str(artifact["artifactHash"])
35 dataset_hash = str(artifact["datasetHash"])
36
37 reloaded = TrainingApiService(TrainingJobStore(persistence_path))
38 recreated = reloaded.create_training_job(valid_payload("restart"))
39 reloaded_artifact = reloaded.list_artifacts(job_id)["artifacts"][0]
40
41 self.assertEqual(recreated["id"], job_id)
42 self.assertEqual(reloaded_artifact["datasetHash"], dataset_hash)
43 self.assertEqual(reloaded_artifact["artifactHash"], artifact_hash)
44 self.assertEqual(dataset_hash, fixture_dataset_hash())
45
46 def test_data_integrity_unsloth_evidence_preserved_byte_for_byte(self) -> None:
47 """CI-visible license evidence preserves the pinned candidate and notice."""
48
49 evidence = (PROJECT_ROOT / "docs/UNSLOTH-LICENSE-EVIDENCE.md").read_text(
50 encoding="utf-8"
51 )
52 self.assertIn("- Candidate version: `2026.6.1`.", evidence)
53 self.assertIn(EXPECTED_UNSLOTH_NOTICE, evidence)
54
55
56 if __name__ == "__main__":
57 unittest.main()
File History 1 commit
sha256:2313b6a6353294a0ca08ff579624198da250b99163a86215aed31a905912e360 Land Scooling Lab T0/T2 training contract and seven-tier tests Human minor 43 days ago