Skip to content

Commit ae39fd0

Browse files
committed
Enhance documentation: Add YAML configuration examples for workflow steps and attributes
1 parent ce860b9 commit ae39fd0

File tree

8 files changed

+217
-14
lines changed

8 files changed

+217
-14
lines changed

docs/reference/api-full.md

Lines changed: 108 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ For a curated, example-driven API guide, see **[api.md](api.md)**.
1010
> - **[CLI Reference](cli.md)** - Command-line interface
1111
> - **[DSL Reference](dsl.md)** - YAML syntax guide
1212
13-
**Generated from source code on:** June 14, 2025 at 00:45 UTC
13+
**Generated from source code on:** June 14, 2025 at 01:14 UTC
1414

1515
**Modules auto-discovered:** 39
1616

@@ -1806,6 +1806,18 @@ Base class for all workflow steps.
18061806

18071807
All workflow steps are automatically logged with execution timing information.
18081808

1809+
YAML Configuration:
1810+
```yaml
1811+
workflow:
1812+
- step_type: <StepTypeName>
1813+
name: "optional_step_name" # Optional: Custom name for this step instance
1814+
# ... step-specific parameters ...
1815+
```
1816+
1817+
Attributes:
1818+
name: Optional custom identifier for this workflow step instance,
1819+
used for logging and result storage purposes.
1820+
18091821
**Attributes:**
18101822

18111823
- `name` (str)
@@ -1829,6 +1841,16 @@ A decorator that registers a WorkflowStep subclass under `step_type`.
18291841

18301842
A workflow step that builds a StrictMultiDiGraph from scenario.network.
18311843

1844+
This step converts the scenario's network definition into a graph structure
1845+
suitable for analysis algorithms. No additional parameters are required.
1846+
1847+
YAML Configuration:
1848+
```yaml
1849+
workflow:
1850+
- step_type: BuildGraph
1851+
name: "build_network_graph" # Optional: Custom name for this step
1852+
```
1853+
18321854
**Attributes:**
18331855

18341856
- `name` (str)
@@ -1851,6 +1873,22 @@ A workflow step that samples maximum capacity between node groups across random
18511873
Performs Monte-Carlo analysis by repeatedly applying failures and measuring capacity
18521874
to build statistical envelopes of network resilience.
18531875

1876+
YAML Configuration:
1877+
```yaml
1878+
workflow:
1879+
- step_type: CapacityEnvelopeAnalysis
1880+
name: "capacity_envelope_monte_carlo" # Optional: Custom name for this step
1881+
source_path: "^datacenter/.*" # Regex pattern for source node groups
1882+
sink_path: "^edge/.*" # Regex pattern for sink node groups
1883+
mode: "combine" # "combine" or "pairwise" flow analysis
1884+
failure_policy: "random_failures" # Optional: Named failure policy to use
1885+
iterations: 1000 # Number of Monte-Carlo trials
1886+
parallelism: 4 # Number of parallel worker processes
1887+
shortest_path: false # Use shortest paths only
1888+
flow_placement: "PROPORTIONAL" # Flow placement strategy
1889+
seed: 42 # Optional: Seed for reproducible results
1890+
```
1891+
18541892
Attributes:
18551893
source_path: Regex pattern to select source node groups.
18561894
sink_path: Regex pattern to select sink node groups.
@@ -1890,15 +1928,28 @@ Attributes:
18901928

18911929
A workflow step that probes capacity (max flow) between selected groups of nodes.
18921930

