@@ -120,12 +120,6 @@ class FailurePolicy:
120120 4) Collect the union of all failed entities across all rules.
121121 5) Optionally expand failures by shared-risk groups or sub-risks.
122122
123- Large-scale performance:
124- - If you set `use_cache=True`, matched sets for each rule are cached,
125- so repeated calls to `apply_failures` can skip re-matching if the
126- network hasn't changed. If your network changes between calls,
127- you should clear the cache or re-initialize the policy.
128-
129123 Example YAML configuration:
130124 ```yaml
131125 failure_policy:
@@ -173,10 +167,6 @@ class FailurePolicy:
173167 fail_risk_group_children (bool):
174168 If True, and if a risk_group is marked as failed, expand to
175169 children risk_groups recursively.
176- use_cache (bool):
177- If True, match results for each rule are cached to speed up
178- repeated calls. If the network changes, the cached results
179- may be stale.
180170 seed (Optional[int]):
181171 Seed for reproducible random operations. If None, operations
182172 will be non-deterministic.
@@ -186,13 +176,9 @@ class FailurePolicy:
186176 attrs : Dict [str , Any ] = field (default_factory = dict )
187177 fail_risk_groups : bool = False
188178 fail_risk_group_children : bool = False
189- use_cache : bool = False
190179 seed : Optional [int ] = None
191180 modes : List [FailureMode ] = field (default_factory = list )
192181
193- # Internal cache for matched sets: (rule_index -> set_of_entities)
194- _match_cache : Dict [int , Set [str ]] = field (default_factory = dict , init = False )
195-
196182 def apply_failures (
197183 self ,
198184 network_nodes : Dict [str , Any ],
@@ -286,9 +272,6 @@ def _match_scope(
286272 """Get the set of IDs matched by the given rule, either from cache
287273 or by performing a fresh match over the relevant entity type.
288274 """
289- if self .use_cache and rule_idx in self ._match_cache :
290- return self ._match_cache [rule_idx ]
291-
292275 # Decide which mapping to iterate
293276 if rule .entity_scope == "node" :
294277 matched = self ._match_entities (network_nodes , rule .conditions , rule .logic )
@@ -298,9 +281,6 @@ def _match_scope(
298281 matched = self ._match_entities (
299282 network_risk_groups , rule .conditions , rule .logic
300283 )
301-
302- if self .use_cache :
303- self ._match_cache [rule_idx ] = matched
304284 return matched
305285
306286 def _match_entities (
@@ -610,7 +590,6 @@ def to_dict(self) -> Dict[str, Any]:
610590 "attrs" : self .attrs ,
611591 "fail_risk_groups" : self .fail_risk_groups ,
612592 "fail_risk_group_children" : self .fail_risk_group_children ,
613- "use_cache" : self .use_cache ,
614593 "seed" : self .seed ,
615594 }
616595 if self .modes :
0 commit comments