Coverage for data_pipeline/v2_manifest.py: 100%
18 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-22 12:55 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-22 12:55 +0000
1"""V2 metadata contract for the existing Lean-data training pipeline."""
3from __future__ import annotations
5from datetime import datetime, timezone
6from pathlib import Path
8ROOT = Path(__file__).resolve().parents[1]
11def _asset_group_counts(assets: list[dict]) -> dict[str, int]:
12 counts: dict[str, int] = {}
13 for asset in assets:
14 security_type = str(asset.get("security_type", "unknown"))
15 counts[security_type] = counts.get(security_type, 0) + 1
16 return counts
19def _pipeline_consumers() -> list[str]:
20 return [
21 "train.py baseline model training",
22 "Lean backtesting via main.py",
23 "moe expert datasets",
24 "regime detection features",
25 "topology snapshots",
26 "dynamic risk and volatility dashboard feeds",
27 ]
30def build_v2_pipeline_manifest(config: dict, dataset_manifest: dict | None = None) -> dict:
31 phase1 = config["phase1"]
32 universe = phase1["universe"]
33 assets = list(universe["assets"])
34 dataset_manifest = dataset_manifest or {}
36 return {
37 "project": config.get("name", "Aether Quant"),
38 "version": "v2",
39 "created_at": datetime.now(timezone.utc).isoformat(),
40 "data_source": {
41 "type": "local_lean_data_folder",
42 "root": "data",
43 "absolute_root": str(ROOT / "data"),
44 "training_uses_lean_data_folder": True,
45 "backtesting_uses_lean_data_folder": True,
46 },
47 "universe": {
48 "name": universe.get("name"),
49 "resolution": universe.get("resolution"),
50 "asset_count": len(assets),
51 "asset_group_counts": _asset_group_counts(assets),
52 "tickers": [asset["ticker"] for asset in assets],
53 },
54 "windows": phase1["windows"],
55 "features": {
56 "base_features": phase1["features"]["input_set"],
57 "target": phase1["target"],
58 "normalization": phase1["features"].get("normalization"),
59 },
60 "quality": {
61 "training_eligible_assets": dataset_manifest.get("training_eligible_assets", []),
62 "trading_eligible_assets": dataset_manifest.get("trading_eligible_assets", []),
63 "observation_only_assets": dataset_manifest.get("observation_only_assets", []),
64 },
65 "consumers": _pipeline_consumers(),
66 "next_v2_dependencies": [
67 "regime vectors",
68 "expert-specific training slices",
69 "topology snapshots",
70 "volatility sizing inputs",
71 "experience observations",
72 ],
73 }