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

Add e2e test for Caikit Nlp Client #1075

Merged
merged 47 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
0d54b3b
add draft of python keywords + test suite file
bdattoma Dec 12, 2023
a8f69c9
upgrade python and add caikit py library
bdattoma Dec 12, 2023
4c2f55a
add temp python code for caikit client
bdattoma Dec 12, 2023
fd411aa
fix typo and add query python kw
bdattoma Dec 15, 2023
034c201
refactor LLM keywords - part 1
bdattoma Dec 19, 2023
fa42e21
refactor llm suites - part 2
bdattoma Dec 19, 2023
cdb025f
first test draft
bdattoma Dec 19, 2023
50e06ca
trim response string before return
bdattoma Dec 19, 2023
9460644
add grpc tls test
bdattoma Dec 19, 2023
7e63c67
fix mtls keyword args
bdattoma Dec 20, 2023
52ff7c7
finalize cert creation script
bdattoma Dec 20, 2023
92bc977
add grpc mtls test
bdattoma Dec 20, 2023
d16fd41
refactor http keywords
bdattoma Dec 20, 2023
a127278
add http without validation test
bdattoma Dec 20, 2023
9cd8503
add client return for future usage
bdattoma Dec 20, 2023
0a8a493
add timeout arg for http query + small refactor
bdattoma Dec 20, 2023
cc5cf51
add http mtls test
bdattoma Dec 20, 2023
6f53fdc
fetch new version of clean up from upstream/master
bdattoma Dec 20, 2023
25438c8
remove temp files
bdattoma Dec 20, 2023
7cfe94a
fix grpc args
bdattoma Dec 21, 2023
d282306
finalize test suite
bdattoma Dec 21, 2023
1194f09
format with black formatter
bdattoma Dec 21, 2023
87ffd76
fix isort
bdattoma Dec 21, 2023
be7be8b
fix dry run action - attempt 1
bdattoma Dec 21, 2023
bd2820e
run caikit-nlp-client tests in jupyter
bdattoma Dec 21, 2023
939b105
Revert "upgrade python and add caikit py library"
bdattoma Dec 21, 2023
2769dac
Revert "fix dry run action - attempt 1"
bdattoma Dec 21, 2023
4a2c9e7
remove caikit nlp cli tests and wrapper
bdattoma Dec 21, 2023
118d31d
add polarion ID
bdattoma Dec 21, 2023
b01b244
fix files list
bdattoma Dec 21, 2023
9b67677
change nb image
bdattoma Dec 22, 2023
c19ff91
remove https from host string
bdattoma Dec 22, 2023
3676453
Merge branch 'master' into f/caikit-py-client
bdattoma Jan 8, 2024
f33a1f7
fix some robocop alerts
bdattoma Jan 8, 2024
247a4bd
fix some robocop alerts - part 2
bdattoma Jan 8, 2024
72b355a
add missing test/keyword documentation
bdattoma Jan 8, 2024
5ba0d5f
disable warnings in jupyter
bdattoma Jan 9, 2024
7729dae
small wait after trigger cell run + final screenshot
bdattoma Jan 9, 2024
4fe113d
remove commented code
bdattoma Jan 9, 2024
c3bf62e
fix post call timeout format
bdattoma Jan 9, 2024
2711dfa
Merge branch 'master' into f/caikit-py-client
bdattoma Jan 9, 2024
256ec83
Merge branch 'master' into f/caikit-py-client
bdattoma Jan 11, 2024
2dca783
Merge branch 'master' into f/caikit-py-client
bdattoma Jan 12, 2024
722ab9e
Merge branch 'master' into f/caikit-py-client
bdattoma Jan 12, 2024
13067ae
Merge branch 'master' into f/caikit-py-client
FedeAlonso Jan 15, 2024
24b3b25
Merge branch 'master' into f/caikit-py-client
bdattoma Jan 15, 2024
1131736
Merge branch 'master' into f/caikit-py-client
bdattoma Jan 15, 2024
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
262 changes: 262 additions & 0 deletions ods_ci/tests/Resources/CLI/ModelServing/caikit-py-query.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,262 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "327091d3-ece5-4ad1-b53f-7ac76c90c355",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"!pip install caikit-nlp-client"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a14fdacb-9641-4782-b1b2-bfa1522a4630",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from caikit_nlp_client import GrpcClient, HttpClient\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8d1b7329-9368-4ec5-8f90-0462f478f031",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"MODEL_ID = os.environ[\"MODEL_ID\"]\n",
"HTTP_HOST = os.environ[\"HTTP_HOST\"]\n",
"GRPC_HOST = os.environ[\"GRPC_HOST\"]\n",
"PORT = os.environ[\"PORT\"]\n",
"QUERY_TEXT = os.environ[\"QUERY_TEXT\"] # text = \"At what temperature does water boil?\"\n",
"EXPECTED_ANSWER = os.environ[\"EXPECTED_ANSWER\"]"
]
},
{
"cell_type": "markdown",
"id": "7d48030c-afec-459b-a5a7-7e69f8f19f72",
"metadata": {},
"source": [
"# HTTP"
]
},
{
"cell_type": "markdown",
"id": "c887b45b-37c2-4bdb-aadf-9d431e3d233a",
"metadata": {},
"source": [
"## skip ssl validation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "68ff80f1-3645-45e5-961a-fe3398c21929",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%%capture --no-display\n",
"http_client = HttpClient(f\"{HTTP_HOST}:{PORT}\", verify=False)\n",
"generated_text = http_client.generate_text(MODEL_ID, QUERY_TEXT)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b134f83a",
"metadata": {},
"outputs": [],
"source": [
"print(generated_text)\n",
"assert generated_text.strip() == EXPECTED_ANSWER.strip()"
]
},
{
"cell_type": "markdown",
"id": "8f3d6e1c-3bdb-43c0-a29a-e2523aa26629",
"metadata": {},
"source": [
"## with TLS cert"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f1aa3f42-837f-4779-b380-eb88a098eb9b",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"http_client = HttpClient(f\"{HTTP_HOST}:{PORT}\", ca_cert_path=\"openshift_ca_istio_knative.crt\")\n",
"generated_text = http_client.generate_text(MODEL_ID, QUERY_TEXT)\n",
"print(generated_text)\n",
"assert generated_text.strip() == EXPECTED_ANSWER.strip()"
]
},
{
"cell_type": "markdown",
"id": "16389c2f-e8c2-4ff7-8d8e-f0b00692a652",
"metadata": {},
"source": [
"## with mTLS"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b86e636e-2793-447b-98d2-42e4098d55d6",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"http_client = HttpClient(f\"{HTTP_HOST}:{PORT}\",\n",
" ca_cert_path=\"openshift_ca_istio_knative.crt\",\n",
" client_cert_path=\"public.crt\",\n",
" client_key_path=\"private.key\")\n",
"generated_text = http_client.generate_text(MODEL_ID, QUERY_TEXT)\n",
"print(generated_text)\n",
"assert generated_text.strip() == EXPECTED_ANSWER.strip()"
]
},
{
"cell_type": "markdown",
"id": "f2a79e67-d235-4dbd-8ade-2bbbcdb4a64d",
"metadata": {},
"source": [
"# gRPC"
]
},
{
"cell_type": "markdown",
"id": "5ff860a8-c2ca-469a-9980-88473763f16e",
"metadata": {},
"source": [
"## skip ssl validation"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c1fc93ef-9e90-4076-84fd-477a57d3b0fe",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%%capture --no-display\n",
"grpc_client = GrpcClient(GRPC_HOST, int(PORT), verify=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3bed4431",
"metadata": {},
"outputs": [],
"source": [
"generated_text = grpc_client.generate_text(MODEL_ID, QUERY_TEXT)\n",
"print(generated_text)\n",
"assert generated_text.strip() == EXPECTED_ANSWER.strip()"
]
},
{
"cell_type": "markdown",
"id": "520b655b-0d18-4a8c-8b05-318d42bacf16",
"metadata": {},
"source": [
"## with TLS cert"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8fce9f84-0f3f-440d-a878-1da4d2050458",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"with open(\"openshift_ca_istio_knative.crt\", \"rb\") as fh:\n",
" ca_cert = fh.read()\n",
"grpc_client = GrpcClient(GRPC_HOST, int(PORT), ca_cert=ca_cert)\n",
"generated_text = grpc_client.generate_text(MODEL_ID, QUERY_TEXT)\n",
"print(generated_text)\n",
"assert generated_text.strip() == EXPECTED_ANSWER.strip()"
]
},
{
"cell_type": "markdown",
"id": "a878ede6-3e6d-49b4-ad14-d73de6a7c927",
"metadata": {},
"source": [
"## with mTLS"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2e708533-53f3-457f-9680-0303779c268b",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"with open(\"openshift_ca_istio_knative.crt\", \"rb\") as fh:\n",
" ca_cert = fh.read()\n",
"with open(\"public.crt\", \"rb\") as fh:\n",
" client_cert = fh.read()\n",
"with open(\"private.key\", \"rb\") as fh:\n",
" client_key = fh.read()\n",
"\n",
"\n",
"grpc_client = GrpcClient(GRPC_HOST, int(PORT), ca_cert=ca_cert, client_cert=client_cert, client_key=client_key)\n",
"generated_text = grpc_client.generate_text(MODEL_ID, QUERY_TEXT)\n",
"print(generated_text)\n",
"assert generated_text.strip() == EXPECTED_ANSWER.strip()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e1d9d6cf-b4ee-4f56-9a95-7e8782c8dd72",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
12 changes: 12 additions & 0 deletions ods_ci/tests/Resources/CLI/ModelServing/gen_client_certs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh

BASE_CERT_DIR=client_certs
mkdir $BASE_CERT_DIR

openssl req -x509 -sha256 -nodes -days 365 -newkey rsa:2048 -subj "/O=Example Inc./CN=myclient.local" -keyout $BASE_CERT_DIR/root.key -out $BASE_CERT_DIR/root.crt

openssl req -nodes -newkey rsa:2048 -subj "/CN=test.myclient.local/O=Example Inc." -keyout $BASE_CERT_DIR/private.key -out $BASE_CERT_DIR/sign_req.csr

openssl x509 -req -days 365 -set_serial 0 -CA $BASE_CERT_DIR/root.crt -CAkey $BASE_CERT_DIR/root.key -in $BASE_CERT_DIR/sign_req.csr -out $BASE_CERT_DIR/public.crt

# openssl x509 -in ${BASE_CERT_DIR}/public.crt -text
Loading
Loading