In this section
- GlobalGrid2050 Catalogue GridAtlas V9 storage · globalgrid2050 / scripts/catalogue_gridatlas_v9.py lines 701–826
- GlobalGrid2050 Test Catalogue GridAtlas V9 test · globalgrid2050 / scripts/test_catalogue_gridatlas_v9.py lines 1–199
- GlobalGrid2050 V6 Add Atlas V8 Dashboard Link storage · globalgrid2050 / scripts/v6_add_atlas_v8_dashboard_link.py lines 1–106
- GlobalGrid2050 V7 Add Atlas V8 Dashboard Link storage · globalgrid2050 / scripts/v7_add_atlas_v8_dashboard_link.py lines 1–106
GlobalGrid2050 Catalogue GridAtlas V9
A Python command-line tool in the scripts folder covering composition and the Renewable Energy Planning Database (REPD) register, using SHA-256, and uses data from the GridAtlas repository.
storageglobalgrid2050 / scripts/catalogue_gridatlas_v9.py · lines 701–826 of 826 (continued from section 501) · Entry point · pattern build_manifest (shared by 2 files)
- What it does
- Defines 28 functions or classes, including ContractError, require, read_bytes, read_text, read_json. Uses libraries __future__, argparse, datetime, hashlib, json. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'gridatlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: the REPD register.
- Inputs & outputs
- In: data source: gridatlas data; JSON file current-v3.json; JSON file live-set.json; JSON file release-manifest.json; JSON file -composition.json; command-line arguments.
- Downstream impact
- It is itself an entry point (Python CLI); no other file was found loading it.
- What it achieves
- It reads bytes (`read_bytes`), reads text (`read_text`) and reads JSON (`read_json`). Compile one verified Grid Atlas V9 pointer into the GlobalGrid catalogue. It reads `live-set.json`. It accepts `--root`, `--pointer-json` and `--release-manifest`.
- Why it matters
- No other file in the estate was found to import it; it is an entry point.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- GlobalGrid2050 — Renewable Energy Planning Database (REPD) Grid Atlas v8 Page (estate URL), GridAtlas — Atlas Page (estate URL), __future__, argparse, datetime, hashlib, json, re, sys, pathlib
- Used by
- none found
- Produces
- ContractError, require, read_bytes, read_text, read_json, sha256_bytes, sha256_text, canonical_json, validate_sha, validate_catalogue_time, validate_upstream, atlas_entry
- Defines here
- path_arg, parser, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/catalogue_gridatlas_v9.py:701-826 · blob 5db93f3fae427922bf267900986f7ab2c772bda3 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
manifest_atlas = manifest.get("atlas")
require(isinstance(manifest_atlas, dict), "Catalogue manifest Atlas record is missing")
for key in (
"resolved_commit",
"pointer_sha256",
"release_manifest_sha256",
"release_id",
"route",
"live_url",
"golden_deep_link",
):
require(manifest_atlas.get(key) == atlas.get(key), f"Catalogue Atlas {key} no longer matches the verified pointer")
entry_line, _ = atlas_entry(atlas)
root_html = read_text(root / "index.html")
require(root_html.count(V8_ENTRY) == 1, "Current root no longer preserves the exact V8 sentinel")
require(root_html.count('./repd_grid_atlasv8/') == 1, "Current root no longer preserves the V8 route exactly once")
require(root_html.count(entry_line) == 1, "Current root does not contain the governed Atlas entry exactly once")
catalogue = manifest.get("catalogue")
require(isinstance(catalogue, dict), "Catalogue output record is missing")
snapshot_rel = catalogue.get("snapshot_index_path")
require(isinstance(snapshot_rel, str), "Catalogue snapshot index path is missing")
expected_snapshot_rel = f"homepage_versions/{release_id}/index.html"
require(snapshot_rel == expected_snapshot_rel, "Catalogue snapshot path is not its timestamped release folder")
snapshot_bytes = read_bytes(root / snapshot_rel)
require(sha256_bytes(snapshot_bytes) == catalogue.get("snapshot_index_sha256"), "Catalogue snapshot SHA-256 is invalid")
snapshot = snapshot_bytes.decode("utf-8")
require('<base href="https://globalgrid2050.com/">' in snapshot, "Catalogue snapshot has no functional root base URL")
require(snapshot.count(entry_line) == 1, "Catalogue snapshot does not contain the Atlas entry exactly once")
require(snapshot.count(V8_ENTRY) == 1, "Catalogue snapshot does not preserve the V8 entry exactly once")
return {
"ok": True,
"release_id": release_id,
"catalogue_generation": generation,
"catalogue_manifest_path": catalogue_manifest.relative_to(root).as_posix(),
"catalogue_manifest_sha256": sha256_bytes(read_bytes(catalogue_manifest)),
"snapshot_index_path": snapshot_rel,
"public_snapshot_url": catalogue.get("public_snapshot_url"),
"atlas_release_id": atlas["release_id"],
"atlas_live_url": atlas["live_url"],
"atlas_golden_deep_link": atlas["golden_deep_link"],
"atlas_release_manifest_sha256": atlas["release_manifest_sha256"],
"v8_public_url": V8_URL,
"root_index_sha256": sha256_text(root_html),
"released_root_index_sha256": catalogue.get("root_index_sha256_at_release"),
"root_has_advanced_since_release": sha256_text(root_html) != catalogue.get("root_index_sha256_at_release"),
}
def path_arg(value: str) -> Path:
return Path(value)
def parser() -> argparse.ArgumentParser:
result = argparse.ArgumentParser(description=__doc__)
subparsers = result.add_subparsers(dest="command", required=True)
apply_parser = subparsers.add_parser("apply", help="Compile and write the bounded catalogue outputs")
apply_parser.add_argument("--root", type=path_arg, default=Path.cwd())
apply_parser.add_argument("--pointer-json", type=path_arg, required=True)
apply_parser.add_argument("--release-manifest", type=path_arg, required=True)
apply_parser.add_argument("--gridatlas-commit", required=True)
apply_parser.add_argument("--base-commit", required=True)
apply_parser.add_argument("--catalogue-generation", required=True)
apply_parser.add_argument("--incepted-at", required=True)
apply_parser.add_argument("--created-at", required=True)
apply_parser.add_argument("--result-json", type=path_arg)
refresh_parser = subparsers.add_parser(
"refresh-composition",
help="Refresh the marked current-composition row identity in place",
)
refresh_parser.add_argument("--root", type=path_arg, default=Path.cwd())
refresh_parser.add_argument("--gridatlas", type=path_arg, required=True)
refresh_parser.add_argument("--check", action="store_true", help="Report the refresh without writing index.html")
refresh_parser.add_argument(
"--notes-current",
action="store_true",
help=(
"Assert that the note's measurement prose already describes the incoming release, so "
"no lag clause is added and any existing one is cleared. Only a human who wrote that "
"prose may pass this; an unattended run must not."
),
)
refresh_parser.add_argument("--result-json", type=path_arg)
verify_parser = subparsers.add_parser("verify", help="Verify committed or staged catalogue bytes")
verify_parser.add_argument("--root", type=path_arg, default=Path.cwd())
verify_parser.add_argument("--catalogue-manifest", type=path_arg, required=True)
verify_parser.add_argument("--pointer-json", type=path_arg, required=True)
verify_parser.add_argument("--release-manifest", type=path_arg, required=True)
verify_parser.add_argument("--gridatlas-commit", required=True)
verify_parser.add_argument("--result-json", type=path_arg)
return result
def main() -> int:
args = parser().parse_args()
try:
if args.command == "apply":
payload = apply_catalogue(args)
elif args.command == "refresh-composition":
payload = refresh_composition(args)
else:
payload = verify_catalogue(
root=args.root,
catalogue_manifest=args.catalogue_manifest,
pointer_json=args.pointer_json,
release_manifest=args.release_manifest,
gridatlas_commit=args.gridatlas_commit,
)
rendered = canonical_json(payload)
if args.result_json:
args.result_json.parent.mkdir(parents=True, exist_ok=True)
args.result_json.write_text(rendered, encoding="utf-8")
sys.stdout.write(rendered)
return 0
except ContractError as exc:
print(f"CATALOGUE CONTRACT FAILURE: {exc}", file=sys.stderr)
return 1
if __name__ == "__main__":
raise SystemExit(main())GlobalGrid2050 Test Catalogue GridAtlas V9
A test in the scripts folder that checks GridAtlas — Atlas Page using data from the GridAtlas repository.
testglobalgrid2050 / scripts/test_catalogue_gridatlas_v9.py · lines 1–199 of 199 · Entry point · pattern composition (shared by 2 files)
- What it does
- It tests transformers. Defines 7 functions or classes, including composition, note_of, Results, __init__, check. Uses libraries __future__, importlib.util, sys, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'gridatlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: transformers.
- Inputs & outputs
- In: data source: gridatlas data.
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 Project Signals Acid Workflow (globalgrid2050).
- What it achieves
- It is built from the composition step (`composition`), the note of helper (`note_of`) and the results class (`Results`). Pin the fail-closed contracts of the Grid Atlas catalogue compiler.
- Why it matters
- Run by GlobalGrid2050 Project Signals Acid Workflow.
- Application
- globalgrid2050 · scripts · test
- Uses
- GridAtlas — Atlas Page (estate URL), __future__, importlib.util, sys, pathlib
- Used by
- run by GlobalGrid2050 Project Signals Acid Workflow (workflow run)
- Produces
- composition, note_of, Results, main
- Defines here
- composition, note_of, Results, __init__, check, refuses, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/test_catalogue_gridatlas_v9.py:1-199 · blob ab6281258f7a58d03892e18c8c044779693d79e5 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: ingest · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""Pin the fail-closed contracts of the Grid Atlas catalogue compiler.
Dependency-free on purpose, like `measure_homepage_version.py`, so it runs in
GitHub Actions and locally with no setup:
python scripts/test_catalogue_gridatlas_v9.py
The fixture below reproduces the exact condition that jammed `compile_root()`
from 30 August: the composition href
`https://ventusltd.github.io/gridatlas/atlas/` occurs THREE times in one file —
the public `os-strip` banner, the governed catalogue row, and the immutable
`.../atlas/releases/202608291239-atlas-v9/` row which contains it as a *prefix*.
Every account of the jam in this estate said "twice"; a substring count says
three. That is why the row is identified by the GRIDATLAS_V9_AUTOMATION markers
and not by its href, and this file exists so that reasoning cannot be quietly
undone later.
"""
from __future__ import annotations
import importlib.util
import sys
from pathlib import Path
MODULE_PATH = Path(__file__).with_name("catalogue_gridatlas_v9.py")
_spec = importlib.util.spec_from_file_location("catalogue_gridatlas_v9", MODULE_PATH)
cg = importlib.util.module_from_spec(_spec)
assert _spec.loader is not None
_spec.loader.exec_module(cg)
ROW = (
' { name:"UK Grid Atlas V9.98 — Current Verified Release", '
'url:"https://ventusltd.github.io/gridatlas/atlas/", '
'note:"CURRENT VERIFIED · v9.98 · 202609032246 · the map opens as the first impression, '
'and the transformer count is a count of machines", '
'data_gridatlas_release:"202609032246-gridatlas-v9.98" }, '
'/* data-gridatlas-release="202609032246-gridatlas-v9.98" */'
)
FIXTURE = "\n".join([
"<html><head>",
"</head><body>",
' <div class="os-strip"><a href="https://ventusltd.github.io/gridatlas/atlas/">'
'UK Grid Atlas V9.86 — Current Verified Release</a>'
'<span class="live-status">202609030200 · verified live</span></div>',
"<script>",
"const AREAS = [",
' { name:"Grid", children:[',
cg.V8_ENTRY,
" /* <!-- GRIDATLAS_V9_AUTOMATION_START --> */",
ROW,
" /* <!-- GRIDATLAS_V9_AUTOMATION_END --> */",
'{ name:"UK Grid Atlas V9 — 202608291239", '
'url:"https://ventusltd.github.io/gridatlas/atlas/releases/202608291239-atlas-v9/", '
'note:"LIVE VERIFIED · immutable timestamped release" },',
" ]},",
"];",
"</script></body></html>",
])
ROW_INDEX = FIXTURE.split("\n").index(ROW)
EDITORIAL = "the map opens as the first impression, and the transformer count is a count of machines"
def composition(generation: str, version: str) -> dict[str, str]:
return {
"generation": generation,
"version": version,
"release_id": f"{generation}-gridatlas-{version}",
"live_url": cg.COMPOSITION_LIVE_URL,
}
LIVE = composition("202609032315", "v9.99")
def note_of(html: str) -> str:
match = cg.COMPOSITION_ROW_RE.match(html.split("\n")[ROW_INDEX])
assert match is not None, "fixture row no longer matches the governed row shape"
return match.group("editorial")
class Results:
def __init__(self) -> None:
self.failures: list[str] = []
def check(self, label: str, ok: bool, detail: str = "") -> None:
if not ok:
self.failures.append(label)
print("%-4s | %s%s" % ("PASS" if ok else "FAIL", label, (" -> " + detail) if detail else ""))
def refuses(self, label: str, html: str, expect_refusal: bool = True,
comp: dict[str, str] | None = None, **kwargs: object) -> None:
try:
cg.refresh_composition_row(html, comp or LIVE, **kwargs) # type: ignore[arg-type]
outcome, refused = "ACCEPTED", False
except cg.ContractError as error:
outcome, refused = "REFUSED: %s" % error, True
self.check(label, refused == expect_refusal, outcome[:88])
def main() -> int:
r = Results()
lines = FIXTURE.split("\n")
print("=== the jam itself ===")
r.check(
"composition href occurs three times, not twice",
FIXTURE.count(cg.COMPOSITION_LIVE_URL) == 3,
"count=%d" % FIXTURE.count(cg.COMPOSITION_LIVE_URL),
)
r.check("markers still isolate exactly one row", cg.marked_row_index(lines) == ROW_INDEX)
r.refuses("a file carrying the duplicate href is ACCEPTED", FIXTURE, expect_refusal=False)
print()
print("=== the sentinel contract ===")
r.refuses("V8 sentinel loses its four leading spaces",
FIXTURE.replace(cg.V8_ENTRY, cg.V8_ENTRY.lstrip()))
r.refuses("V8 route occurs twice",
FIXTURE.replace("</body>", '<a href="./repd_grid_atlasv8/"></a></body>'))
r.refuses("START marker missing", FIXTURE.replace("GRIDATLAS_V9_AUTOMATION_START", "X", 1))
r.refuses("END marker duplicated",
FIXTURE.replace("</body>", "<!-- GRIDATLAS_V9_AUTOMATION_END --></body>"))
two_rows = lines[:]
two_rows.insert(ROW_INDEX + 1, ROW)
r.refuses("two rows inside the marked region", "\n".join(two_rows))
drifted = lines[:]
drifted[ROW_INDEX] = ROW.replace(
'data_gridatlas_release:"202609032246-gridatlas-v9.98"',
'data_gridatlas_release:"202609032222-gridatlas-v9.97"',
)
r.refuses("row identity fields disagree with each other", "\n".join(drifted))
wrong_url = lines[:]
wrong_url[ROW_INDEX] = ROW.replace(
'url:"https://ventusltd.github.io/gridatlas/atlas/"', 'url:"https://example.invalid/"')
r.refuses("row url is not the governed composition URL", "\n".join(wrong_url))
entry_line, _ = cg.atlas_entry({
"generation": "202608291430",
"live_url": "https://ventusltd.github.io/gridatlas/202608291430-atlas-v9/",
})
try:
cg.compile_root(FIXTURE, entry_line, "https://ventusltd.github.io/gridatlas/202608291430-atlas-v9/")
r.check("compile_root refuses to flatten a composition row", False, "it overwrote the row")
except cg.ContractError as error:
r.check("compile_root refuses to flatten a composition row", "composition model" in str(error))
print()
print("=== the refresh ===")
refreshed, changed, report = cg.refresh_composition_row(FIXTURE, LIVE)
after = refreshed.split("\n")
differing = [i for i, (a, b) in enumerate(zip(lines, after)) if a != b]
r.check("exactly one line changes", changed and differing == [ROW_INDEX], "changed lines=%s" % differing)
# The outgoing version legitimately survives inside the lag clause, so the
# assertion is that the four IDENTITY fields moved - not that the string is
# gone from the file.
r.check("all four identity fields move together",
refreshed.count("202609032315-gridatlas-v9.99") == 2
and "V9.99 — Current" in refreshed
and "· v9.99 · 202609032315 ·" in refreshed
and "202609032246" not in refreshed
and "v9.98" not in refreshed.replace("notes written for v9.98 · ", ""))
r.check("os-strip banner untouched", after[2] == lines[2])
r.check("immutable release row untouched", after[ROW_INDEX + 2] == lines[ROW_INDEX + 2])
r.check("idempotent second run reports no change",
cg.refresh_composition_row(refreshed, LIVE)[1] is False)
print()
print("=== the editorial lag, bounded at one generation ===")
r.check("identity moving alone flags the prose",
note_of(refreshed) == "notes written for v9.98 · " + EDITORIAL,
"lag=%s" % report["editorial_lag"])
# A *newer* composition arriving while the prose still lags is the case that
# must stop: it is the second generation of drift, and nobody came back.
NEXT = composition("202609040100", "v10.00")
r.refuses("a second unattended refresh while the flag stands", refreshed, comp=NEXT)
r.refuses("...but --notes-current still lets a human through", refreshed,
expect_refusal=False, comp=NEXT, notes_current=True)
cleared, _, cleared_report = cg.refresh_composition_row(refreshed, LIVE, notes_current=True)
r.check("--notes-current clears the flag and restores the prose",
note_of(cleared) == EDITORIAL and cleared_report["editorial_lag"] is None)
r.check("a run that moves nothing adds no flag",
not note_of(cg.refresh_composition_row(cleared, LIVE)[0]).startswith("notes written for"))
print()
print("RESULT: %d failure(s)" % len(r.failures))
for failure in r.failures:
print(" FAILED: %s" % failure)
return 1 if r.failures else 0
if __name__ == "__main__":
raise SystemExit(main())GlobalGrid2050 V6 Add Atlas V8 Dashboard Link
A Python command-line tool in the scripts folder that reads cables, solar and battery storage (BESS). It is built from the read step (`read`) and the write step (`write`).
storageglobalgrid2050 / scripts/v6_add_atlas_v8_dashboard_link.py · lines 1–106 of 106 · Entry point
- What it does
- It loads cables, solar and battery storage (BESS). Defines read, write, main. Uses libraries __future__, datetime, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'atlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: cables, solar, battery storage (BESS).
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 V6 Add Atlas V8 Dashboard Link Workflow (globalgrid2050).
- What it achieves
- This script does not move or copy the Atlas V8 app.
- Why it matters
- Run by GlobalGrid2050 V6 Add Atlas V8 Dashboard Link Workflow.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- __future__, datetime, pathlib
- Used by
- run by GlobalGrid2050 V6 Add Atlas V8 Dashboard Link Workflow (workflow run)
- Produces
- read, write, main
- Defines here
- read, write, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/v6_add_atlas_v8_dashboard_link.py:1-106 · blob 62f34b08f8e02e0c589ef6a2d66b84412489135c · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""
Add Atlas V8 link to V6 dashboard.
This script does not move or copy the Atlas V8 app.
It only adds a V6 dashboard card and a supporting engineering function note.
"""
from __future__ import annotations
import datetime as dt
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
V6_INDEX = ROOT / "solar-bess-topology-v6" / "index.html"
ATLAS_INDEX = ROOT / "repd_grid_atlasv8" / "index.html"
REPORTS = ROOT / "gridbot_reports"
REPORT = REPORTS / "v6_add_atlas_v8_dashboard_link.md"
ATLAS_CARD = '''
<a class="card" href="../repd_grid_atlasv8/">
<h2>UK Energy Atlas V8</h2>
<p>Standalone UK grid, renewables pipeline and infrastructure atlas for wider spatial and grid screening analysis.</p>
<span>Open app</span>
</a>'''
CARD_MARKER = ''' <a class="card" href="./cable-geometry-visualiser/index.html">
<h2>Cable Geometry Visualiser</h2>
<p>Cable formation, trench, bend and geometry visualiser.</p>
<span>Open app</span>
</a>'''
FUNCTION_ITEM = '''
<div class="function-item"><h3>15. Atlas V8 wider grid analysis</h3><p>Open the standalone Atlas V8 app for wider UK grid, infrastructure, project pipeline and spatial screening analysis alongside the V6 solar BESS tools.</p></div>'''
FUNCTION_MARKER = ''' <div class="function-item"><h3>14. Commercial engineering linkage</h3><p>Connect topology, cable distance, grid proximity and losses to CAPEX, revenue, profit, cashflow and IRR sensitivity.</p></div>'''
def read(path: Path) -> str:
return path.read_text(encoding="utf-8")
def write(path: Path, text: str) -> None:
path.write_text(text, encoding="utf-8")
def main() -> int:
if not V6_INDEX.exists():
raise SystemExit(f"Missing V6 dashboard: {V6_INDEX}")
if not ATLAS_INDEX.exists():
raise SystemExit(f"Missing Atlas V8 app: {ATLAS_INDEX}")
html = read(V6_INDEX)
actions: list[str] = []
if "../repd_grid_atlasv8/" not in html:
if CARD_MARKER not in html:
raise SystemExit("Cable Geometry Visualiser card marker not found in V6 dashboard")
html = html.replace(CARD_MARKER, CARD_MARKER + ATLAS_CARD)
actions.append("Added UK Energy Atlas V8 card after Cable Geometry Visualiser card")
else:
actions.append("Atlas V8 card already present")
if "15. Atlas V8 wider grid analysis" not in html:
if FUNCTION_MARKER not in html:
raise SystemExit("Commercial engineering linkage function marker not found in V6 dashboard")
html = html.replace(FUNCTION_MARKER, FUNCTION_MARKER + FUNCTION_ITEM)
actions.append("Added Atlas V8 wider grid analysis as engineering function 15")
else:
actions.append("Atlas V8 engineering function already present")
write(V6_INDEX, html)
REPORTS.mkdir(parents=True, exist_ok=True)
timestamp = dt.datetime.now(dt.timezone.utc).isoformat()
report = "\n".join([
"# V6 Add Atlas V8 Dashboard Link",
"",
f"UTC created: {timestamp}",
"",
"## Purpose",
"",
"Add a V6 dashboard link to the existing standalone Atlas V8 application without moving or duplicating the Atlas folder.",
"",
"## Target",
"",
"- Dashboard: `solar-bess-topology-v6/index.html`",
"- Linked app: `repd_grid_atlasv8/`",
"",
"## Actions",
"",
*[f"- {action}" for action in actions],
"",
"## Test links",
"",
"- `/solar-bess-topology-v6/`",
"- `/repd_grid_atlasv8/`",
"",
])
write(REPORT, report)
print(f"V6 dashboard Atlas V8 link update complete. Report: {REPORT.relative_to(ROOT)}")
return 0
if __name__ == "__main__":
raise SystemExit(main())GlobalGrid2050 V7 Add Atlas V8 Dashboard Link
A Python command-line tool in the scripts folder that reads cables, solar and battery storage (BESS). It is built from the read step (`read`) and the write step (`write`).
storageglobalgrid2050 / scripts/v7_add_atlas_v8_dashboard_link.py · lines 1–106 of 106 · Entry point
- What it does
- It loads cables, solar and battery storage (BESS). Defines read, write, main. Uses libraries __future__, datetime, pathlib. Side effects: reads or writes files.
- Why it exists in the grid workflow
- Domain stage upstream_foresight (path word 'atlas'): upstream engineering foresight over GB transmission and distribution topology (TSO/DNO, 132kV and above, the REPD pipeline, data centres), which Ventus Ltd states it models for foresight. Domain terms in the code: cables, solar, battery storage (BESS).
- Downstream impact
- Used directly by 1 file: GlobalGrid2050 V7 Add Atlas V8 Dashboard Link Workflow (globalgrid2050).
- What it achieves
- This script does not move or copy the Atlas V8 app.
- Why it matters
- Run by GlobalGrid2050 V7 Add Atlas V8 Dashboard Link Workflow.
- Application
- globalgrid2050 · scripts · Python CLI
- Uses
- __future__, datetime, pathlib
- Used by
- run by GlobalGrid2050 V7 Add Atlas V8 Dashboard Link Workflow (workflow run)
- Produces
- read, write, main
- Defines here
- read, write, main
- Cannot conclude
- Whether this code runs, is used by a live app today, or is correct. This is a static reading.
- Evidence
- globalgrid2050@0aca5121f0795e469b6cf4fc3d3b628edba8d883 scripts/v7_add_atlas_v8_dashboard_link.py:1-106 · blob 0eb6ff8911db33e8a2785bb025a5f4919b23ffd9 · GitHub at these lines
- State
- achieves: comment · context: readme_derived · stage: output · effects: filesystem · domain stage: upstream_foresight · users: IPP_developer, ICP_grid_engineer · canonical: production_core
#!/usr/bin/env python3
"""
Add Atlas V8 link to V7 dashboard.
This script does not move or copy the Atlas V8 app.
It only adds a V7 dashboard card and a supporting engineering function note.
"""
from __future__ import annotations
import datetime as dt
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
V7_INDEX = ROOT / "solar-bess-topology-v7" / "index.html"
ATLAS_INDEX = ROOT / "repd_grid_atlasv8" / "index.html"
REPORTS = ROOT / "gridbot_reports"
REPORT = REPORTS / "v7_add_atlas_v8_dashboard_link.md"
ATLAS_CARD = '''
<a class="card" href="../repd_grid_atlasv8/">
<h2>UK Energy Atlas V8</h2>
<p>Standalone UK grid, renewables pipeline and infrastructure atlas for wider spatial and grid screening analysis.</p>
<span>Open app</span>
</a>'''
CARD_MARKER = ''' <a class="card" href="./cable-geometry-visualiser/index.html">
<h2>Cable Geometry Visualiser</h2>
<p>Cable formation, trench, bend and geometry visualiser.</p>
<span>Open app</span>
</a>'''
FUNCTION_ITEM = '''
<div class="function-item"><h3>15. Atlas V8 wider grid analysis</h3><p>Open the standalone Atlas V8 app for wider UK grid, infrastructure, project pipeline and spatial screening analysis alongside the V7 solar BESS tools.</p></div>'''
FUNCTION_MARKER = ''' <div class="function-item"><h3>14. Commercial engineering linkage</h3><p>Connect topology, cable distance, grid proximity and losses to CAPEX, revenue, profit, cashflow and IRR sensitivity.</p></div>'''
def read(path: Path) -> str:
return path.read_text(encoding="utf-8")
def write(path: Path, text: str) -> None:
path.write_text(text, encoding="utf-8")
def main() -> int:
if not V7_INDEX.exists():
raise SystemExit(f"Missing V7 dashboard: {V7_INDEX}")
if not ATLAS_INDEX.exists():
raise SystemExit(f"Missing Atlas V8 app: {ATLAS_INDEX}")
html = read(V7_INDEX)
actions: list[str] = []
if "../repd_grid_atlasv8/" not in html:
if CARD_MARKER not in html:
raise SystemExit("Cable Geometry Visualiser card marker not found in V7 dashboard")
html = html.replace(CARD_MARKER, CARD_MARKER + ATLAS_CARD)
actions.append("Added UK Energy Atlas V8 card after Cable Geometry Visualiser card")
else:
actions.append("Atlas V8 card already present")
if "15. Atlas V8 wider grid analysis" not in html:
if FUNCTION_MARKER not in html:
raise SystemExit("Commercial engineering linkage function marker not found in V7 dashboard")
html = html.replace(FUNCTION_MARKER, FUNCTION_MARKER + FUNCTION_ITEM)
actions.append("Added Atlas V8 wider grid analysis as engineering function 15")
else:
actions.append("Atlas V8 engineering function already present")
write(V7_INDEX, html)
REPORTS.mkdir(parents=True, exist_ok=True)
timestamp = dt.datetime.now(dt.timezone.utc).isoformat()
report = "\n".join([
"# V7 Add Atlas V8 Dashboard Link",
"",
f"UTC created: {timestamp}",
"",
"## Purpose",
"",
"Add a V7 dashboard link to the existing standalone Atlas V8 application without moving or duplicating the Atlas folder.",
"",
"## Target",
"",
"- Dashboard: `solar-bess-topology-v7/index.html`",
"- Linked app: `repd_grid_atlasv8/`",
"",
"## Actions",
"",
*[f"- {action}" for action in actions],
"",
"## Test links",
"",
"- `/solar-bess-topology-v7/`",
"- `/repd_grid_atlasv8/`",
"",
])
write(REPORT, report)
print(f"V7 dashboard Atlas V8 link update complete. Report: {REPORT.relative_to(ROOT)}")
return 0
if __name__ == "__main__":
raise SystemExit(main())