Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 1 addition & 18 deletions src/telemetry_lab/ai_assisted_detection_demo/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)

Expand Down
19 changes: 1 addition & 18 deletions src/telemetry_lab/config_change_investigation_demo/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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():
Expand Down
17 changes: 17 additions & 0 deletions src/telemetry_lab/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading