EphAsad commited on
Commit
2002265
·
verified ·
1 Parent(s): 693f9e0

Update training/signal_trainer.py

Browse files
Files changed (1) hide show
  1. training/signal_trainer.py +21 -7
training/signal_trainer.py CHANGED
@@ -1,21 +1,35 @@
1
  # training/signal_trainer.py
 
 
 
 
 
2
 
3
  from __future__ import annotations
4
  from typing import Dict, Any
 
 
 
 
 
5
 
6
 
7
  def train_signals() -> Dict[str, Any]:
8
  """
9
- Placeholder for Stage 10C.
 
 
10
 
11
- Later this will update:
12
- data/signals_catalog.json
 
 
 
 
 
13
 
14
- For now we return a simple stub so that the UI
15
- and gold_trainer.py work without errors.
16
- """
17
  return {
18
  "ok": True,
19
  "message": "Signal trainer not implemented yet (Stage 10C placeholder).",
20
- "signals_catalog_path": "data/signals_catalog.json",
21
  }
 
1
  # training/signal_trainer.py
2
+ # ------------------------------------------------------------
3
+ # Stage 10C placeholder:
4
+ # Safely returns a no-op result for signal training.
5
+ # This MUST NOT crash during import.
6
+ # ------------------------------------------------------------
7
 
8
  from __future__ import annotations
9
  from typing import Dict, Any
10
+ import json
11
+ import os
12
+
13
+
14
+ SIGNALS_PATH = "data/signals_catalog.json"
15
 
16
 
17
  def train_signals() -> Dict[str, Any]:
18
  """
19
+ Placeholder trainer. Does nothing except ensure signals_catalog.json exists.
20
+ Must NEVER crash.
21
+ """
22
 
23
+ # Ensure signals catalog exists
24
+ if not os.path.exists(SIGNALS_PATH):
25
+ try:
26
+ with open(SIGNALS_PATH, "w", encoding="utf-8") as f:
27
+ json.dump({}, f, indent=2, ensure_ascii=False)
28
+ except Exception:
29
+ pass
30
 
 
 
 
31
  return {
32
  "ok": True,
33
  "message": "Signal trainer not implemented yet (Stage 10C placeholder).",
34
+ "signals_catalog_path": SIGNALS_PATH,
35
  }