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

03/06 and 05/05 pipelines working #172

Merged
merged 2 commits into from
Apr 9, 2024
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
4 changes: 1 addition & 3 deletions lab-materials/03/06/llm_usage.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import os

from langchain.llms import VLLMOpenAI
from langchain.chains.combine_documents.stuff import StuffDocumentsChain
from langchain.chains import LLMChain
from langchain.prompts import PromptTemplate
from langchain.evaluation import load_evaluator
from langchain.embeddings import HuggingFaceEmbeddings

INFERENCE_SERVER_URL = "http://vllm.llm-hosting.svc.cluster.local:8000"
INFERENCE_SERVER_URL = "http://llm.ic-shared-llm.svc.cluster.local:8000"
MAX_NEW_TOKENS = 512
TOP_P = 0.95
TEMPERATURE = 0.01
Expand Down
19 changes: 10 additions & 9 deletions lab-materials/03/06/sanity_check.pipeline
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@
"kubernetes_shared_mem_size": {},
"kubernetes_tolerations": [],
"mounted_volumes": [],
"runtime_image": "quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-sanity-pipeline:1.0",
"filename": "test_response_quality.py"
},
"label": "",
"ui_data": {
"label": "test_response_quality.py",
"image": "/notebook/robert-serving-test/pipelinetest/static/elyra/python.svg",
"image": "/notebook/user2-auto/my-workbench/static/elyra/python.svg",
"x_pos": 582,
"y_pos": 143,
"description": "Run Python script"
Expand Down Expand Up @@ -77,7 +76,9 @@
"op": "execute-python-node",
"app_data": {
"component_parameters": {
"dependencies": [],
"dependencies": [
"llm_usage.py"
],
"include_subdirectories": false,
"outputs": [
"responsetime_result.json"
Expand All @@ -94,7 +95,7 @@
"label": "",
"ui_data": {
"label": "test_responsetime.py",
"image": "/notebook/robert-serving-test/pipelinetest/static/elyra/python.svg",
"image": "/notebook/user2-auto/my-workbench/static/elyra/python.svg",
"x_pos": 584,
"y_pos": 299,
"description": "Run Python script"
Expand Down Expand Up @@ -152,7 +153,7 @@
"label": "",
"ui_data": {
"label": "test_security.py",
"image": "/notebook/robert-serving-test/pipelinetest/static/elyra/python.svg",
"image": "/notebook/user2-auto/my-workbench/static/elyra/python.svg",
"x_pos": 585,
"y_pos": 437,
"description": "Run Python script"
Expand Down Expand Up @@ -210,7 +211,7 @@
"label": "",
"ui_data": {
"label": "summarize_results.py",
"image": "/notebook/robert-serving-test/pipelinetest/static/elyra/python.svg",
"image": "/notebook/user2-auto/my-workbench/static/elyra/python.svg",
"x_pos": 977,
"y_pos": 295,
"description": "Run Python script"
Expand Down Expand Up @@ -273,14 +274,14 @@
"name": "sanity_check",
"runtime": "Data Science Pipelines",
"pipeline_defaults": {
"kubernetes_shared_mem_size": {},
"kubernetes_pod_labels": [],
"kubernetes_tolerations": [],
"kubernetes_pod_annotations": [],
"kubernetes_shared_mem_size": {},
"kubernetes_pod_labels": [],
"mounted_volumes": [],
"kubernetes_secrets": [],
"env_vars": [],
"runtime_image": "quay.io/modh/runtime-images@sha256:7dd23e58291cad7a0ab4a8e04bda06492f2c027eb33b226358380db58dcdd60b"
"runtime_image": "quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-sanity-pipeline:1.1"
}
}
},
Expand Down
40 changes: 20 additions & 20 deletions lab-materials/03/06/sanity_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
sh -c "mkdir -p ./jupyter-work-dir && cd ./jupyter-work-dir"
sh -c "echo 'Downloading file:///opt/app-root/bin/utils/bootstrapper.py' && curl --fail -H 'Cache-Control: no-cache' -L file:///opt/app-root/bin/utils/bootstrapper.py --output bootstrapper.py"
sh -c "echo 'Downloading file:///opt/app-root/bin/utils/requirements-elyra.txt' && curl --fail -H 'Cache-Control: no-cache' -L file:///opt/app-root/bin/utils/requirements-elyra.txt --output requirements-elyra.txt"
sh -c "python3 -m pip install packaging && python3 -m pip freeze > requirements-current.txt && python3 bootstrapper.py --pipeline-name 'sanity_check' --cos-endpoint 'https://minio-api-robert-serving-test.apps.rhods-internal.61tk.p1.openshiftapps.com' --cos-bucket 'pipeline-bucket' --cos-directory 'sanity_check-0109084010' --cos-dependencies-archive 'test_response_quality-d0510f0c-fc50-42fc-a598-97e26b34ed88.tar.gz' --file 'insurance-claim-processing/lab-materials/03/06/test_response_quality.py' --outputs 'quality_result.json' "
sh -c "python3 -m pip install packaging && python3 -m pip freeze > requirements-current.txt && python3 bootstrapper.py --pipeline-name 'sanity_check' --cos-endpoint 'http://minio.ic-shared-minio.svc:9000' --cos-bucket 'user2' --cos-directory 'sanity_check-0409135238' --cos-dependencies-archive 'test_response_quality-d0510f0c-fc50-42fc-a598-97e26b34ed88.tar.gz' --file 'insurance-claim-processing/lab-materials/03/06/test_response_quality.py' --outputs 'quality_result.json' "
command:
- sh
- -c
Expand All @@ -55,12 +55,12 @@ spec:
valueFrom:
secretKeyRef:
key: AWS_ACCESS_KEY_ID
name: aws-connection-minio-pipeline
name: aws-connection-shared-minio---pipelines
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
key: AWS_SECRET_ACCESS_KEY
name: aws-connection-minio-pipeline
name: aws-connection-shared-minio---pipelines
- name: ELYRA_RUNTIME_ENV
value: kfp
- name: ELYRA_ENABLE_PIPELINE_INFO
Expand All @@ -71,7 +71,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.annotations['pipelines.kubeflow.org/run_name']
image: quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-sanity-pipeline:1.0
image: quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-sanity-pipeline:1.1
stepTemplate:
volumeMounts:
- name: mlpipeline-metrics
Expand All @@ -92,7 +92,7 @@ spec:
elyra/pipeline-source: sanity_check.pipeline
pipelines.kubeflow.org/task_display_name: test_response_quality
pipelines.kubeflow.org/component_spec_digest: '{"name": "Run a file",
"outputs": [], "version": "Run a file@sha256=5358a652664edc3aa96dcbf0002719b8c6b6b4dfa176a48c3c3786c22766358e"}'
"outputs": [], "version": "Run a file@sha256=0ede2ced24a6127c78656498f8e9b13b6b1d1d8e42c8db43354771af59f60488"}'
- name: run-a-file-2
taskSpec:
steps:
Expand All @@ -102,7 +102,7 @@ spec:
sh -c "mkdir -p ./jupyter-work-dir && cd ./jupyter-work-dir"
sh -c "echo 'Downloading file:///opt/app-root/bin/utils/bootstrapper.py' && curl --fail -H 'Cache-Control: no-cache' -L file:///opt/app-root/bin/utils/bootstrapper.py --output bootstrapper.py"
sh -c "echo 'Downloading file:///opt/app-root/bin/utils/requirements-elyra.txt' && curl --fail -H 'Cache-Control: no-cache' -L file:///opt/app-root/bin/utils/requirements-elyra.txt --output requirements-elyra.txt"
sh -c "python3 -m pip install packaging && python3 -m pip freeze > requirements-current.txt && python3 bootstrapper.py --pipeline-name 'sanity_check' --cos-endpoint 'https://minio-api-robert-serving-test.apps.rhods-internal.61tk.p1.openshiftapps.com' --cos-bucket 'pipeline-bucket' --cos-directory 'sanity_check-0109084010' --cos-dependencies-archive 'test_responsetime-c50bb14f-a036-4af1-b5dc-21e48eb80f7f.tar.gz' --file 'insurance-claim-processing/lab-materials/03/06/test_responsetime.py' --outputs 'responsetime_result.json' "
sh -c "python3 -m pip install packaging && python3 -m pip freeze > requirements-current.txt && python3 bootstrapper.py --pipeline-name 'sanity_check' --cos-endpoint 'http://minio.ic-shared-minio.svc:9000' --cos-bucket 'user2' --cos-directory 'sanity_check-0409135238' --cos-dependencies-archive 'test_responsetime-c50bb14f-a036-4af1-b5dc-21e48eb80f7f.tar.gz' --file 'insurance-claim-processing/lab-materials/03/06/test_responsetime.py' --outputs 'responsetime_result.json' "
command:
- sh
- -c
Expand All @@ -111,12 +111,12 @@ spec:
valueFrom:
secretKeyRef:
key: AWS_ACCESS_KEY_ID
name: aws-connection-minio-pipeline
name: aws-connection-shared-minio---pipelines
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
key: AWS_SECRET_ACCESS_KEY
name: aws-connection-minio-pipeline
name: aws-connection-shared-minio---pipelines
- name: ELYRA_RUNTIME_ENV
value: kfp
- name: ELYRA_ENABLE_PIPELINE_INFO
Expand All @@ -127,7 +127,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.annotations['pipelines.kubeflow.org/run_name']
image: quay.io/modh/runtime-images@sha256:7dd23e58291cad7a0ab4a8e04bda06492f2c027eb33b226358380db58dcdd60b
image: quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-sanity-pipeline:1.1
stepTemplate:
volumeMounts:
- name: mlpipeline-metrics
Expand All @@ -148,7 +148,7 @@ spec:
elyra/pipeline-source: sanity_check.pipeline
pipelines.kubeflow.org/task_display_name: test_responsetime
pipelines.kubeflow.org/component_spec_digest: '{"name": "Run a file",
"outputs": [], "version": "Run a file@sha256=3e58a6283faf2610ead4310f242aa11d207880bb328d65d9b80064eac003274c"}'
"outputs": [], "version": "Run a file@sha256=fbcb6cccb2393e957b4b042a22dffff6d92d28a73efb5775c07bb82b7973cdf3"}'
- name: run-a-file-3
taskSpec:
steps:
Expand All @@ -158,7 +158,7 @@ spec:
sh -c "mkdir -p ./jupyter-work-dir && cd ./jupyter-work-dir"
sh -c "echo 'Downloading file:///opt/app-root/bin/utils/bootstrapper.py' && curl --fail -H 'Cache-Control: no-cache' -L file:///opt/app-root/bin/utils/bootstrapper.py --output bootstrapper.py"
sh -c "echo 'Downloading file:///opt/app-root/bin/utils/requirements-elyra.txt' && curl --fail -H 'Cache-Control: no-cache' -L file:///opt/app-root/bin/utils/requirements-elyra.txt --output requirements-elyra.txt"
sh -c "python3 -m pip install packaging && python3 -m pip freeze > requirements-current.txt && python3 bootstrapper.py --pipeline-name 'sanity_check' --cos-endpoint 'https://minio-api-robert-serving-test.apps.rhods-internal.61tk.p1.openshiftapps.com' --cos-bucket 'pipeline-bucket' --cos-directory 'sanity_check-0109084010' --cos-dependencies-archive 'test_security-6b595dc7-afb8-46bb-bf52-7cd695ddafb8.tar.gz' --file 'insurance-claim-processing/lab-materials/03/06/test_security.py' --outputs 'security_result.json' "
sh -c "python3 -m pip install packaging && python3 -m pip freeze > requirements-current.txt && python3 bootstrapper.py --pipeline-name 'sanity_check' --cos-endpoint 'http://minio.ic-shared-minio.svc:9000' --cos-bucket 'user2' --cos-directory 'sanity_check-0409135238' --cos-dependencies-archive 'test_security-6b595dc7-afb8-46bb-bf52-7cd695ddafb8.tar.gz' --file 'insurance-claim-processing/lab-materials/03/06/test_security.py' --outputs 'security_result.json' "
command:
- sh
- -c
Expand All @@ -167,12 +167,12 @@ spec:
valueFrom:
secretKeyRef:
key: AWS_ACCESS_KEY_ID
name: aws-connection-minio-pipeline
name: aws-connection-shared-minio---pipelines
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
key: AWS_SECRET_ACCESS_KEY
name: aws-connection-minio-pipeline
name: aws-connection-shared-minio---pipelines
- name: ELYRA_RUNTIME_ENV
value: kfp
- name: ELYRA_ENABLE_PIPELINE_INFO
Expand All @@ -183,7 +183,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.annotations['pipelines.kubeflow.org/run_name']
image: quay.io/modh/runtime-images@sha256:7dd23e58291cad7a0ab4a8e04bda06492f2c027eb33b226358380db58dcdd60b
image: quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-sanity-pipeline:1.1
stepTemplate:
volumeMounts:
- name: mlpipeline-metrics
Expand All @@ -204,7 +204,7 @@ spec:
elyra/pipeline-source: sanity_check.pipeline
pipelines.kubeflow.org/task_display_name: test_security
pipelines.kubeflow.org/component_spec_digest: '{"name": "Run a file",
"outputs": [], "version": "Run a file@sha256=51651082dff4a766733eb7e70c27fa7c33370a3c14f3af453c03a463d0a64dac"}'
"outputs": [], "version": "Run a file@sha256=911e07386ce6fbae48167dee9e6eb42f31497bc01b0ef69e3d3b40b4d203a6d0"}'
- name: run-a-file-4
taskSpec:
steps:
Expand All @@ -214,7 +214,7 @@ spec:
sh -c "mkdir -p ./jupyter-work-dir && cd ./jupyter-work-dir"
sh -c "echo 'Downloading file:///opt/app-root/bin/utils/bootstrapper.py' && curl --fail -H 'Cache-Control: no-cache' -L file:///opt/app-root/bin/utils/bootstrapper.py --output bootstrapper.py"
sh -c "echo 'Downloading file:///opt/app-root/bin/utils/requirements-elyra.txt' && curl --fail -H 'Cache-Control: no-cache' -L file:///opt/app-root/bin/utils/requirements-elyra.txt --output requirements-elyra.txt"
sh -c "python3 -m pip install packaging && python3 -m pip freeze > requirements-current.txt && python3 bootstrapper.py --pipeline-name 'sanity_check' --cos-endpoint 'https://minio-api-robert-serving-test.apps.rhods-internal.61tk.p1.openshiftapps.com' --cos-bucket 'pipeline-bucket' --cos-directory 'sanity_check-0109084010' --cos-dependencies-archive 'summarize_results-6b99ceae-d124-4758-904a-03e1a49fe56d.tar.gz' --file 'insurance-claim-processing/lab-materials/03/06/summarize_results.py' --inputs 'responsetime_result.json;security_result.json;quality_result.json' --outputs 'results.json' "
sh -c "python3 -m pip install packaging && python3 -m pip freeze > requirements-current.txt && python3 bootstrapper.py --pipeline-name 'sanity_check' --cos-endpoint 'http://minio.ic-shared-minio.svc:9000' --cos-bucket 'user2' --cos-directory 'sanity_check-0409135238' --cos-dependencies-archive 'summarize_results-6b99ceae-d124-4758-904a-03e1a49fe56d.tar.gz' --file 'insurance-claim-processing/lab-materials/03/06/summarize_results.py' --inputs 'responsetime_result.json;security_result.json;quality_result.json' --outputs 'results.json' "
command:
- sh
- -c
Expand All @@ -223,12 +223,12 @@ spec:
valueFrom:
secretKeyRef:
key: AWS_ACCESS_KEY_ID
name: aws-connection-minio-pipeline
name: aws-connection-shared-minio---pipelines
- name: AWS_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
key: AWS_SECRET_ACCESS_KEY
name: aws-connection-minio-pipeline
name: aws-connection-shared-minio---pipelines
- name: ELYRA_RUNTIME_ENV
value: kfp
- name: ELYRA_ENABLE_PIPELINE_INFO
Expand All @@ -239,7 +239,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.annotations['pipelines.kubeflow.org/run_name']
image: quay.io/modh/runtime-images@sha256:7dd23e58291cad7a0ab4a8e04bda06492f2c027eb33b226358380db58dcdd60b
image: quay.io/rh-aiservices-bu/rhoai-lab-insurance-claim-sanity-pipeline:1.1
stepTemplate:
volumeMounts:
- name: mlpipeline-metrics
Expand All @@ -260,7 +260,7 @@ spec:
elyra/pipeline-source: sanity_check.pipeline
pipelines.kubeflow.org/task_display_name: summarize_results
pipelines.kubeflow.org/component_spec_digest: '{"name": "Run a file",
"outputs": [], "version": "Run a file@sha256=bfe6fa070a3ebd821fe5801ef8beb2f710d88a1e58380eb85b169a1b44a5b753"}'
"outputs": [], "version": "Run a file@sha256=710a8e5ea145ddcf52ee1df00cbb79bc030fb9b139970cea9676a461974dcd0e"}'
runAfter:
- run-a-file
- run-a-file-2
Expand Down
14 changes: 7 additions & 7 deletions lab-materials/03/06/test_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
import requests
import json

