trace: make window materialization atomic
This commit is contained in:
@@ -853,6 +853,64 @@ class CoreFlowTests(unittest.TestCase):
|
||||
self.assertEqual(rows[0]["output_length"], 7)
|
||||
self.assertIsInstance(rows[0]["sampling_u"], float)
|
||||
|
||||
def test_prepare_trace_windows_preserves_existing_files_on_failure(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
tmp_path = Path(tmp)
|
||||
legacy_source = tmp_path / "legacy"
|
||||
thinking_source = tmp_path / "thinking"
|
||||
output_root = tmp_path / "trace_windows"
|
||||
traces_dir = output_root / "traces"
|
||||
legacy_source.mkdir()
|
||||
thinking_source.mkdir()
|
||||
traces_dir.mkdir(parents=True)
|
||||
|
||||
for filename in [
|
||||
"qwen_chat_blksz_64_031109-031111",
|
||||
"qwen_chat_blksz_64_031121-031123",
|
||||
]:
|
||||
for suffix in [".jsonl", "_prompt.jsonl"]:
|
||||
path = legacy_source / f"{filename}{suffix}"
|
||||
path.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"chat_id": "c1",
|
||||
"turn": 1,
|
||||
"timestamp": 3605.0,
|
||||
"input_length": 20,
|
||||
"output_length": 7,
|
||||
"prompt": "prompt",
|
||||
}
|
||||
)
|
||||
+ "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
sentinel = traces_dir / "chat_w20260311_1000.jsonl"
|
||||
sentinel.write_text("sentinel\n", encoding="utf-8")
|
||||
|
||||
proc = subprocess.run(
|
||||
[
|
||||
"python3",
|
||||
"scripts/prepare_trace_windows.py",
|
||||
"--legacy-source",
|
||||
str(legacy_source),
|
||||
"--thinking-source",
|
||||
str(thinking_source),
|
||||
"--output-root",
|
||||
str(output_root),
|
||||
"--workloads",
|
||||
"chat",
|
||||
"--overwrite",
|
||||
],
|
||||
cwd="/home/gahow/phd/aituner",
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
|
||||
self.assertNotEqual(proc.returncode, 0)
|
||||
self.assertEqual(sentinel.read_text(encoding="utf-8"), "sentinel\n")
|
||||
self.assertEqual(sorted(path.name for path in traces_dir.glob("*.tmp.*")), [])
|
||||
|
||||
def test_binary_search_max_feasible(self) -> None:
|
||||
result = binary_search_max_feasible(
|
||||
low=0.0,
|
||||
|
||||
Reference in New Issue
Block a user