Skip to content

Commit c83d279

Browse files
committed
scripts and scenarios
1 parent feb8e6e commit c83d279

13 files changed

Lines changed: 404 additions & 21 deletions

examples/backbone_baseline.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ visualization:
8585
use_real_geometry: true
8686
site_graph:
8787
export: true
88+
blueprints:
89+
export: true
8890

8991
traffic:
9092
enabled: true

examples/backbone_clos.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ visualization:
8585
use_real_geometry: true
8686
site_graph:
8787
export: true
88+
blueprints:
89+
export: true
8890

8991
traffic:
9092
enabled: true

examples/backbone_slimfly.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ visualization:
8585
use_real_geometry: true
8686
site_graph:
8787
export: true
88+
blueprints:
89+
export: true
8890

8991
traffic:
9092
enabled: true

examples/backbone_slimfly_spine.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ visualization:
8585
use_real_geometry: true
8686
site_graph:
8787
export: true
88+
blueprints:
89+
export: true
8890

8991
traffic:
9092
enabled: true

examples/small_test_baseline.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ visualization:
7373
use_real_geometry: true
7474
site_graph:
7575
export: true
76+
blueprints:
77+
export: true
7678

7779
traffic:
7880
enabled: true

examples/small_test_clos.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ visualization:
7373
use_real_geometry: true
7474
site_graph:
7575
export: true
76+
blueprints:
77+
export: true
7678

7779
traffic:
7880
enabled: true

examples/small_test_slimfly.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ visualization:
7373
use_real_geometry: true
7474
site_graph:
7575
export: true
76+
blueprints:
77+
export: true
7678

7779
traffic:
7880
enabled: true

examples/small_test_slimfly_spine.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ visualization:
7373
use_real_geometry: true
7474
site_graph:
7575
export: true
76+
blueprints:
77+
export: true
7678

7779
traffic:
7880
enabled: true

run.sh

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
# Behavior:
1616
# - Recursively finds *_scenario.yml / *_scenario.yaml files under <root_dir>.
1717
# - For each scenario, runs in its directory:
18-
# ngraph inspect <file> → writes notebook/artifacts (tool-defined)
19-
# ngraph run <file> → writes results JSON (tool-defined)
20-
# ngraph report --html <file> → writes HTML report (tool-defined)
18+
# ngraph inspect -o <dir> <file>
19+
# ngraph run -o <dir> <file>
20+
# ngraph report -o <dir> <results.json> --html --notebook <path>
2121
# - Logs for each step are saved next to the scenario file:
2222
# <stem>.inspect.log, <stem>.run.log, <stem>.report.log
2323
# - If --force is not set and cached artifacts are found (results JSON + HTML),
@@ -63,7 +63,7 @@ EOF
6363
}
6464

