feat(m1): offline generation pipeline + CLI (T1.5)

- tsmm.data.gen_pipeline.gen_one_sample: composes attrs/series/anomaly/event/missing/instruct
  into one JSON-serializable sample (full schema)
- write_jsonl helper
- scripts/gen_synthetic.py: multiprocessing + tqdm CLI (--n/--out/--seed/--workers)
- regression: build_instruction('event') with empty events no longer raises (TDD RED first)
- tests/test_gen_pipeline.py (6 tests, RED->GREEN)

Exit criteria: python scripts/gen_synthetic.py --n 1000 -> 1000 samples, schema-OK,
all 6 categories balanced (~130-190 each).
This commit is contained in:
张宗平
2026-06-29 23:29:04 +08:00
parent 1b4c6ddf4c
commit 9cfda37275
6 changed files with 346 additions and 2 deletions
+9
View File
@@ -97,6 +97,15 @@ def test_event_answer_references_the_event():
assert "deploy" in (instruction + " " + answer).lower()
def test_event_category_handles_missing_events_gracefully():
"""Regression: selecting the 'event' category when events==[] must not raise."""
ctx = _sample_context()
ctx["events"] = []
instruction, answer = build_instruction(category="event", **ctx, seed=0)
assert isinstance(instruction, str) and instruction.strip()
assert isinstance(answer, str) and answer.strip()
def test_root_cause_answer_is_text():
ctx = _sample_context()
_, answer = build_instruction(category="root_cause", **ctx, seed=0)