1
1
from abc import ABC , abstractmethod
2
+ import os
2
3
import copy
3
4
import json
4
5
import numpy as np
5
- from typing import Dict , Any , Optional
6
+ from typing import Dict , Any , Optional , Union
6
7
from typing_extensions import Protocol , runtime_checkable
7
8
from alibi_detect .version import __version__
8
9
@@ -153,7 +154,7 @@ def from_config(cls, config: dict):
153
154
detector .config ['meta' ]['version_warning' ] = version_warning
154
155
return detector
155
156
156
- def _set_config (self , inputs ): # TODO - move to BaseDetector once config save/load implemented for non-drift
157
+ def _set_config (self , inputs : dict ): # TODO - move to BaseDetector once config save/load implemented for non-drift
157
158
"""
158
159
Set a detectors `config` attribute upon detector instantiation.
159
160
@@ -218,11 +219,12 @@ class ConfigurableDetector(Detector, Protocol):
218
219
219
220
Used for typing save and load functionality in `alibi_detect.saving.saving`.
220
221
"""
221
- def get_config (self ): ...
222
+ def get_config (self ) -> dict : ...
222
223
223
- def from_config (self ): ...
224
+ @classmethod
225
+ def from_config (cls , config : dict ): ...
224
226
225
- def _set_config (self ): ...
227
+ def _set_config (self , inputs : dict ): ...
226
228
227
229
228
230
@runtime_checkable
@@ -231,9 +233,9 @@ class StatefulDetectorOnline(ConfigurableDetector, Protocol):
231
233
232
234
Used for typing save and load functionality in `alibi_detect.saving.saving`.
233
235
"""
234
- def save_state (self , filepath ): ...
236
+ def save_state (self , filepath : Union [ str , os . PathLike ] ): ...
235
237
236
- def load_state (self , filepath ): ...
238
+ def load_state (self , filepath : Union [ str , os . PathLike ] ): ...
237
239
238
240
239
241
class NumpyEncoder (json .JSONEncoder ):
0 commit comments