Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump alibi-detect to 0.8.1 in adserver #3871

Merged
merged 4 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/alibi-detect-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,7 @@ COPY --from=builder /opt/conda /opt/conda
COPY --from=builder /usr/bin/rclone /usr/bin/rclone
COPY --from=builder /licenses /licenses

# This is to have writable numba cache directory
ENV NUMBA_CACHE_DIR /tmp/numba-cache
axsaucedo marked this conversation as resolved.
Show resolved Hide resolved

ENTRYPOINT ["python", "-m", "adserver"]
6 changes: 4 additions & 2 deletions components/alibi-detect-server/adserver/cd_model.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import json
from typing import List, Dict, Optional, Union
from typing import List, Dict, Optional, Union, cast
import logging
import numpy as np
from .numpy_encoder import NumpyEncoder
Expand Down Expand Up @@ -52,7 +52,7 @@ def __init__(
"""
super().__init__(name, storage_uri, model)
self.drift_batch_size = drift_batch_size
self.batch: np.array = None
self.batch: Optional[np.ndarray] = None
self.model: Data = model

def process_event(self, inputs: Union[List, Dict], headers: Dict) -> Optional[ModelResponse]:
Expand Down Expand Up @@ -86,6 +86,8 @@ def process_event(self, inputs: Union[List, Dict], headers: Dict) -> Optional[Mo
else:
self.batch = np.concatenate((self.batch, X))

self.batch = cast(np.ndarray, self.batch)

if self.batch.shape[0] >= self.drift_batch_size:
logging.info(
"Running drift detection. Batch size is %d. Needed %d",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def _extract_list(body: Dict) -> List:
raise Exception("Unknown Seldon payload %s" % body)


def _create_seldon_data_def(array: np.array, ty: SeldonPayload):
def _create_seldon_data_def(array: np.ndarray, ty: SeldonPayload):
datadef = {}
if ty == SeldonPayload.TENSOR:
datadef["tensor"] = {"shape": array.shape, "values": array.ravel().tolist()}
Expand Down
7 changes: 3 additions & 4 deletions components/alibi-detect-server/adserver/protocols/v2.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from http import HTTPStatus
from typing import Dict, List
from typing import Dict, List, Any

import numpy as np
import tornado
Expand All @@ -8,10 +8,9 @@
) # pylint: disable=no-name-in-module


def _create_np_from_v2(data: list, ty: str, shape: list) -> np.array:
npty = np.float
def _create_np_from_v2(data: list, ty: str, shape: list) -> np.ndarray:
if ty == "BOOL":
npty = np.bool
npty: Any = bool
elif ty == "UINT8":
npty = np.uint8
elif ty == "UINT16":
Expand Down
Loading