Skip to content

Commit 08318e8

Browse files
committed
Add YAML configuration examples and integration tests for FailurePolicy
1 parent 4d88244 commit 08318e8

File tree

4 files changed

+652
-72
lines changed

4 files changed

+652
-72
lines changed

docs/reference/api-full.md

Lines changed: 38 additions & 1 deletion
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 16, 2025 at 22:17 UTC
13+
**Generated from source code on:** June 17, 2025 at 01:32 UTC
1414

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

@@ -385,6 +385,43 @@ Large-scale performance:
385385
network hasn't changed. If your network changes between calls,
386386
you should clear the cache or re-initialize the policy.
387387

388+
Example YAML configuration:
389+
```yaml
390+
failure_policy:
391+
attrs:
392+
name: "Texas Grid Outage Scenario"
393+
description: "Regional power grid failure affecting telecom infrastructure"
394+
fail_shared_risk_groups: true
395+
rules:
396+
# Fail all nodes in Texas electrical grid
397+
- entity_scope: "node"
398+
conditions:
399+
- attr: "electric_grid"
400+
operator: "=="
401+
value: "texas"
402+
logic: "and"
403+
rule_type: "all"
404+
405+
# Randomly fail 40% of underground fiber links in affected region
406+
- entity_scope: "link"
407+
conditions:
408+
- attr: "region"
409+
operator: "=="
410+
value: "southwest"
411+
- attr: "installation"
412+
operator: "=="
413+
value: "underground"
414+
logic: "and"
415+
rule_type: "random"
416+
probability: 0.4
417+
418+
# Choose exactly 2 risk groups to fail (e.g., data centers)
419+
- entity_scope: "risk_group"
420+
logic: "any"
421+
rule_type: "choice"
422+
count: 2
423+
```
424+
388425
Attributes:
389426
rules (List[FailureRule]):
390427
A list of FailureRules to apply.

ngraph/failure_policy.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,43 @@ class FailurePolicy:
9494
network hasn't changed. If your network changes between calls,
9595
you should clear the cache or re-initialize the policy.
9696
97+
Example YAML configuration:
98+
```yaml
99+
failure_policy:
100+
attrs:
101+
name: "Texas Grid Outage Scenario"
102+
description: "Regional power grid failure affecting telecom infrastructure"
103+
fail_shared_risk_groups: true
104+
rules:
105+
# Fail all nodes in Texas electrical grid
106+
- entity_scope: "node"
107+
conditions:
108+
- attr: "electric_grid"
109+
operator: "=="
110+
value: "texas"
111+
logic: "and"
112+
rule_type: "all"
113+
114+
# Randomly fail 40% of underground fiber links in affected region
115+
- entity_scope: "link"
116+
conditions:
117+
- attr: "region"
118+
operator: "=="
119+
value: "southwest"
120+
- attr: "installation"
121+
operator: "=="
122+
value: "underground"
123+
logic: "and"
124+
rule_type: "random"
125+
probability: 0.4
126+
127+
# Choose exactly 2 risk groups to fail (e.g., data centers)
128+
- entity_scope: "risk_group"
129+
logic: "any"
130+
rule_type: "choice"
131+
count: 2
132+
```
133+
97134
Attributes:
98135
rules (List[FailureRule]):
99136
A list of FailureRules to apply.

0 commit comments

Comments
 (0)