diff --git a/AGENTS.md b/AGENTS.md index fca85af..37703a2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,7 +12,7 @@ - Install: `python -m pip install -e .` - Test: `pytest` -- Demo run: `python -m telemetry_window_demo.cli run --config configs/default.yaml` +- Demo run: `telemetry-lab run window --config configs/default.yaml` ## Review guidelines diff --git a/src/telemetry_lab/ai_assisted_detection_demo/pipeline.py b/src/telemetry_lab/ai_assisted_detection_demo/pipeline.py index aca8f44..2b724d7 100644 --- a/src/telemetry_lab/ai_assisted_detection_demo/pipeline.py +++ b/src/telemetry_lab/ai_assisted_detection_demo/pipeline.py @@ -11,7 +11,7 @@ import yaml -from ..io import ensure_output_directory, ensure_output_file_path +from ..io import ensure_output_directory, ensure_output_file_path, load_jsonl from ..manifest import ( RUN_MANIFEST_SCHEMA_VERSION, build_run_manifest, @@ -319,23 +319,6 @@ def run_demo( } -def load_jsonl(path: Path) -> list[dict[str, Any]]: - records: list[dict[str, Any]] = [] - with path.open("r", encoding="utf-8") as handle: - for line_number, line in enumerate(handle, start=1): - raw = line.strip() - if not raw: - continue - try: - payload = json.loads(raw) - except json.JSONDecodeError as exc: - raise ValueError(f"Invalid JSONL at line {line_number} in {path}") from exc - if not isinstance(payload, dict): - raise ValueError("Expected JSON object records in JSONL input.") - records.append(payload) - return records - - def load_yaml(path: Path) -> dict[str, Any]: with path.open("r", encoding="utf-8") as handle: loaded = yaml.safe_load(handle) or {} diff --git a/src/telemetry_lab/cloud_iam_change_investigation_demo/pipeline.py b/src/telemetry_lab/cloud_iam_change_investigation_demo/pipeline.py index 594d106..7c93cfa 100644 --- a/src/telemetry_lab/cloud_iam_change_investigation_demo/pipeline.py +++ b/src/telemetry_lab/cloud_iam_change_investigation_demo/pipeline.py @@ -8,7 +8,7 @@ import yaml -from ..io import ensure_output_directory, ensure_output_file_path +from ..io import ensure_output_directory, ensure_output_file_path, load_jsonl from ..manifest import ( RUN_MANIFEST_SCHEMA_VERSION, build_run_manifest, @@ -164,23 +164,6 @@ def load_yaml(path: Path) -> dict[str, Any]: return payload -def load_jsonl(path: Path) -> list[dict[str, Any]]: - records: list[dict[str, Any]] = [] - with path.open("r", encoding="utf-8") as handle: - for line_number, line in enumerate(handle, start=1): - raw = line.strip() - if not raw: - continue - try: - payload = json.loads(raw) - except json.JSONDecodeError as exc: - raise ValueError(f"Invalid JSONL at line {line_number} in {path}") from exc - if not isinstance(payload, dict): - raise ValueError("Expected JSON object records in JSONL input.") - records.append(payload) - return records - - def validate_demo_config(config: Mapping[str, Any]) -> dict[str, Any]: reject_unknown_fields(config, CLOUD_IAM_CONFIG_FIELDS) diff --git a/src/telemetry_lab/config_change_investigation_demo/pipeline.py b/src/telemetry_lab/config_change_investigation_demo/pipeline.py index 763fffb..b662b85 100644 --- a/src/telemetry_lab/config_change_investigation_demo/pipeline.py +++ b/src/telemetry_lab/config_change_investigation_demo/pipeline.py @@ -8,7 +8,7 @@ import yaml -from ..io import ensure_output_directory, ensure_output_file_path +from ..io import ensure_output_directory, ensure_output_file_path, load_jsonl from ..manifest import ( RUN_MANIFEST_SCHEMA_VERSION, build_run_manifest, @@ -198,23 +198,6 @@ def validate_demo_config(config: Mapping[str, Any]) -> dict[str, Any]: } -def load_jsonl(path: Path) -> list[dict[str, Any]]: - records: list[dict[str, Any]] = [] - with path.open("r", encoding="utf-8") as handle: - for line_number, line in enumerate(handle, start=1): - raw = line.strip() - if not raw: - continue - try: - payload = json.loads(raw) - except json.JSONDecodeError as exc: - raise ValueError(f"Invalid JSONL at line {line_number} in {path}") from exc - if not isinstance(payload, dict): - raise ValueError("Expected JSON object records in JSONL input.") - records.append(payload) - return records - - def resolve_demo_path(demo_root: Path, value: str) -> Path: candidate = Path(value) if candidate.is_absolute(): diff --git a/src/telemetry_lab/io.py b/src/telemetry_lab/io.py index 18b12e4..c0794c8 100644 --- a/src/telemetry_lab/io.py +++ b/src/telemetry_lab/io.py @@ -31,6 +31,23 @@ ALERT_TABLE_TEXT_COLUMNS = ("rule_name", "severity") +def load_jsonl(path: Path) -> list[dict[str, Any]]: + records: list[dict[str, Any]] = [] + with path.open("r", encoding="utf-8") as handle: + for line_number, line in enumerate(handle, start=1): + raw = line.strip() + if not raw: + continue + try: + payload = json.loads(raw) + except json.JSONDecodeError as exc: + raise ValueError(f"Invalid JSONL at line {line_number} in {path}") from exc + if not isinstance(payload, dict): + raise ValueError("Expected JSON object records in JSONL input.") + records.append(payload) + return records + + def load_config(path: str | Path) -> dict[str, Any]: config_path = Path(path) _require_existing_file(config_path, display_name="Config file")