anhtld commited on
Commit
6e17bd6
·
verified ·
1 Parent(s): 36ff02f

auto-sync 2026-07-04T05:22:54Z workspace (part 4)

Browse files
workspace/scripts/train_utility_energy.py CHANGED
@@ -49,6 +49,11 @@ def main(argv: list[str] | None = None) -> int:
49
  default="base",
50
  help="Deployment-visible chart feature family used by ChartEncoder.",
51
  )
 
 
 
 
 
52
  args = parser.parse_args(argv)
53
 
54
  random.seed(args.seed)
@@ -151,7 +156,7 @@ def main(argv: list[str] | None = None) -> int:
151
  json.dumps(_group_means(rows, "seed", metric_names), indent=2, sort_keys=True) + "\n"
152
  )
153
  (out_dir / "table.tex").write_text(_table(summary) + "\n")
154
- (out_dir / "report.md").write_text(_report(summary) + "\n")
155
  print(json.dumps({"out_dir": str(out_dir), "num_charts": len(charts)}, indent=2))
156
  return 0
157
 
@@ -243,6 +248,19 @@ def _report(summary: dict[str, Any]) -> str:
243
  return "\n".join(lines)
244
 
245
 
 
 
 
 
 
 
 
 
 
 
 
 
 
246
  def _fmt(value: Any) -> str:
247
  return "n/a" if not isinstance(value, (int, float)) or not math.isfinite(value) else f"{value:.4f}"
248
 
 
49
  default="base",
50
  help="Deployment-visible chart feature family used by ChartEncoder.",
51
  )
52
+ parser.add_argument(
53
+ "--no-markdown-report",
54
+ action="store_true",
55
+ help="Do not write report.md; persistent prose is consolidated in README.md.",
56
+ )
57
  args = parser.parse_args(argv)
58
 
59
  random.seed(args.seed)
 
156
  json.dumps(_group_means(rows, "seed", metric_names), indent=2, sort_keys=True) + "\n"
157
  )
158
  (out_dir / "table.tex").write_text(_table(summary) + "\n")
159
+ _write_markdown_report(out_dir, summary, no_markdown_report=args.no_markdown_report)
160
  print(json.dumps({"out_dir": str(out_dir), "num_charts": len(charts)}, indent=2))
161
  return 0
162
 
 
248
  return "\n".join(lines)
249
 
250
 
251
+ def _write_markdown_report(
252
+ out_dir: Path,
253
+ summary: dict[str, Any],
254
+ *,
255
+ no_markdown_report: bool,
256
+ ) -> None:
257
+ report_path = out_dir / "report.md"
258
+ if no_markdown_report:
259
+ report_path.unlink(missing_ok=True)
260
+ return
261
+ report_path.write_text(_report(summary) + "\n")
262
+
263
+
264
  def _fmt(value: Any) -> str:
265
  return "n/a" if not isinstance(value, (int, float)) or not math.isfinite(value) else f"{value:.4f}"
266
 
workspace/tests/test_readme_only_markdown_flags.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from pathlib import Path
4
+
5
+ from scripts import audit_action_bounds
6
+ from scripts import audit_chart_feature_sources
7
+ from scripts import audit_cil_charts
8
+ from scripts import build_action_scale_vector
9
+ from scripts import build_data_accounting
10
+ from scripts import calibrate_dominance
11
+ from scripts import check_tangent_reconstruction
12
+ from scripts import eval_chart_positive_memory_proxy
13
+ from scripts import export_chart_object_embeddings
14
+ from scripts import export_chart_observation_embeddings
15
+ from scripts import train_utility_energy
16
+
17
+
18
+ def test_readme_only_report_helpers_remove_stale_markdown(tmp_path: Path) -> None:
19
+ writers = [
20
+ lambda out: build_data_accounting._write_markdown_report(
21
+ out,
22
+ {},
23
+ no_markdown_report=True,
24
+ ),
25
+ lambda out: audit_cil_charts._write_markdown_report(out, {}, no_markdown_report=True),
26
+ lambda out: check_tangent_reconstruction._write_markdown_report(
27
+ out,
28
+ {},
29
+ no_markdown_report=True,
30
+ ),
31
+ lambda out: audit_chart_feature_sources._write_markdown_report(
32
+ out,
33
+ {},
34
+ no_markdown_report=True,
35
+ ),
36
+ lambda out: audit_action_bounds._write_markdown_report(
37
+ out,
38
+ {},
39
+ no_markdown_report=True,
40
+ ),
41
+ lambda out: export_chart_observation_embeddings._write_markdown_report(
42
+ out,
43
+ {},
44
+ no_markdown_report=True,
45
+ ),
46
+ lambda out: export_chart_object_embeddings._write_markdown_report(
47
+ out,
48
+ {},
49
+ no_markdown_report=True,
50
+ ),
51
+ lambda out: eval_chart_positive_memory_proxy._write_markdown_report(
52
+ out,
53
+ "local_atlas",
54
+ 1,
55
+ {},
56
+ no_markdown_report=True,
57
+ ),
58
+ lambda out: build_action_scale_vector._write_markdown_report(
59
+ out,
60
+ {},
61
+ no_markdown_report=True,
62
+ ),
63
+ lambda out: calibrate_dominance._write_markdown_report(
64
+ out,
65
+ {},
66
+ no_markdown_report=True,
67
+ ),
68
+ lambda out: train_utility_energy._write_markdown_report(
69
+ out,
70
+ {},
71
+ no_markdown_report=True,
72
+ ),
73
+ ]
74
+ for index, writer in enumerate(writers):
75
+ out_dir = tmp_path / f"run_{index}"
76
+ out_dir.mkdir()
77
+ report_path = out_dir / "report.md"
78
+ report_path.write_text("stale\n")
79
+
80
+ writer(out_dir)
81
+
82
+ assert not report_path.exists()