Skip to content

Commit 0c3395f

Browse files
author
Ashley Scillitoe
authored
Set x_ref_preprocessed=True during legacy loading (#732)
For patch release v0.10.5
1 parent b7a3b41 commit 0c3395f

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

CHANGELOG.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,9 @@
55
[Full Changelog](https://github.com/SeldonIO/alibi-detect/compare/v0.10.4...v0.10.5)
66

77
### Fixed
8-
- Fixed a bug preventing backward compatibility when loading detectors (containing TensorFlow models) saved with `<v0.10.0`
9-
([#729](https://github.com/SeldonIO/alibi-detect/pull/729)). This bug also meant that detectors (containing TensorFlow models) saved with
10-
`save_detector(..., legacy=True)` in `>=v0.10.0` did not properly obey the legacy file format. The `config.toml` file format used by
11-
default in `>=v0.10.0` is not affected.
8+
- Fixed two bugs preventing backward compatibility when loading detectors saved with `<v0.10.0`
9+
([#729](https://github.com/SeldonIO/alibi-detect/pull/729) and [#732](https://github.com/SeldonIO/alibi-detect/pull/732)). This bug also meant that detectors
10+
saved with `save_detector(..., legacy=True)` in `>=v0.10.0` did not properly obey the legacy file format. The `config.toml` file format used by default in `>=v0.10.0` is unaffected.
1211

1312
## v0.10.4
1413
## [v0.10.4](https://github.com/SeldonIO/alibi-detect/tree/v0.10.4) (2022-10-21)

alibi_detect/saving/tensorflow/_loading.py

+9
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,15 @@ def load_detector_legacy(filepath: Union[str, os.PathLike], suffix: str, **kwarg
233233
# load outlier detector specific parameters
234234
state_dict = dill.load(open(filepath.joinpath(detector_name + suffix), 'rb'))
235235

236+
# Update the drift detector preprocess kwargs if state_dict is from an old alibi-detect version (<v0.10).
237+
# See https://github.com/SeldonIO/alibi-detect/pull/732
238+
if 'kwargs' in state_dict and 'other' in state_dict: # A drift detector if both of these exist
239+
if 'x_ref_preprocessed' not in state_dict['kwargs']: # if already exists then must have been saved w/ >=v0.10
240+
# Set x_ref_preprocessed to True
241+
state_dict['kwargs']['x_ref_preprocessed'] = True
242+
# Move `preprocess_x_ref` from `other` to `kwargs`
243+
state_dict['kwargs']['preprocess_x_ref'] = state_dict['other']['preprocess_x_ref']
244+
236245
# initialize detector
237246
model_dir = filepath.joinpath('model')
238247
detector: Optional[Detector] = None # to avoid mypy errors

0 commit comments

Comments
 (0)