6565
ARGS=()
66-
while [[ $# > 0 ]]; do
66+
while [[ $# -gt 0 ]]; do
6767
case "$1" in
6868
--include)
6969
shift || true
@@ -146,8 +146,8 @@ passes_filters() {
146146

147147
has_cached() {
148148
# Cached if expected results and HTML report exist
149-
local dir="$1"; local stem="$2"
150-
if [[ -f "$dir/$stem.json" && -f "$dir/$stem.html" ]]; then
149+
local dir="$1"; local results_prefix="$2"
150+
if [[ -f "$dir/$results_prefix.json" && -f "$dir/$results_prefix.html" ]]; then
151151
return 0
152152
fi
153153
return 1
@@ -176,6 +176,10 @@ while IFS= read -r -d '' scn; do
176176
scn_dir=$(cd "$(dirname -- "$scn")" && pwd)
177177
scn_base_noext=${scn_name%.*}
178178
scn_stem=${scn_base_noext}
179+
results_prefix="$scn_stem.results"
180+
results_json="$scn_dir/$results_prefix.json"
181+
html_path="$scn_dir/$results_prefix.html"
182+
ipynb_path="$scn_dir/$results_prefix.ipynb"
179183

180184
echo "➡️ Scenario: $scn_name"
181185
echo " 📁 Dir: $scn_dir"
@@ -184,31 +188,26 @@ while IFS= read -r -d '' scn; do
184188
log_run="$scn_dir/$scn_stem.run.log"
185189
log_rep="$scn_dir/$scn_stem.report.log"
186190

187-
if [[ "$FORCE" == "false" ]] && has_cached "$scn_dir" "$scn_stem"; then
191+
if [[ "$FORCE" == "false" ]] && has_cached "$scn_dir" "$results_prefix"; then
188192
echo "⏭️ Cached: results + report found, skipping"
189193
ins_status="⏭️ cached"; run_status="⏭️ cached"; rep_status="⏭️ cached"
190194
ins_cached=$((ins_cached + 1))
191195
run_cached=$((run_cached + 1))
192196
rep_cached=$((rep_cached + 1))
193197
else
194198
# Inspect
195-
(cd "$scn_dir" && "${NGRAPH_INVOKE[@]}" inspect "$scn_abs") 2>&1 | tee "$log_ins"
199+
(cd "$scn_dir" && "${NGRAPH_INVOKE[@]}" inspect -o "$scn_dir" "$scn_abs") 2>&1 | tee "$log_ins"
196200
ins_ec=${PIPESTATUS[0]}
197201
if [[ $ins_ec -eq 0 ]]; then
198202
ins_status=""; ins_ok=$((ins_ok + 1))
199203
# Run
200-
(cd "$scn_dir" && "${NGRAPH_INVOKE[@]}" run "$scn_abs") 2>&1 | tee "$log_run"
204+
(cd "$scn_dir" && "${NGRAPH_INVOKE[@]}" run -o "$scn_dir" -r "$results_json" "$scn_abs") 2>&1 | tee "$log_run"
201205
run_ec=${PIPESTATUS[0]}
202206
if [[ $run_ec -eq 0 ]]; then
203207
run_status=""; run_ok=$((run_ok + 1))
204208
# Report
205-
results_json="$scn_dir/$scn_stem.json"
206-
# If the default name was not used, fallback to results.json
207-
if [[ ! -f "$results_json" && -f "$scn_dir/results.json" ]]; then
208-
results_json="$scn_dir/results.json"
209-
fi
210-
# Generate both HTML and Notebook deterministically named after the scenario stem
211-
(cd "$scn_dir" && "${NGRAPH_INVOKE[@]}" report "$results_json" --html "$scn_dir/$scn_stem.html" --notebook "$scn_dir/$scn_stem.ipynb") 2>&1 | tee "$log_rep"
209+
# Generate both HTML and Notebook under the scenario directory using the results-derived prefix
210+
(cd "$scn_dir" && "${NGRAPH_INVOKE[@]}" report -o "$scn_dir" "$results_json" --html "$html_path" --notebook "$ipynb_path") 2>&1 | tee "$log_rep"
212211
rep_ec=${PIPESTATUS[0]}
213212
if [[ $rep_ec -eq 0 ]]; then
214213
rep_status=""; rep_ok=$((rep_ok + 1))

topogen/config.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,8 @@ class TopologyConfig:
492492
_export_site_graph: bool = False
493493
_visualization_dpi: int = 300
494494
_source_path: Path | None = None
495+
# Export per-blueprint abstract+concrete diagrams
496+
_export_blueprint_diagrams: bool = False
495497
# Optional instrumentation fields for debugging/export
496498
_debug_dir: Path | None = None
497499
_source_stem: str | None = None
@@ -1007,6 +1009,13 @@ def _from_dict(cls, config_dict: dict[str, Any]) -> TopologyConfig:
10071009
"'visualization.site_graph' must be a dictionary if provided"
10081010
)
10091011
export_site_graph = bool(vis_site.get("export", False))
1012+
# Optional per-blueprint diagram export
1013+
vis_blueprints = vis.get("blueprints", {}) or {}
1014+
if not isinstance(vis_blueprints, dict):
1015+
raise ValueError(
1016+
"'visualization.blueprints' must be a dictionary if provided"
1017+
)
1018+
export_blueprints = bool(vis_blueprints.get("export", False))
10101019
# Optional global visualization DPI
10111020
dpi_val = vis.get("dpi", 300)
10121021
try:
@@ -1035,6 +1044,7 @@ def _from_dict(cls, config_dict: dict[str, Any]) -> TopologyConfig:
10351044
cfg._use_real_corridor_geometry = use_real_geometry
10361045
cfg._export_site_graph = export_site_graph
10371046
cfg._visualization_dpi = visualization_dpi
1047+
cfg._export_blueprint_diagrams = export_blueprints
10381048
return cfg
10391049

10401050
def validate(self) -> None:

0 commit comments

Comments
 (0)