Skip to content

Commit

Permalink
Merge branch 'SeldonIO:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
mwm5945 authored Jul 11, 2023
2 parents 54bccd8 + 7e48277 commit 0612d87
Show file tree
Hide file tree
Showing 54 changed files with 2,974 additions and 1,375 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/alibidetect_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Rclone
run: |
wget https://downloads.rclone.org/v1.62.2/rclone-v1.62.2-linux-amd64.zip
unzip rclone-v1.62.2-linux-amd64.zip
mv rclone-v1.62.2-linux-amd64/rclone /usr/local/bin/rclone
- name: Set up Python 3.8
uses: actions/setup-python@v4
with:
Expand Down
11 changes: 0 additions & 11 deletions ci_build_and_push_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,6 @@ function build_push_alibi_explainer {
EXPLAIN_EXIT_VALUE=$?
}

function build_push_storage_initializer {
make \
-C components/storage-initializer \
docker-build \
docker-push
STORAGE_INITIALIZER_EXIT_VALUE=$?
}

function build_push_rclone_storage_initializer {
make \
-C components/rclone-storage-initializer \
Expand Down Expand Up @@ -204,7 +196,6 @@ build_push_mlflowserver
build_push_xgboostserver
build_push_tfproxy
build_push_alibi_explainer
build_push_storage_initializer
build_push_rclone_storage_initializer
build_push_mab
build_push_keras_cifar10
Expand All @@ -228,7 +219,6 @@ echo "SKLEARN_EXIT_VALUE $SKLEARN_EXIT_VALUE"
echo "MLFLOW_EXIT_VALUE $MLFLOW_EXIT_VALUE"
echo "XGBOOST_EXIT_VALUE $XGBOOST_EXIT_VALUE"
echo "TFPROXY_EXIT_VALUE $TFPROXY_EXIT_VALUE"
echo "STORAGE_INITIALIZER_EXIT_VALUE $STORAGE_INITIALIZER_EXIT_VALUE"
echo "RCLONE_STORAGE_INITIALIZER_EXIT_VALUE $RCLONE_STORAGE_INITIALIZER_EXIT_VALUE"
echo "MAB_EXIT_VALUE $MAB_EXIT_VALUE"
echo "CIFAR10_EXIT_VALUE $CIFAR10_EXIT_VALUE"
Expand All @@ -246,7 +236,6 @@ exit $((${PYTHON_EXIT_VALUE} \
+ ${MLFLOW_EXIT_VALUE} \
+ ${XGBOOST_EXIT_VALUE} \
+ ${TFPROXY_EXIT_VALUE} \
+ ${STORAGE_INITIALIZER_EXIT_VALUE} \
+ ${RCLONE_STORAGE_INITIALIZER_EXIT_VALUE} \
+ ${MAB_EXIT_VALUE} \
+ ${CIFAR10_EXIT_VALUE} \
Expand Down
10 changes: 9 additions & 1 deletion components/alibi-detect-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,15 @@ ENV PATH "$POETRY_HOME/bin:$PATH"
ENV POETRY_VIRTUALENVS_CREATE false

# Install the server
## NOTE: Removing explicitly requirements.txt file from subdeps test
## dependencies causing false positives in Snyk.
COPY poetry.lock pyproject.toml ./
COPY _seldon_core ./_seldon_core
RUN poetry install && rm ~/.cache/pip -rf
RUN poetry install && \
rm ~/.cache/pip -rf && \
rm -f /opt/conda/lib/python3.8/site-packages/gslib/vendored/boto/requirements.txt \
/opt/conda/lib/python3.8/site-packages/gslib/vendored/oauth2client/docs/requirements.txt \
/opt/conda/lib/python3.8/site-packages/tests/conda_env/support/requirements.txt

# Add licences
RUN mkdir /licenses
Expand All @@ -64,6 +70,8 @@ COPY version.txt version.txt

FROM base as final
WORKDIR /microservice
ENV RCLONE_CONFIG_GS_TYPE="google cloud storage" \
RCLONE_CONFIG_GS_ANONYMOUS="true"

# mesa-libGL: this is to avoid "ImportError: libGL.so.1" from opencv
RUN microdnf install -y mesa-libGL
Expand Down
23 changes: 1 addition & 22 deletions components/alibi-detect-server/adserver/base/storage.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import os
import sys
import kfserving
import logging
import tempfile
from distutils.util import strtobool
Expand All @@ -17,23 +16,6 @@
rclone = None


def _rclone_enabled():
# IF RCLONE_ENABLED variable set explicitly we read from it
enabled = os.environ.get("RCLONE_ENABLED", None)
if enabled is not None:
return strtobool(enabled)

# Otherwise we determine if Rclone config is provided
for key in os.environ.keys():
if "RCLONE_CONFIG" in key:
return True
else:
return False


RCLONE_ENABLED = _rclone_enabled()


class Rclone:
def __init__(self, cfg_file: str = None):
self.cfg_file = cfg_file
Expand All @@ -57,7 +39,4 @@ def copy(self, src: str, dest: str = None):


def download_model(storage_uri) -> str:
if RCLONE_ENABLED:
return Rclone().copy(storage_uri)
else:
return kfserving.Storage.download(storage_uri)
return Rclone().copy(storage_uri)
9 changes: 9 additions & 0 deletions components/alibi-detect-server/adserver/cd_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ def _append_drift_metrcs(metrics, drift, name):
metric_found = [metric_found]

for i, instance in enumerate(metric_found):
if name == "is_drift":
metrics.append(
{
"key": f"seldon_metric_drift_counter",
"value": instance,
"type": "COUNTER",
"tags": {"index": str(i)},
}
)
metrics.append(
{
"key": f"seldon_metric_drift_{name}",
Expand Down
7 changes: 7 additions & 0 deletions components/alibi-detect-server/adserver/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pytest

@pytest.fixture(autouse=True)
def rclone(monkeypatch):
monkeypatch.setenv("RCLONE_CONFIG_GS_TYPE", "google cloud storage")
monkeypatch.setenv("RCLONE_CONFIG_GS_ANONYMOUS", "true")
yield
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def test_basic(self):
res = ad_model.process_event(req, headers)
self.assertEqual(res.data["data"]["is_drift"], 0)
print(res.metrics)
self.assertEqual(len(res.metrics), 8)
self.assertEqual(len(res.metrics), 9)

def test_batch(self):
model = DummyCDModel()
Expand All @@ -49,7 +49,7 @@ def test_batch(self):

res = ad_model.process_event(req, headers)
self.assertEqual(res.data["data"]["is_drift"], 0)
self.assertEqual(len(res.metrics), 8)
self.assertEqual(len(res.metrics), 9)

res = ad_model.process_event(req, headers)
self.assertEqual(res, None)
Expand Down
Loading

0 comments on commit 0612d87

Please sign in to comment.