Skip to content

Commit fe4053e

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 5e204d3 commit fe4053e

File tree

10 files changed

+90
-23
lines changed

10 files changed

+90
-23
lines changed

CodeGen/openshift-rhoai/manifests/README.md

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,21 @@
22

33
## Prerequisites
44

5-
1. **Red Hat OpenShift Cluster** with dynamic *StorageClass* to provision *PersistentVolumes* e.g. **OpenShift Data Foundation**) and installed Operators: **Red Hat - Authorino (Technical Preview)**, **Red Hat OpenShift Service Mesh**, **Red Hat OpenShift Serverless** and **Red Hat Openshift AI**.
5+
1. **Red Hat OpenShift Cluster** with dynamic _StorageClass_ to provision _PersistentVolumes_ e.g. **OpenShift Data Foundation**) and installed Operators: **Red Hat - Authorino (Technical Preview)**, **Red Hat OpenShift Service Mesh**, **Red Hat OpenShift Serverless** and **Red Hat Openshift AI**.
66
2. Exposed image registry to push there docker images (https://docs.openshift.com/container-platform/4.16/registry/securing-exposing-registry.html).
77
3. Access to S3-compatible object storage bucket (e.g. **OpenShift Data Foundation**, **AWS S3**) and values of access and secret access keys and S3 endpoint (https://docs.redhat.com/en/documentation/red_hat_openshift_data_foundation/4.16/html/managing_hybrid_and_multicloud_resources/accessing-the-multicloud-object-gateway-with-your-applications_rhodf#accessing-the-multicloud-object-gateway-with-your-applications_rhodf)\
8-
4. Account on https://huggingface.co/, access to model _ise-uiuc/Magicoder-S-DS-6.7B_ (for Xeon) or _meta-llama/CodeLlama-7b-hf_ (for Gaudi) and token with _Read permissions_. Update the access token in your repository using following commands.
8+
4. Account on https://huggingface.co/, access to model _ise-uiuc/Magicoder-S-DS-6.7B_ (for Xeon) or _meta-llama/CodeLlama-7b-hf_ (for Gaudi) and token with _Read permissions_. Update the access token in your repository using following commands.
99

1010
On Xeon:
11+
1112
```
1213
cd GenAIExamples/CodeGen/openshift-rhoai/manifests/xeon
1314
export HFTOKEN="YourOwnToken"
1415
sed -i "s/insert-your-huggingface-token-here/${HFTOKEN}/g" codegen.yaml servingruntime-magicoder.yaml
1516
```
1617

1718
On Gaudi:
19+
1820
```
1921
cd GenAIExamples/CodeGen/openshift-rhoai/manifests/gaudi
2022
export HFTOKEN="YourOwnToken"
@@ -26,35 +28,42 @@ sed -i "s/insert-your-huggingface-token-here/${HFTOKEN}/g" codegen.yaml servingr
2628
1. Log in to OpenShift CLI and run following commands to create new serving runtime.
2729

2830
On Xeon:
31+
2932
```
3033
cd GenAIExamples/CodeGen/openshift-rhoai/manifests/xeon
3134
oc apply -f servingruntime-magicoder.yaml
3235
```
3336

3437
On Gaudi:
38+
3539
```
3640
cd GenAIExamples/CodeGen/openshift-rhoai/manifests/gaudi
3741
oc apply -f servingruntime-codellama.yaml
3842
```
3943

40-
Verify if template has been created with ```oc get template -n redhat-ods-applications``` command.
44+
Verify if template has been created with `oc get template -n redhat-ods-applications` command.
4145

4246
2. Find the route for **Red Hat OpenShift AI** dashboard with below command and open it in the browser:
47+
4348
```
4449
oc get routes -A | grep rhods-dashboard
4550
```
46-
3. Go to **Data Science Project** and clik **Create data science project**. Fill the **Name** and click **Create**.
47-
4. Go to **Workbenches** tab and clik **Create workbench**. Fill the **Name**, under **Notebook image** choose *Standard Data Science*, under **Cluster storage** choose *Create new persistent storage* and change **Persistent storage size** to 40 GB. Click **Create workbench**.
51+
52+
3. Go to **Data Science Project** and click **Create data science project**. Fill the **Name** and click **Create**.
53+
4. Go to **Workbenches** tab and click **Create workbench**. Fill the **Name**, under **Notebook image** choose _Standard Data Science_, under **Cluster storage** choose _Create new persistent storage_ and change **Persistent storage size** to 40 GB. Click **Create workbench**.
4854
5. Open newly created Jupiter notebook and run following commands to download the model and upload it on s3:
55+
4956
```
5057
%env S3_ENDPOINT=<S3_RGW_ROUTE>
5158
%env S3_ACCESS_KEY=<AWS_ACCESS_KEY_ID>
5259
%env S3_SECRET_KEY=<AWS_SECRET_ACCESS_KEY>
5360
%env HF_TOKEN=<PASTE_HUGGINGFACE_TOKEN>
5461
```
62+
5563
```
5664
!pip install huggingface-hub
5765
```
66+
5867
```
5968
import os
6069
import boto3
@@ -75,41 +84,52 @@ s3_resource = session.resource('s3',
7584
aws_secret_access_key=s3_secretkey)
7685
bucket = s3_resource.Bucket(bucket_name)
7786
```
78-
For Xeon download *ise-uiuc/Magicoder-S-DS-6.7B*:
87+
88+
For Xeon download _ise-uiuc/Magicoder-S-DS-6.7B_:
89+
7990
```
8091
snapshot_download("ise-uiuc/Magicoder-S-DS-6.7B", cache_dir=f'./models', token=hf_token)
8192
```
82-
For Gaudi download *meta-llama/CodeLlama-7b-hf*:
93+
94+
For Gaudi download _meta-llama/CodeLlama-7b-hf_:
95+
8396
```
8497
snapshot_download("meta-llama/CodeLlama-7b-hf", cache_dir=f'./models', token=hf_token)
8598
```
99+
86100
Upload the downloaded model to S3:
101+
87102
```
88103
files = (file for file in glob.glob(f'{path}/**/*', recursive=True) if os.path.isfile(file) and "snapshots" in file)
89104
for filename in files:
90105
s3_name = filename.replace(path, '')
91106
print(f'Uploading: {filename} to {path}{s3_name}')
92107
bucket.upload_file(filename, f'{path}{s3_name}')
93108
```
94-
6. Go to your project in **Red Hat OpenShift AI** dashboard, then "Models" tab and click **Deploy model** under *Single-model serving platform*. Fill the **Name**, choose newly created **Serving runtime**: *Text Generation Inference Magicoder-S-DS-6.7B on CPU* (for Xeon) or *Text Generation Inference CodeLlama-7b-hf on Gaudi* (for Gaudi), **Model framework**: *llm* and change **Model server size** to *Custom*: 16 CPUs and 64 Gi memory. For deployment with Gaudi select proper **Accelerator**. Click the checkbox to create external route in **Model route** section and uncheck the token authentication. Under **Model location** choose *New data connection* and fill all required fields for s3 access, **Bucket** *first.bucket* and **Path**: *models*. Click **Deploy**. It takes about 10 minutes to get *Loaded* status.\
95-
If it's not going to *Loaded* status and revision changed status to "ProgressDeadlineExceeded" (``oc get revision``), scale model deployment to 0 and than to 1 with command ``oc scale deployment.apps/<model_deployment_name> --replicas=1`` and wait about 10 minutes for deployment.
109+
110+
6. Go to your project in **Red Hat OpenShift AI** dashboard, then "Models" tab and click **Deploy model** under _Single-model serving platform_. Fill the **Name**, choose newly created **Serving runtime**: _Text Generation Inference Magicoder-S-DS-6.7B on CPU_ (for Xeon) or _Text Generation Inference CodeLlama-7b-hf on Gaudi_ (for Gaudi), **Model framework**: _llm_ and change **Model server size** to _Custom_: 16 CPUs and 64 Gi memory. For deployment with Gaudi select proper **Accelerator**. Click the checkbox to create external route in **Model route** section and uncheck the token authentication. Under **Model location** choose _New data connection_ and fill all required fields for s3 access, **Bucket** _first.bucket_ and **Path**: _models_. Click **Deploy**. It takes about 10 minutes to get _Loaded_ status.\
111+
If it's not going to _Loaded_ status and revision changed status to "ProgressDeadlineExceeded" (`oc get revision`), scale model deployment to 0 and than to 1 with command `oc scale deployment.apps/<model_deployment_name> --replicas=1` and wait about 10 minutes for deployment.
96112

97113
## Deploy CodeGen
98114

99115
1. Login to OpenShift CLI, go to your project and find the URL of TGI_LLM_ENDPOINT:
116+
100117
```
101118
oc get service.serving.knative.dev
102119
```
120+
103121
Update the TGI_LLM_ENDPOINT in your repository.
104122

105123
On Xeon:
124+
106125
```
107126
cd GenAIExamples/CodeGen/openshift-rhoai/manifests/xeon
108127
export TGI_LLM_ENDPOINT="YourURL"
109128
sed -i "s#insert-your-tgi-url-here#${TGI_LLM_ENDPOINT}#g" codegen.yaml
110129
```
111130

112131
On Gaudi:
132+
113133
```
114134
cd GenAIExamples/CodeGen/openshift-rhoai/manifests/gaudi
115135
export TGI_LLM_ENDPOINT="YourURL"
@@ -119,22 +139,28 @@ sed -i "s#insert-your-tgi-url-here#${TGI_LLM_ENDPOINT}#g" codegen.yaml
119139
2. Build docker images locally
120140

121141
- LLM Docker Image:
142+
122143
```
123144
git clone https://github.com/opea-project/GenAIComps.git
124145
cd GenAIComps
125146
docker build -t opea/llm-tgi:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/llms/text-generation/tgi/Dockerfile .
126147
```
148+
127149
- MegaService Docker Image:
150+
128151
```
129152
git clone https://github.com/opea-project/GenAIExamples
130153
cd GenAIExamples/CodeGen
131154
docker build -t opea/codegen:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile .
132155
```
156+
133157
- UI Docker Image:
158+
134159
```
135160
cd GenAIExamples/CodeGen/ui
136161
docker build -t opea/codegen-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f ./docker/Dockerfile .
137162
```
163+
138164
To verify run the command: `docker images`.
139165

140166
3. Login to docker, tag the images and push it to image registry with following commands:
@@ -144,11 +170,13 @@ docker login -u <user> -p $(oc whoami -t) <openshift-image-registry_route>
144170
docker tag <image_id> <openshift-image-registry_route>/<namespace>/<image_name>:<tag>
145171
docker push <openshift-image-registry_route>/<namespace>/<image_name>:<tag>
146172
```
173+
147174
To verify run the command: `oc get istag`.
148175

149-
4. Use the *IMAGE REFERENCE* from previous step to update images names in manifest files.
176+
4. Use the _IMAGE REFERENCE_ from previous step to update images names in manifest files.
150177

151178
On Xeon:
179+
152180
```
153181
cd GenAIExamples/CodeGen/openshift-rhoai/manifests/xeon
154182
export IMAGE_LLM_TGI="YourImage"
@@ -160,6 +188,7 @@ sed -i "s#insert-your-image-codegen-ui#${IMAGE_CODEGEN_UI}#g" ui-server.yaml
160188
```
161189

162190
On Gaudi:
191+
163192
```
164193
cd GenAIExamples/CodeGen/openshift-rhoai/manifests/gaudi
165194
export IMAGE_LLM_TGI="YourImage"
@@ -170,33 +199,38 @@ sed -i "s#insert-your-image-codegen#${IMAGE_CODEGEN}#g" codegen.yaml
170199
sed -i "s#insert-your-image-codegen-ui#${IMAGE_CODEGEN_UI}#g" ui-server.yaml
171200
```
172201

173-
5. Create *rhoai-ca-bundle* secret:
202+
5. Create _rhoai-ca-bundle_ secret:
203+
174204
```
175205
oc create secret generic rhoai-ca-bundle --from-literal=tls.crt="$(oc extract secret/knative-serving-cert -n istio-system --to=- --keys=tls.crt)"
176206
```
177207

178208
6. Deploy CodeGen with command:
209+
179210
```
180211
oc apply -f codegen.yaml
181212
```
182213

183-
7. Check the *codegen* route with command `oc get routes` and update the route in *ui-server.yaml* file:
214+
7. Check the _codegen_ route with command `oc get routes` and update the route in _ui-server.yaml_ file:
184215

185216
On Xeon:
217+
186218
```
187219
cd GenAIExamples/CodeGen/openshift-rhoai/manifests/xeon
188220
export CODEGEN_ROUTE="YourCodegenRoute"
189221
sed -i "s/insert-your-codegen-route/${CODEGEN_ROUTE}/g" ui-server.yaml
190222
```
191223

192224
On Gaudi:
225+
193226
```
194227
cd GenAIExamples/CodeGen/openshift-rhoai/manifests/gaudi
195228
export CODEGEN_ROUTE="YourCodegenRoute"
196229
sed -i "s/insert-your-codegen-route/${CODEGEN_ROUTE}/g" ui-server.yaml
197230
```
198231

199232
8. Deploy UI with command:
233+
200234
```
201235
oc apply -f ui-server.yaml
202236
```
@@ -214,4 +248,4 @@ curl http://${CODEGEN_ROUTE}/v1/codegen -H "Content-Type: application/json" -d '
214248

215249
## Launch the UI
216250

217-
To access the frontend, find the route for *ui-server* with command `oc get routes` and open it in the browser.
251+
To access the frontend, find the route for _ui-server_ with command `oc get routes` and open it in the browser.

CodeGen/openshift-rhoai/manifests/gaudi/servingruntime-codellama.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
14
---
25
apiVersion: template.openshift.io/v1
36
kind: Template

CodeGen/openshift-rhoai/manifests/gaudi/ui-server.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
14
apiVersion: apps/v1
25
kind: Deployment
36
metadata:

CodeGen/openshift-rhoai/manifests/xeon/servingruntime-magicoder.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
14
---
25
apiVersion: template.openshift.io/v1
36
kind: Template

CodeGen/openshift-rhoai/manifests/xeon/ui-server.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
14
apiVersion: apps/v1
25
kind: Deployment
36
metadata:

CodeGen/openshift/manifests/README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22

33
## Prerequisites
44

5-
1. **Red Hat OpenShift Cluster** with dynamic *StorageClass* to provision *PersistentVolumes* e.g. **OpenShift Data Foundation**)
5+
1. **Red Hat OpenShift Cluster** with dynamic _StorageClass_ to provision _PersistentVolumes_ e.g. **OpenShift Data Foundation**)
66
2. Exposed image registry to push there docker images (https://docs.openshift.com/container-platform/4.16/registry/securing-exposing-registry.html).
7-
3. Account on https://huggingface.co/, access to model *ise-uiuc/Magicoder-S-DS-6.7B* (for Xeon) or *meta-llama/CodeLlama-7b-hf* (for Gaugi) and token with _Read permissions_. Update the access token in your repository using following commands.
7+
3. Account on https://huggingface.co/, access to model _ise-uiuc/Magicoder-S-DS-6.7B_ (for Xeon) or _meta-llama/CodeLlama-7b-hf_ (for Gaugi) and token with _Read permissions_. Update the access token in your repository using following commands.
88

99
On Xeon:
10+
1011
```
1112
cd GenAIExamples/CodeGen/openshift/manifests/xeon
1213
export HFTOKEN="YourOwnToken"
1314
sed -i "s/insert-your-huggingface-token-here/${HFTOKEN}/g" codegen.yaml
1415
```
1516

1617
On Gaudi:
18+
1719
```
1820
cd GenAIExamples/CodeGen/openshift/manifests/gaudi
1921
export HFTOKEN="YourOwnToken"
@@ -25,22 +27,28 @@ sed -i "s/insert-your-huggingface-token-here/${HFTOKEN}/g" codegen.yaml
2527
1. Build docker images locally
2628

2729
- LLM Docker Image:
30+
2831
```
2932
git clone https://github.com/opea-project/GenAIComps.git
3033
cd GenAIComps
3134
docker build -t opea/llm-tgi:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f comps/llms/text-generation/tgi/Dockerfile .
3235
```
36+
3337
- MegaService Docker Image:
38+
3439
```
3540
git clone https://github.com/opea-project/GenAIExamples
3641
cd GenAIExamples/CodeGen
3742
docker build -t opea/codegen:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f Dockerfile .
3843
```
44+
3945
- UI Docker Image:
46+
4047
```
4148
cd GenAIExamples/CodeGen/ui
4249
docker build -t opea/codegen-ui:latest --build-arg https_proxy=$https_proxy --build-arg http_proxy=$http_proxy -f ./docker/Dockerfile .
4350
```
51+
4452
To verify run the command: `docker images`.
4553

4654
2. Login to docker, tag the images and push it to image registry with following commands:
@@ -50,11 +58,13 @@ docker login -u <user> -p $(oc whoami -t) <openshift-image-registry_route>
5058
docker tag <image_id> <openshift-image-registry_route>/<namespace>/<image_name>:<tag>
5159
docker push <openshift-image-registry_route>/<namespace>/<image_name>:<tag>
5260
```
61+
5362
To verify run the command: `oc get istag`.
5463

5564
3. Update images names in manifest files.
5665

5766
On Xeon:
67+
5868
```
5969
cd GenAIExamples/CodeGen/openshift/manifests/xeon
6070
export IMAGE_LLM_TGI="YourImage"
@@ -66,6 +76,7 @@ sed -i "s#insert-your-image-codegen-ui#${IMAGE_CODEGEN_UI}#g" ui-server.yaml
6676
```
6777

6878
On Gaudi:
79+
6980
```
7081
cd GenAIExamples/CodeGen/openshift/manifests/gaudi
7182
export IMAGE_LLM_TGI="YourImage"
@@ -77,27 +88,31 @@ sed -i "s#insert-your-image-codegen-ui#${IMAGE_CODEGEN_UI}#g" ui-server.yaml
7788
```
7889

7990
4. Deploy CodeGen with command:
91+
8092
```
8193
oc apply -f codegen.yaml
8294
```
8395

84-
5. Check the *codegen* route with command `oc get routes` and update the route in *ui-server.yaml* file.
96+
5. Check the _codegen_ route with command `oc get routes` and update the route in _ui-server.yaml_ file.
8597

8698
On Xeon:
99+
87100
```
88101
cd GenAIExamples/CodeGen/openshift/manifests/xeon
89102
export CODEGEN_ROUTE="YourCodegenRoute"
90103
sed -i "s/insert-your-codegen-route/${CODEGEN_ROUTE}/g" ui-server.yaml
91104
```
92105

93106
On Gaudi:
107+
94108
```
95109
cd GenAIExamples/CodeGen/openshift/manifests/gaudi
96110
export CODEGEN_ROUTE="YourCodegenRoute"
97111
sed -i "s/insert-your-codegen-route/${CODEGEN_ROUTE}/g" ui-server.yaml
98112
```
99113

100114
6. Deploy UI with command:
115+
101116
```
102117
oc apply -f ui-server.yaml
103118
```
@@ -115,4 +130,4 @@ curl http://${CODEGEN_ROUTE}/v1/codegen -H "Content-Type: application/json" -d '
115130

116131
## Launch the UI
117132

118-
To access the frontend, find the route for *ui-server* with command `oc get routes` and open it in the browser.
133+
To access the frontend, find the route for _ui-server_ with command `oc get routes` and open it in the browser.

CodeGen/openshift/manifests/gaudi/codegen.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ spec:
175175
startupProbe:
176176
exec:
177177
command:
178-
- python
179-
- -c
178+
- python
179+
- -c
180180
- 'import requests; req = requests.get("http://codegen-tgi:8080/info"); print(req)'
181181
initialDelaySeconds: 5
182182
periodSeconds: 5

CodeGen/openshift/manifests/gaudi/ui-server.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Copyright (C) 2024 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
14
apiVersion: apps/v1
25
kind: Deployment
36
metadata:
@@ -16,7 +19,7 @@ spec:
1619
spec:
1720
initContainers:
1821
- name: copy-ui-to-workdir
19-
image: "insert-your-image-codegen-ui"
22+
image: "insert-your-image-codegen-ui"
2023
command:
2124
- /bin/bash
2225
- -c

0 commit comments

Comments
 (0)