Skip to content

Commit 2aa6d9c

Browse files
refactor(config): consolidate protection into routing and normalize CLI defaults
Major configuration architecture improvements: - Refactor protection mechanism from separate `protection_mode` setting to `route_method=1plus1_protection` - Normalize all CLI parameter defaults to None for better config file precedence - Move k_paths from general_settings to routing_settings section - Update all example configs, templates, and tests to reflect new structure - Add request tracking infrastructure in SDNController for failure handling - Enhance backup path management in routing properties This change simplifies the configuration model by treating 1+1 protection as a routing method rather than a separate protection layer, making the system more intuitive and reducing configuration complexity. Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 99a09d4 commit 2aa6d9c

43 files changed

Lines changed: 1764 additions & 137 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ python -m fusion.cli.run_sim \
151151
--failure_type geo \
152152
--geo_center_node 5 \
153153
--geo_hop_radius 2 \
154-
--protection_mode 1plus1
154+
--route_method 1plus1_protection
155155
```
156156

157157
### Example Configurations
@@ -174,8 +174,10 @@ failure_type = geo
174174
geo_center_node = 5
175175
geo_hop_radius = 2
176176

177+
[routing_settings]
178+
route_method = 1plus1_protection
179+
177180
[protection_settings]
178-
protection_mode = 1plus1
179181
protection_switchover_ms = 50.0
180182
```
181183

fusion/cli/parameters/analysis.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@ def add_statistics_args(parser: argparse.ArgumentParser) -> None:
2929
stats_group.add_argument(
3030
"--snapshot_step",
3131
type=int,
32-
default=100,
32+
default=None,
3333
help="Number of requests between snapshots",
3434
)
3535
stats_group.add_argument(
3636
"--save_step",
3737
type=int,
38-
default=1000,
38+
default=None,
3939
help="Number of requests between saving results",
4040
)
4141
stats_group.add_argument(
4242
"--print_step",
4343
type=int,
44-
default=1000,
44+
default=None,
4545
help="Number of requests between progress updates",
4646
)
4747
stats_group.add_argument(
@@ -71,7 +71,10 @@ def add_plotting_args(parser: argparse.ArgumentParser) -> None:
7171
)
7272
add_plot_format_args(plot_group)
7373
plot_group.add_argument(
74-
"--plot_dpi", type=int, default=300, help="Resolution (DPI) for generated plots"
74+
"--plot_dpi",
75+
type=int,
76+
default=None,
77+
help="Resolution (DPI) for generated plots",
7578
)
7679
plot_group.add_argument(
7780
"--show_plots",
@@ -97,7 +100,7 @@ def add_export_args(parser: argparse.ArgumentParser) -> None:
97100
"--file_type",
98101
type=str,
99102
choices=["json", "csv", "excel", "tsv"],
100-
default="json",
103+
default=None,
101104
help="Default file format for data export",
102105
)
103106