1931+
YAML Configuration:
1932+
```yaml
1933+
workflow:
1934+
- step_type: CapacityProbe
1935+
name: "capacity_probe_analysis" # Optional: Custom name for this step
1936+
source_path: "^datacenter/.*" # Regex pattern to select source node groups
1937+
sink_path: "^edge/.*" # Regex pattern to select sink node groups
1938+
mode: "combine" # "combine" or "pairwise" flow analysis
1939+
probe_reverse: false # Also compute flow in reverse direction
1940+
shortest_path: false # Use shortest paths only
1941+
flow_placement: "PROPORTIONAL" # "PROPORTIONAL" or "EQUAL_BALANCED"
1942+
```
1943+
18931944
Attributes:
1894-
source_path (str): A regex pattern to select source node groups.
1895-
sink_path (str): A regex pattern to select sink node groups.
1896-
mode (str): "combine" or "pairwise" (defaults to "combine").
1945+
source_path: A regex pattern to select source node groups.
1946+
sink_path: A regex pattern to select sink node groups.
1947+
mode: "combine" or "pairwise" (defaults to "combine").
18971948
- "combine": All matched sources form one super-source; all matched sinks form one super-sink.
18981949
- "pairwise": Compute flow for each (source_group, sink_group).
1899-
probe_reverse (bool): If True, also compute flow in the reverse direction (sink→source).
1900-
shortest_path (bool): If True, only use shortest paths when computing flow.
1901-
flow_placement (FlowPlacement): Handling strategy for parallel equal cost paths (default PROPORTIONAL).
1950+
probe_reverse: If True, also compute flow in the reverse direction (sink→source).
1951+
shortest_path: If True, only use shortest paths when computing flow.
1952+
flow_placement: Handling strategy for parallel equal cost paths (default PROPORTIONAL).
19021953

19031954
**Attributes:**
19041955

@@ -1927,6 +1978,21 @@ Stateless mutator applied to a :class:`ngraph.scenario.Scenario`.
19271978

19281979
Subclasses must override :meth:`apply`.
19291980

1981+
Transform-based workflow steps are automatically registered and can be used
1982+
in YAML workflow configurations. Each transform is wrapped as a WorkflowStep
1983+
using the @register_transform decorator.
1984+
1985+
YAML Configuration (Generic):
1986+
```yaml
1987+
workflow:
1988+
- step_type: <TransformName>
1989+
name: "optional_step_name" # Optional: Custom name for this step instance
1990+
# ... transform-specific parameters ...
1991+
```
1992+
1993+
Attributes:
1994+
label: Optional description string for this transform instance.
1995+
19301996
**Methods:**
19311997

19321998
- `apply(self, scenario: 'Scenario') -> 'None'`
@@ -1953,6 +2019,23 @@ Raises:
19532019

19542020
Attach (or create) remote nodes and link them to attachment stripes.
19552021

2022+
YAML Configuration:
2023+
```yaml
2024+
workflow:
2025+
- step_type: DistributeExternalConnectivity
2026+
name: "external_connectivity" # Optional: Custom name for this step
2027+
remote_locations: # List of remote node locations/names
2028+
- "denver"
2029+
- "seattle"
2030+
- "chicago"
2031+
attachment_path: "^datacenter/.*" # Regex pattern for attachment nodes
2032+
stripe_width: 3 # Number of attachment nodes per stripe
2033+
link_count: 2 # Number of links per remote node
2034+
capacity: 100.0 # Capacity per link
2035+
cost: 10.0 # Cost per link
2036+
remote_prefix: "external/" # Prefix for remote node names
2037+
```
2038+
19562039
Args:
19572040
remote_locations: Iterable of node names, e.g. ``["den", "sea"]``.
19582041
attachment_path: Regex matching nodes that accept the links.
@@ -1979,6 +2062,24 @@ Enable *count* disabled nodes that match *path*.
19792062

19802063
Ordering is configurable; default is lexical by node name.
19812064

2065+
YAML Configuration:
2066+
```yaml
2067+
workflow:
2068+
- step_type: EnableNodes
2069+
name: "enable_edge_nodes" # Optional: Custom name for this step
2070+
path: "^edge/.*" # Regex pattern to match nodes to enable
2071+
count: 5 # Number of nodes to enable
2072+
order: "name" # Selection order: "name", "random", or "reverse"
2073+
```
2074+
2075+
Args:
2076+
path: Regex pattern to match disabled nodes that should be enabled.
2077+
count: Number of nodes to enable (must be positive integer).
2078+
order: Selection strategy when multiple nodes match:
2079+
- "name": Sort by node name (lexical order)
2080+
- "reverse": Sort by node name in reverse order
2081+
- "random": Random selection order
2082+
19822083
**Methods:**
19832084