def test_security(endpoint, expected_serving_sha):
def test_security(endpoint, expected_id,):
response = requests.get(endpoint)

if response.status_code==200:
response_json = response.json()
else:
raise Exception(f"Response status code is {response.status_code}")

if response_json["sha"] != expected_serving_sha:
raise Exception(f"Serving SHA has changed, endpoint may have been tampered with")
if expected_id not in response_json["data"][0]["permission"][0]["id"]:
raise Exception(f"Model ID has changed, model may have been tampered with")

print(f"Security check OK")

with open("security_result.json", "w") as f:
json.dump({
"serving_sha_match": response_json["sha"] == expected_serving_sha
"model_id_match": expected_id in response_json["data"][0]["permission"][0]["id"],
}, f)

if __name__ == '__main__':
info_endpoint = "http://llm.ic-shared-llm.svc.cluster.local:3000" + "/info"
expected_serving_sha = "630800eed37b15c4b0c9eb8e6ab47212026720f7"
test_security(info_endpoint, expected_serving_sha)
info_endpoint = "http://llm.ic-shared-llm.svc.cluster.local:8000" + "/v1/models"
expected_id = "modelperm" #This is just for the demo, in a real scenario you would input the model id here
test_security(info_endpoint, expected_id)
2 changes: 1 addition & 1 deletion lab-materials/05/05-05/.pipeline-envs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LLM_ENDPOINT=http://llm.ic-shared-llm.svc.cluster.local:3000
LLM_ENDPOINT=http://llm.ic-shared-llm.svc.cluster.local:8000
POSTGRES_DB=claimdb
POSTGRES_USER=claimdb
POSTGRES_PASSWORD=claimdb
Expand Down
22 changes: 11 additions & 11 deletions lab-materials/05/05-05/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ def connect(self, config):
conn (psycopg2.extensions.connection): A connection object representing the database connection.
"""
self.logger.info(f"Connecting to PostgreSQL Database...")
try:
conn = psycopg2.connect(
host = config["POSTGRES_HOST"],
dbname = config["POSTGRES_DB"],
user = config["POSTGRES_USER"],
password = config["POSTGRES_PASSWORD"],
port = config["POSTGRES_PORT"]
)
self.logger.info(f"Connection successful!")
except psycopg2.OperationalError as e:
self.logger.info(f"Could not connect to Database: {e}")
# try:
conn = psycopg2.connect(
host = config["POSTGRES_HOST"],
dbname = config["POSTGRES_DB"],
user = config["POSTGRES_USER"],
password = config["POSTGRES_PASSWORD"],
port = config["POSTGRES_PORT"]
)
self.logger.info(f"Connection successful!")
# except psycopg2.OperationalError as e:
# self.logger.info(f"Could not connect to Database: {e}")

return conn

Expand Down
Loading
Loading