Skip to content

Commit c6e78fc

Browse files
author
Ashley Scillitoe
authored
Remove config_spec versioning (#641)
1 parent 0bf6de9 commit c6e78fc

File tree

7 files changed

+6
-31
lines changed

7 files changed

+6
-31
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ See the [documentation](https://docs.seldon.io/projects/alibi-detect/en/latest/c
1010

1111
### Changed
1212
- Minimum `prophet` version bumped to `1.1.0` (used by `OutlierProphet`). This upgrade removes the dependency on `pystan` as `cmdstanpy` is used instead. This version also comes with pre-built wheels for all major platforms and Python versions, making both installation and testing easier ([#627](https://github.com/SeldonIO/alibi-detect/pull/627)).
13+
- **Breaking change** The configuration field `config_spec` has been removed. In order to load detectors serialized from previous Alibi Detect versions, the field will need to be deleted from the detector's `config.toml` file. However, in any case, serialization compatibility across Alibi Detect versions is not currently guranteed. ([#641](https://github.com/SeldonIO/alibi-detect/pull/641)).
14+
1315

1416
### Development
1517
- UTF-8 decoding is enforced when `README.md` is opened by `setup.py`. This is to prevent pip install errors on systems with `PYTHONIOENCODING` set to use other encoders ([#605](https://github.com/SeldonIO/alibi-detect/pull/605)).

alibi_detect/base.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55
from typing import Dict, Any, Optional
66
from typing_extensions import Protocol, runtime_checkable
7-
from alibi_detect.version import __version__, __config_spec__
7+
from alibi_detect.version import __version__
88

99

1010
DEFAULT_META = {
@@ -173,7 +173,6 @@ def _set_config(self, inputs): # TODO - move to BaseDetector once config save/l
173173
'name': name,
174174
'meta': {
175175
'version': __version__,
176-
'config_spec': __config_spec__,
177176
}
178177
}
179178

alibi_detect/saving/schemas.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ class Config:
8888

8989
class MetaData(CustomBaseModel):
9090
version: str
91-
config_spec: str
9291
version_warning: bool = False
9392

9493

alibi_detect/saving/tests/test_validate.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
from alibi_detect.saving import validate_config
66
from alibi_detect.saving.saving import X_REF_FILENAME
7-
from alibi_detect.version import __config_spec__, __version__
7+
from alibi_detect.version import __version__
88
from copy import deepcopy
99

1010
# Define a detector config dict
1111
mmd_cfg = {
1212
'meta': {
1313
'version': __version__,
14-
'config_spec': __config_spec__,
1514
},
1615
'name': 'MMDDrift',
1716
'x_ref': np.array([[-0.30074928], [1.50240758], [0.43135768], [2.11295779], [0.79684913]]),
@@ -32,7 +31,6 @@ def test_validate_config(cfg):
3231
# Check cfg is returned with correct metadata
3332
meta = cfg_full.get('meta') # pop as don't want to compare meta to cfg in next bit
3433
assert meta['version'] == __version__
35-
assert meta['config_spec'] == __config_spec__
3634
assert not meta.pop('version_warning') # pop this one to remove from next check
3735

3836
# Check remaining values of items in cfg unchanged
@@ -45,19 +43,13 @@ def test_validate_config(cfg):
4543
_ = validate_config(cfg_unres)
4644
assert not cfg.get('meta').get('version_warning')
4745

48-
# Check warning raised and warning field added if version or config_spec different
46+
# Check warning raised and warning field added if version different
4947
cfg_err = cfg.copy()
5048
cfg_err['meta']['version'] = '0.1.x'
5149
with pytest.warns(Warning): # error will be raised if a warning IS NOT raised
5250
cfg_err = validate_config(cfg_err, resolved=True)
5351
assert cfg_err.get('meta').get('version_warning')
5452

55-
cfg_err = cfg.copy()
56-
cfg_err['meta']['config_spec'] = '0.x'
57-
with pytest.warns(Warning): # error will be raised if a warning IS NOT raised
58-
cfg_err = validate_config(cfg_err, resolved=True)
59-
assert cfg_err.get('meta').get('version_warning')
60-
6153
# Check ValueError raised if name unrecognised
6254
cfg_err = cfg.copy()
6355
cfg_err['name'] = 'MMDDriftWrong'

alibi_detect/saving/validate.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from alibi_detect.saving.schemas import ( # type: ignore[attr-defined]
44
DETECTOR_CONFIGS, DETECTOR_CONFIGS_RESOLVED)
5-
from alibi_detect.version import __config_spec__, __version__
5+
from alibi_detect.version import __version__
66

77

88
def validate_config(cfg: dict, resolved: bool = False) -> dict:
@@ -41,7 +41,6 @@ def validate_config(cfg: dict, resolved: bool = False) -> dict:
4141
meta = {} if meta is None else meta # Needed because pydantic sets meta=None if it is missing from the config
4242
version_warning = meta.get('version_warning', False)
4343
version = meta.get('version', None)
44-
config_spec = meta.get('config_spec', None)
4544

4645
# Raise warning if config file already contains a version_warning
4746
if version_warning:
@@ -54,11 +53,4 @@ def validate_config(cfg: dict, resolved: bool = False) -> dict:
5453
f'{__version__}. This may lead to breaking code or invalid results.')
5554
cfg['meta'].update({'version_warning': True})
5655

57-
# Check config specification version
58-
if config_spec is not None and config_spec != __config_spec__:
59-
warnings.warn(f'Config has specification {version} when the installed '
60-
f'alibi-detect version expects specification {__config_spec__}.'
61-
'This may lead to breaking code or invalid results.')
62-
cfg['meta'].update({'version_warning': True})
63-
6456
return cfg

alibi_detect/version.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,3 @@
33
# 2) we can import it in setup.py for the same reason
44
# 3) we can import it into your module module
55
__version__ = "0.10.4dev"
6-
7-
# Define the config specification version. This is distinct to the library version above. It is only updated when
8-
# any detector config schema is updated, such that loading a previous config spec cannot be guaranteed to work.
9-
# The minor version number is associated with minor changes such as adding/removing/changing kwarg's, whilst the major
10-
# number is reserved for significant changes to the config layout.
11-
__config_spec__ = "0.1"

doc/source/overview/config_files.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,9 +461,6 @@ artefacts before attempting the sometimes time-consuming operation of instantiat
461461
%```python
462462
%{'name': {'title': 'Name', 'type': 'string'},
463463
% 'version': {'title': 'Version', 'default': '0.8.1dev', 'type': 'string'},
464-
% 'config_spec': {'title': 'Config Spec',
465-
% 'default': '0.1.0dev',
466-
% 'type': 'string'},
467464
% 'backend': {'title': 'Backend',
468465
% 'default': 'tensorflow',
469466
% 'enum': ['tensorflow', 'pytorch'],

0 commit comments

Comments
 (0)