Skip to content

Commit 8a09f75

Browse files
ambledclaude
andcommitted
Defer config.py side effects into initialize(), bump version (v0.6.2)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4c9b624 commit 8a09f75

7 files changed

Lines changed: 331 additions & 300 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## [Unreleased]
44

5+
## [0.6.2] - 2026-02-17
6+
7+
### Changed
8+
- Deferred `config.py` import-time side effects into explicit `initialize()` function
9+
510
## [0.6.1] - 2026-02-16
611

712
### Changed

src/wnm/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""A service to manage a cluster of decentralized Autonomi nodes"""
22

3-
__version__ = "0.6.1"
3+
__version__ = "0.6.2"

src/wnm/__main__.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,8 @@
88

99
from sqlalchemy import insert, select
1010

11-
from wnm import __version__
12-
from wnm.config import (
13-
LOCK_FILE,
14-
S,
15-
apply_config_updates,
16-
config_updates,
17-
engine,
18-
machine_config,
19-
options,
20-
)
11+
from wnm import __version__, config
12+
from wnm.config import LOCK_FILE, apply_config_updates
2113
from wnm.decision_engine import DecisionEngine
2214
from wnm.executor import ActionExecutor
2315
from wnm.migration import detect_port_ranges_from_nodes, survey_machine
@@ -69,7 +61,7 @@ def signal_handler(signum, frame):
6961

7062

7163
# Make a decision about what to do (new implementation using DecisionEngine)
72-
def choose_action(machine_config, metrics, dry_run):
64+
def choose_action(machine_config, metrics, dry_run, options, S):
7365
"""Plan and execute actions using DecisionEngine and ActionExecutor.
7466
7567
This function now acts as a thin wrapper around the new decision engine
@@ -79,6 +71,8 @@ def choose_action(machine_config, metrics, dry_run):
7971
machine_config: Machine configuration dictionary
8072
metrics: Current system metrics
8173
dry_run: If True, log actions without executing
74+
options: Parsed CLI options
75+
S: Database session factory
8276
8377
Returns:
8478
Dictionary with execution status
@@ -119,22 +113,22 @@ def choose_action(machine_config, metrics, dry_run):
119113
)
120114

121115
# Use the new DecisionEngine to plan actions
122-
engine = DecisionEngine(
116+
de = DecisionEngine(
123117
machine_config,
124118
metrics,
125119
is_init=is_init,
126120
should_survey_init=should_survey_init,
127121
enable_upgrade=getattr(options, "enable_upgrade", False),
128122
)
129-
actions = engine.plan_actions()
123+
actions = de.plan_actions()
130124

131125
# Log the computed features for debugging
132126
if (
133127
options.show_decisions
134128
or options.v
135129
or logging.getLogger().isEnabledFor(logging.DEBUG)
136130
):
137-
logging.info(json.dumps(engine.get_features(), indent=2))
131+
logging.info(json.dumps(de.get_features(), indent=2))
138132

139133
# Inject transient action delay override into machine_config if provided
140134
# Priority: --interval takes precedence over --this_action_delay
@@ -155,6 +149,15 @@ def choose_action(machine_config, metrics, dry_run):
155149

156150

157151
def main():
152+
config.initialize()
153+
154+
# Bind locals from config module (set by initialize())
155+
options = config.options
156+
S = config.S
157+
engine = config.engine
158+
machine_config = config.machine_config
159+
config_updates = config.config_updates
160+
158161
# Handle --version flag (before any lock file or database checks)
159162
if options.version:
160163
print(f"wnm version {__version__}")
@@ -443,7 +446,7 @@ def main():
443446
count=options.count if hasattr(options, "count") else 1,
444447
)
445448
else:
446-
this_action = choose_action(local_config, metrics, options.dry_run)
449+
this_action = choose_action(local_config, metrics, options.dry_run, options, S)
447450

448451
logging.info("Action: " + json.dumps(this_action, indent=2))
449452

0 commit comments

Comments
 (0)