Skip to content

Commit ae96cd2

Browse files
committed
add inspect CLI command
1 parent fbfac88 commit ae96cd2

File tree

3 files changed

+788
-2
lines changed

3 files changed

+788
-2
lines changed

docs/reference/cli.md

Lines changed: 104 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Command Line Interface
22

3-
NetGraph provides a command-line interface for running scenarios and generating results directly from the terminal.
3+
NetGraph provides a command-line interface for inspecting, running, and analyzing scenarios directly from the terminal.
44

55
## Installation
66

@@ -12,7 +12,20 @@ pip install ngraph
1212

1313
## Basic Usage
1414

15-
The primary command is `run`, which executes scenario files:
15+
The CLI provides two primary commands:
16+
17+
- `inspect`: Analyze and validate scenario files without running them
18+
- `run`: Execute scenario files and generate results
19+
20+
### Quick Start
21+
22+
```bash
23+
# Inspect a scenario to understand its structure
24+
python -m ngraph inspect my_scenario.yaml
25+
26+
# Run a scenario after inspection
27+
python -m ngraph run my_scenario.yaml --results
28+
```
1629

1730
```bash
1831
# Run a scenario (execution only, no file output)
@@ -34,6 +47,60 @@ python -m ngraph run scenario.yaml --results --stdout
3447

3548
## Command Reference
3649

50+
### `inspect`
51+
52+
Analyze and validate a NetGraph scenario file without executing it.
53+
54+
**Syntax:**
55+
56+
```bash
57+
python -m ngraph inspect <scenario_file> [options]
58+
```
59+
60+
**Arguments:**
61+
62+
- `scenario_file`: Path to the YAML scenario file to inspect
63+
64+
**Options:**
65+
66+
- `--detail`, `-d`: Show detailed information including complete node/link tables and step parameters
67+
- `--help`, `-h`: Show help message
68+
69+
**What it does:**
70+
71+
The `inspect` command loads and validates a scenario file, then provides information about:
72+
73+
- **Scenario metadata**: Seed configuration and deterministic behavior
74+
- **Network structure**: Node/link counts, enabled/disabled breakdown, hierarchy analysis
75+
- **Capacity statistics**: Link and node capacity analysis with min/max/mean/total values
76+
- **Risk groups**: Network resilience groupings and their status
77+
- **Components library**: Available components for network modeling
78+
- **Failure policies**: Configured failure scenarios and their rules
79+
- **Traffic matrices**: Demand patterns and traffic flows
80+
- **Workflow steps**: Analysis pipeline and step-by-step execution plan
81+
82+
In detail mode (`--detail`), shows complete tables for all nodes and links with capacity and connectivity information.
83+
84+
**Examples:**
85+
86+
```bash
87+
# Basic inspection
88+
python -m ngraph inspect my_scenario.yaml
89+
90+
# Detailed inspection with comprehensive node/link tables and step parameters
91+
python -m ngraph inspect my_scenario.yaml --detail
92+
93+
# Inspect with verbose logging
94+
python -m ngraph inspect my_scenario.yaml --verbose
95+
```
96+
97+
**Use cases:**
98+
99+
- **Scenario validation**: Verify YAML syntax and structure
100+
- **Network debugging**: Analyze blueprint expansion and node/link creation
101+
- **Capacity analysis**: Review network capacity distribution and connectivity
102+
- **Workflow preview**: Examine analysis steps before execution
103+
37104
### `run`
38105

39106
Execute a NetGraph scenario file.
@@ -212,6 +279,41 @@ python -m ngraph run scenario.yaml --results analysis.json --stdout
212279

213280
The CLI executes the complete workflow defined in your scenario file, running all steps in sequence and accumulating results. This automates complex network analysis tasks without manual intervention.
214281

282+
### Recommended Workflow
283+
284+
1. **Inspect first**: Always use `inspect` to validate and understand your scenario
285+
2. **Debug issues**: Use detailed inspection to troubleshoot network expansion problems
286+
3. **Run after validation**: Execute scenarios only after successful inspection
287+
4. **Iterate**: Use inspection during scenario development to verify changes
288+
289+
```bash
290+
# Development workflow
291+
python -m ngraph inspect my_scenario.yaml --detail # Validate and debug
292+
python -m ngraph run my_scenario.yaml --results # Execute after validation
293+
```
294+
295+
### Debugging Scenarios
296+
297+
When developing complex scenarios with blueprints and hierarchical structures:
298+
299+
```bash
300+
# Check if scenario loads correctly
301+
python -m ngraph inspect scenario.yaml
302+
303+
# Debug network expansion issues
304+
python -m ngraph inspect scenario.yaml --detail --verbose
305+
306+
# Verify workflow steps are configured correctly
307+
python -m ngraph inspect scenario.yaml --detail | grep -A 5 "Workflow Steps"
308+
```
309+
310+
The `inspect` command will catch common issues like:
311+
- Invalid YAML syntax
312+
- Missing blueprint references
313+
- Incorrect node/link patterns
314+
- Workflow step configuration errors
315+
- Risk group and policy definition problems
316+
215317
## See Also
216318

217319
- [DSL Reference](dsl.md) - Scenario file syntax and structure

0 commit comments

Comments
 (0)