Skip to content

Commit e22e306

Browse files
committed
test: update delta checkpoint and chained delta tests
- Modify integration test for delta checkpoint flow - Update unit tests for chained deltas and checkpoint cleanup
1 parent ebfaddd commit e22e306

File tree

3 files changed

+131
-145
lines changed

3 files changed

+131
-145
lines changed

tests/integration/infrastructure/test_delta_checkpoint_flow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def test_metadata_is_delta(self) -> None:
297297
window=110,
298298
file_manifest={},
299299
checkpoint_type="DELTA",
300-
base_window=100,
300+
anchor_window=100,
301301
weights_hash="abc123",
302302
)
303303
assert delta_metadata.is_delta()
@@ -308,7 +308,7 @@ def test_metadata_serialization(self) -> None:
308308
window=110,
309309
file_manifest={"delta_sparse.safetensors": "hash123"},
310310
checkpoint_type="DELTA",
311-
base_window=100,
311+
anchor_window=100,
312312
weights_hash="abcdef1234567890",
313313
)
314314

@@ -319,7 +319,7 @@ def test_metadata_serialization(self) -> None:
319319
# Deserialize
320320
loaded = json.loads(json_str)
321321
assert loaded["checkpoint_type"] == "DELTA"
322-
assert loaded["base_window"] == 100
322+
assert loaded["anchor_window"] == 100
323323
assert loaded["weights_hash"] == "abcdef1234567890"
324324

325325

tests/unit/infrastructure/test_chained_deltas.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ class TestRetentionPolicyChainedDeltas:
149149

150150
def test_keeps_entire_active_chain(self) -> None:
151151
"""Should keep all windows from current anchor to now."""
152-
from grail.trainer.checkpoint_publisher import _compute_keep_windows
152+
from grail.shared.retention_utils import compute_retention_windows
153153

154-
with patch("grail.trainer.checkpoint_publisher.DELTA_BASE_INTERVAL", 5):
155-
with patch("grail.trainer.checkpoint_publisher.WINDOW_LENGTH", 30):
154+
with patch("grail.shared.retention_utils.DELTA_BASE_INTERVAL", 5):
155+
with patch("grail.shared.retention_utils.WINDOW_LENGTH", 30):
156156
# Anchor stride = 5 * 30 = 150
157157
# Current window 180: anchor at 150
158-
result = _compute_keep_windows(180)
158+
result = compute_retention_windows(180)
159159

160160
# Should keep: 150, 180 (chain from 150 to 180)
161161
# Also 0 (previous anchor) and 0-150 chain
@@ -164,14 +164,14 @@ def test_keeps_entire_active_chain(self) -> None:
164164

165165
def test_keeps_previous_anchor_chain(self) -> None:
166166
"""Should keep previous anchor's chain for transition."""
167-
from grail.trainer.checkpoint_publisher import _compute_keep_windows
167+
from grail.shared.retention_utils import compute_retention_windows
168168

169-
with patch("grail.trainer.checkpoint_publisher.DELTA_BASE_INTERVAL", 3):
170-
with patch("grail.trainer.checkpoint_publisher.WINDOW_LENGTH", 30):
169+
with patch("grail.shared.retention_utils.DELTA_BASE_INTERVAL", 3):
170+
with patch("grail.shared.retention_utils.WINDOW_LENGTH", 30):
171171
# Anchor stride = 3 * 30 = 90
172172
# Current window 120: anchor at 90
173173
# Previous anchor at 0
174-
result = _compute_keep_windows(120)
174+
result = compute_retention_windows(120)
175175

176176
# Current chain: 90, 120
177177
assert 90 in result
@@ -190,8 +190,8 @@ def test_consumer_retention_keeps_chain(self) -> None:
190190
keep_limit=3,
191191
)
192192

193-
with patch("grail.infrastructure.checkpoint_consumer.DELTA_BASE_INTERVAL", 5):
194-
with patch("grail.infrastructure.checkpoint_consumer.WINDOW_LENGTH", 30):
193+
with patch("grail.shared.retention_utils.DELTA_BASE_INTERVAL", 5):
194+
with patch("grail.shared.retention_utils.WINDOW_LENGTH", 30):
195195
result = manager._compute_keep_windows(180)
196196

197197
# Should keep chain from anchor (150) to now (180)

0 commit comments

Comments
 (0)