Skip to content

Commit

Permalink
Update aif example (kserve#3765)
Browse files Browse the repository at this point in the history
* Update aif example

chore:	Update aif explainer example.
	- Bump KServer to 0.13.0, it will bring some library updates, plus, it fixes a few security alerts in this example.
	- update the scikit-learn package name

Signed-off-by: Spolti <[email protected]>

* move the local instructions to the README

Signed-off-by: Spolti <[email protected]>

* empty commit

Signed-off-by: Spolti <[email protected]>

---------

Signed-off-by: Spolti <[email protected]>
  • Loading branch information
spolti authored Aug 11, 2024
1 parent 9632a52 commit a6a061e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
7 changes: 4 additions & 3 deletions docs/samples/explanation/aif/germancredit/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Use the official lightweight Python image.
# https://hub.docker.com/_/python
FROM python:3.7-slim
FROM python:3.10-slim

ENV APP_HOME /app
WORKDIR $APP_HOME
Expand All @@ -13,7 +13,8 @@ RUN pip install --no-cache-dir -r ./requirements.txt
COPY model.py ./

# Copy german-credit data
COPY german.data /usr/local/lib/python3.7/site-packages/aif360/data/raw/german/
COPY german.doc /usr/local/lib/python3.7/site-packages/aif360/data/raw/german/
COPY german.data /usr/local/lib/python3.10/site-packages/aif360/data/raw/german/
COPY german.doc /usr/local/lib/python3.10/site-packages/aif360/data/raw/german/

CMD ["python", "model.py"]

25 changes: 25 additions & 0 deletions docs/samples/explanation/aif/germancredit/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,28 @@ docker push dockeruser/aifserver:latest
```

Once your docker image is pushed you can pull the image from dockeruser/aifserver:latest when deploying an inferenceservice by specifying the image in the yaml file.


# Running the Container Image locally

Replace the **CMD** argument with the following command to run the container locally.

```bash
CMD ["python", "model.py",
"-m", "aifserver",
"--predictor_host", "german-credit-predictor-default.default.svc.cluster.local",
"--model_name", "german-credit",
"--feature_names", "age", "sex", "credit_history=Delay", "credit_history=None/Paid", "credit_history=Other", "savings=500+", "savings=<500", "savings=Unknown/None", "employment=1-4 years", "employment=4+ years", "employment=unemployed",
"--label_names", "credit",
"--favorable_label", "1",
"--unfavorable_label", "2",
"--privileged_groups", "{\"age\": 1}",
"--unprivileged_groups", "{\"age\": 0}"]
```

Once the image is built, you can run the request to test it:

```bash
# make sure you are in the example's root directory where the `query_bias.py` script and the `input.json` file are located.
python query_bias.py http://localhost:8080/v1/models/german-credit:predict input.json
```
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kserve
sklearn
kserve>=0.13.0
scikit-learn
aif360
numba

0 comments on commit a6a061e

Please sign in to comment.