fusion/cli/parameters/network.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ def add_topology_args(parser: argparse.ArgumentParser) -> None:
2525
help="Network topology name (e.g., 'NSFNet', 'USbackbone60')",
2626
)
2727
network_group.add_argument(
28-
"--cores_per_link", type=int, default=1, help="Number of cores per fiber link"
28+
"--cores_per_link",
29+
type=int,
30+
default=None,
31+
help="Number of cores per fiber link",
2932
)
3033
network_group.add_argument(
3134
"--bw_per_slot",
@@ -96,31 +99,31 @@ def add_spectrum_bands_args(parser: argparse.ArgumentParser) -> None:
9699
spectrum_group.add_argument(
97100
"--c_band",
98101
type=int,
99-
default=96,
102+
default=None,
100103
help="Number of spectral slots in C-band (1530-1565nm)",
101104
)
102105
spectrum_group.add_argument(
103106
"--l_band",
104107
type=int,
105-
default=0,
108+
default=None,
106109
help="Number of spectral slots in L-band (1565-1625nm)",
107110
)
108111
spectrum_group.add_argument(
109112
"--s_band",
110113
type=int,
111-
default=0,
114+
default=None,
112115
help="Number of spectral slots in S-band (1460-1530nm)",
113116
)
114117
spectrum_group.add_argument(
115118
"--e_band",
116119
type=int,
117-
default=0,
120+
default=None,
118121
help="Number of spectral slots in E-band (1360-1460nm)",
119122
)
120123
spectrum_group.add_argument(
121124
"--o_band",
122125
type=int,
123-
default=0,
126+
default=None,
124127
help="Number of spectral slots in O-band (1260-1360nm)",
125128
)
126129

fusion/cli/parameters/routing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def add_routing_args(parser: argparse.ArgumentParser) -> None:
2727
routing_group.add_argument(
2828
"--k_paths",
2929
type=int,
30-
default=3,
30+
default=None,
3131
help="Number of candidate paths for k-shortest path routing",
3232
)
3333

@@ -51,7 +51,7 @@ def add_spectrum_args(parser: argparse.ArgumentParser) -> None:
5151
spectrum_group.add_argument(
5252
"--guard_slots",
5353
type=int,
54-
default=1,
54+
default=None,
5555
help="Number of guard slots between allocations",
5656
)
5757
spectrum_group.add_argument(

fusion/cli/parameters/shared.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@ def add_plot_format_args(
103103
parser.add_argument(
104104
"--plot_format",
105105
type=str,
106-
default="png",
106+
default=None,
107107
help="Output format for generated plots",
108108
)

fusion/cli/parameters/snr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def add_snr_args(parser: argparse.ArgumentParser) -> None:
2828
help="SNR calculation method",
2929
)
3030
parser.add_argument(
31-
"--input_power", type=float, default=1e-3, help="Input power in Watts"
31+
"--input_power", type=float, default=None, help="Input power in Watts"
3232
)
3333
parser.add_argument(
3434
"--egn_model",

fusion/cli/parameters/survivability.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,6 @@ def add_protection_args(parser: argparse.ArgumentParser) -> None:
7979
:type parser: argparse.ArgumentParser
8080
"""
8181
protection_group = parser.add_argument_group("Protection Settings")
82-
protection_group.add_argument(
83-
"--protection_mode",
84-
type=str,
85-
choices=["none", "1plus1"],
86-
default=None,
87-
help="Protection mechanism to use (none, 1plus1)",
88-
)
8982
protection_group.add_argument(
9083
"--protection_switchover_ms",
9184
type=float,

fusion/cli/parameters/training.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,40 +78,40 @@ def add_reinforcement_learning_args(parser: argparse.ArgumentParser) -> None:
7878
rl_group.add_argument(
7979
"--learn_rate",
8080
type=float,
81-
default=0.001,
81+
default=None,
8282
help="Learning rate for RL algorithms",
8383
)
8484
rl_group.add_argument(
85-
"--gamma", type=float, default=0.99, help="Discount factor for future rewards"
85+
"--gamma", type=float, default=None, help="Discount factor for future rewards"
8686
)
8787
rl_group.add_argument(
8888
"--epsilon_start",
8989
type=float,
90-
default=1.0,
90+
default=None,
9191
help="Initial epsilon value for epsilon-greedy exploration",
9292
)
9393
rl_group.add_argument(
9494
"--epsilon_end",
9595
type=float,
96-
default=0.01,
96+
default=None,
9797
help="Final epsilon value for epsilon-greedy exploration",
9898
)
9999
rl_group.add_argument(
100100
"--epsilon_update",
101101
type=str,
102102
choices=["linear", "exponential", "step", "linear_decay", "exp_decay"],
103-
default="linear",
103+
default=None,
104104
help="Epsilon decay strategy",
105105
)
106106

107107
# Reward configuration
108108
rl_group.add_argument(
109-
"--reward", type=float, default=1.0, help="Reward value for successful actions"
109+
"--reward", type=float, default=None, help="Reward value for successful actions"
110110
)
111111
rl_group.add_argument(
112112
"--penalty",
113113
type=float,
114-
default=-1.0,
114+
default=None,
115115
help="Penalty value for unsuccessful actions",
116116
)
117117
rl_group.add_argument(
@@ -147,18 +147,18 @@ def add_feature_extraction_args(parser: argparse.ArgumentParser) -> None:
147147
help="Graph Neural Network architecture type",
148148
)
149149
feature_group.add_argument(
150-
"--layers", type=int, default=3, help="Number of layers in neural network"
150+
"--layers", type=int, default=None, help="Number of layers in neural network"
151151
)
152152
feature_group.add_argument(
153153
"--emb_dim",
154154
type=int,
155-
default=64,
155+
default=None,
156156
help="Embedding dimension for neural networks",
157157
)
158158
feature_group.add_argument(
159159
"--heads",
160160
type=int,
161-
default=8,
161+
default=None,
162162
help="Number of attention heads (for attention-based models)",
163163
)
164164
feature_group.add_argument(
@@ -203,7 +203,7 @@ def add_machine_learning_args(parser: argparse.ArgumentParser) -> None:
203203
ml_group.add_argument(
204204
"--test_size",
205205
type=float,
206-
default=0.2,
206+
default=None,
207207
help="Fraction of data to use for testing (0.0-1.0)",
208208
)
209209
ml_group.add_argument(
@@ -238,20 +238,20 @@ def add_optimization_args(parser: argparse.ArgumentParser) -> None:
238238
opt_group.add_argument(
239239
"--optuna_trials",
240240
type=int,
241-
default=100,
241+
default=None,
242242
help="Number of optimization trials for Optuna",
243243
)
244244
opt_group.add_argument(
245245
"--n_trials",
246246
type=int,
247-
default=10,
247+
default=None,
248248
help="Number of trials for grid search or random search",
249249
)
250250
opt_group.add_argument(
251251
"--device",
252252
type=str,
253253
choices=["cpu", "cuda", "mps", "auto"],
254-
default="auto",
254+
default=None,
255255
help="Computing device for training (cpu/gpu)",
256256
)
257257

fusion/configs/cli_to_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self) -> None:
4343
"num_requests": ("general_settings", "num_requests"),
4444
"request_distribution": ("general_settings", "request_distribution"),
4545
"allocation_method": ("general_settings", "allocation_method"),
46-
"k_paths": ("general_settings", "k_paths"),
46+
"k_paths": ("routing_settings", "k_paths"),
4747
"route_method": ("general_settings", "route_method"),
4848
"save_snapshots": ("general_settings", "save_snapshots"),
4949
"snapshot_step": ("general_settings", "snapshot_step"),

fusion/configs/examples/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,10 @@ python -m fusion.cli.run_sim run_sim --config_path fusion/configs/examples/datas
100100

101101
### Protection Settings
102102

103+
**Note:** Enable 1+1 protection by setting `route_method=1plus1_protection` in routing settings.
104+
103105
| Parameter | Values | Description |
104106
|-----------|--------|-------------|
105-
| `protection_mode` | `none`, `1plus1` | Protection mechanism |
106107
| `protection_switchover_ms` | Float | Switchover latency (ms) |
107108
| `restoration_latency_ms` | Float | Re-routing latency (ms) |
108109
| `revert_to_primary` | Boolean | Revert after repair |

0 commit comments

Comments
 (0)