Skip to content

Commit 725daaf

Browse files
committed
Logging messages for upgrades and for too-new configs
1 parent f567493 commit 725daaf

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

assigner/config/__init__.py

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

66
from assigner.config.versions import upgrade, validate, ValidationError
77

8+
89
class DuplicateUserError(Exception):
910
pass
1011

12+
1113
def config_context(func):
1214
def wrapper(cmdargs, *args):
1315
with Config(cmdargs.config) as conf:

assigner/config/versions.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import jsonschema
2+
import logging
3+
24
from assigner.config.schemas import SCHEMAS
35
from assigner.config.upgrades import UPGRADES
46

7+
logger = logging.getLogger(__name__)
8+
9+
510
class ValidationError(jsonschema.ValidationError):
611
pass
712

@@ -29,9 +34,17 @@ def upgrade(config):
2934
current = get_version(config)
3035
latest = len(SCHEMAS) - 1
3136

32-
for i in range(current, latest):
33-
config = UPGRADES[i](config)
34-
#validate(config, i + 1)
35-
assert get_version(config) == i + 1
37+
if current > latest:
38+
logger.warning("Configuration version %d is newer than latest known configuration version %d", current, latest)
39+
logger.warning("Is your installation of Assigner up to date?")
40+
logger.warning("Attempting to continue anyway...")
41+
return config
42+
43+
if current != latest:
44+
logger.info("Migrating configuration from version %d to version %d.", current, latest)
45+
46+
for version in range(current, latest):
47+
config = UPGRADES[version](config)
48+
assert get_version(config) == version + 1
3649

3750
return config

0 commit comments

Comments
 (0)