Skip to content

Commit

Permalink
Set x_ref_preprocessed=True during legacy loading (#732)
Browse files Browse the repository at this point in the history
For patch release v0.10.5
  • Loading branch information
ascillitoe authored Jan 25, 2023
1 parent b7a3b41 commit 0c3395f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
7 changes: 3 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
[Full Changelog](https://github.com/SeldonIO/alibi-detect/compare/v0.10.4...v0.10.5)

### Fixed
- Fixed a bug preventing backward compatibility when loading detectors (containing TensorFlow models) saved with `<v0.10.0`
([#729](https://github.com/SeldonIO/alibi-detect/pull/729)). This bug also meant that detectors (containing TensorFlow models) 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 not affected.
- Fixed two bugs preventing backward compatibility when loading detectors saved with `<v0.10.0`
([#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
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.

## v0.10.4
## [v0.10.4](https://github.com/SeldonIO/alibi-detect/tree/v0.10.4) (2022-10-21)
Expand Down
9 changes: 9 additions & 0 deletions alibi_detect/saving/tensorflow/_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,15 @@ def load_detector_legacy(filepath: Union[str, os.PathLike], suffix: str, **kwarg
# load outlier detector specific parameters
state_dict = dill.load(open(filepath.joinpath(detector_name + suffix), 'rb'))

# Update the drift detector preprocess kwargs if state_dict is from an old alibi-detect version (<v0.10).
# See https://github.com/SeldonIO/alibi-detect/pull/732
if 'kwargs' in state_dict and 'other' in state_dict: # A drift detector if both of these exist
if 'x_ref_preprocessed' not in state_dict['kwargs']: # if already exists then must have been saved w/ >=v0.10
# Set x_ref_preprocessed to True
state_dict['kwargs']['x_ref_preprocessed'] = True
# Move `preprocess_x_ref` from `other` to `kwargs`
state_dict['kwargs']['preprocess_x_ref'] = state_dict['other']['preprocess_x_ref']

# initialize detector
model_dir = filepath.joinpath('model')
detector: Optional[Detector] = None # to avoid mypy errors
Expand Down

0 comments on commit 0c3395f

Please sign in to comment.