19842085
- `apply(self, scenario: 'Scenario') -> 'None'`

ngraph/transform/base.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,21 @@ class NetworkTransform(abc.ABC):
4545
"""Stateless mutator applied to a :class:`ngraph.scenario.Scenario`.
4646
4747
Subclasses must override :meth:`apply`.
48+
49+
Transform-based workflow steps are automatically registered and can be used
50+
in YAML workflow configurations. Each transform is wrapped as a WorkflowStep
51+
using the @register_transform decorator.
52+
53+
YAML Configuration (Generic):
54+
```yaml
55+
workflow:
56+
- step_type: <TransformName>
57+
name: "optional_step_name" # Optional: Custom name for this step instance
58+
# ... transform-specific parameters ...
59+
```
60+
61+
Attributes:
62+
label: Optional description string for this transform instance.
4863
"""
4964

5065
label: str = ""

ngraph/transform/distribute_external.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ def select(self, index: int, stripes: List[List[Node]]) -> List[Node]:
2323
class DistributeExternalConnectivity(NetworkTransform):
2424
"""Attach (or create) remote nodes and link them to attachment stripes.
2525
26+
YAML Configuration:
27+
```yaml
28+
workflow:
29+
- step_type: DistributeExternalConnectivity
30+
name: "external_connectivity" # Optional: Custom name for this step
31+
remote_locations: # List of remote node locations/names
32+
- "denver"
33+
- "seattle"
34+
- "chicago"
35+
attachment_path: "^datacenter/.*" # Regex pattern for attachment nodes
36+
stripe_width: 3 # Number of attachment nodes per stripe
37+
link_count: 2 # Number of links per remote node
38+
capacity: 100.0 # Capacity per link
39+
cost: 10.0 # Cost per link
40+
remote_prefix: "external/" # Prefix for remote node names
41+
```
42+
2643
Args:
2744
remote_locations: Iterable of node names, e.g. ``["den", "sea"]``.
2845
attachment_path: Regex matching nodes that accept the links.

ngraph/transform/enable_nodes.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,24 @@ class EnableNodesTransform(NetworkTransform):
1212
"""Enable *count* disabled nodes that match *path*.
1313
1414
Ordering is configurable; default is lexical by node name.
15+
16+
YAML Configuration:
17+
```yaml
18+
workflow:
19+
- step_type: EnableNodes
20+
name: "enable_edge_nodes" # Optional: Custom name for this step
21+
path: "^edge/.*" # Regex pattern to match nodes to enable
22+
count: 5 # Number of nodes to enable
23+
order: "name" # Selection order: "name", "random", or "reverse"
24+
```
25+
26+
Args:
27+
path: Regex pattern to match disabled nodes that should be enabled.
28+
count: Number of nodes to enable (must be positive integer).
29+
order: Selection strategy when multiple nodes match:
30+
- "name": Sort by node name (lexical order)
31+
- "reverse": Sort by node name in reverse order
32+
- "random": Random selection order
1533
"""
1634

1735
def __init__(

ngraph/workflow/base.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ class WorkflowStep(ABC):
3131
"""Base class for all workflow steps.
3232
3333
All workflow steps are automatically logged with execution timing information.
34+
35+
YAML Configuration:
36+
```yaml
37+
workflow:
38+
- step_type: <StepTypeName>
39+
name: "optional_step_name" # Optional: Custom name for this step instance
40+
# ... step-specific parameters ...
41+
```
42+
43+
Attributes:
44+
name: Optional custom identifier for this workflow step instance,
45+
used for logging and result storage purposes.
3446
"""
3547

3648
name: str = ""

ngraph/workflow/build_graph.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,18 @@
1111

1212
@dataclass
1313
class BuildGraph(WorkflowStep):
14-
"""A workflow step that builds a StrictMultiDiGraph from scenario.network."""
14+
"""A workflow step that builds a StrictMultiDiGraph from scenario.network.
15+
16+
This step converts the scenario's network definition into a graph structure
17+
suitable for analysis algorithms. No additional parameters are required.
18+
19+
YAML Configuration:
20+
```yaml
21+
workflow:
22+
- step_type: BuildGraph
23+
name: "build_network_graph" # Optional: Custom name for this step
24+
```
25+
"""
1526

1627
def run(self, scenario: Scenario) -> None:
1728
graph = scenario.network.to_strict_multidigraph(add_reverse=True)

ngraph/workflow/capacity_envelope_analysis.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,22 @@ class CapacityEnvelopeAnalysis(WorkflowStep):
131131
Performs Monte-Carlo analysis by repeatedly applying failures and measuring capacity
132132
to build statistical envelopes of network resilience.
133133
134+
YAML Configuration:
135+
```yaml
136+
workflow:
137+
- step_type: CapacityEnvelopeAnalysis
138+
name: "capacity_envelope_monte_carlo" # Optional: Custom name for this step
139+
source_path: "^datacenter/.*" # Regex pattern for source node groups
140+
sink_path: "^edge/.*" # Regex pattern for sink node groups
141+
mode: "combine" # "combine" or "pairwise" flow analysis
142+
failure_policy: "random_failures" # Optional: Named failure policy to use
143+
iterations: 1000 # Number of Monte-Carlo trials
144+
parallelism: 4 # Number of parallel worker processes
145+
shortest_path: false # Use shortest paths only
146+
flow_placement: "PROPORTIONAL" # Flow placement strategy
147+
seed: 42 # Optional: Seed for reproducible results
148+
```
149+
134150
Attributes:
135151
source_path: Regex pattern to select source node groups.
136152
sink_path: Regex pattern to select sink node groups.

ngraph/workflow/capacity_probe.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,28 @@
1414
class CapacityProbe(WorkflowStep):
1515
"""A workflow step that probes capacity (max flow) between selected groups of nodes.
1616
17+
YAML Configuration:
18+
```yaml
19+
workflow:
20+
- step_type: CapacityProbe
21+
name: "capacity_probe_analysis" # Optional: Custom name for this step
22+
source_path: "^datacenter/.*" # Regex pattern to select source node groups
23+
sink_path: "^edge/.*" # Regex pattern to select sink node groups
24+
mode: "combine" # "combine" or "pairwise" flow analysis
25+
probe_reverse: false # Also compute flow in reverse direction
26+
shortest_path: false # Use shortest paths only
27+
flow_placement: "PROPORTIONAL" # "PROPORTIONAL" or "EQUAL_BALANCED"
28+
```
29+
1730
Attributes:
18-
source_path (str): A regex pattern to select source node groups.
19-
sink_path (str): A regex pattern to select sink node groups.
20-
mode (str): "combine" or "pairwise" (defaults to "combine").
31+
source_path: A regex pattern to select source node groups.
32+
sink_path: A regex pattern to select sink node groups.
33+
mode: "combine" or "pairwise" (defaults to "combine").
2134
- "combine": All matched sources form one super-source; all matched sinks form one super-sink.
2235
- "pairwise": Compute flow for each (source_group, sink_group).
23-
probe_reverse (bool): If True, also compute flow in the reverse direction (sink→source).
24-
shortest_path (bool): If True, only use shortest paths when computing flow.
25-
flow_placement (FlowPlacement): Handling strategy for parallel equal cost paths (default PROPORTIONAL).
36+
probe_reverse: If True, also compute flow in the reverse direction (sink→source).
37+
shortest_path: If True, only use shortest paths when computing flow.
38+
flow_placement: Handling strategy for parallel equal cost paths (default PROPORTIONAL).
2639
"""
2740

2841
source_path: str = ""

0 commit comments

Comments
 (0)