3030 containers:
3131 - args:
3232 - '--port=8080'
33- - '--model=\$(MODEL_ID)'
34- - '--download-dir=/cache'
33+ - '--model=/cache/models'
3534 - '--distributed-executor-backend=mp'
3635 - '--served-model-name=mistral-7b-instruct'
3736 - '--max-model-len=4096'
6665 volumeMounts:
6766 - mountPath: /dev/shm
6867 name: shm
69- - mountPath: /cache
70- name: cache
68+ - mountPath: /cache/models
69+ name: models
7170 multiModel: false
7271 supportedModelFormats:
7372 - autoSelect: true
7776 emptyDir:
7877 medium: Memory
7978 sizeLimit: 2Gi
80- - name: cache
79+ - name: models
8180 persistentVolumeClaim:
8281 claimName: model-pvc
8382 EOF
@@ -124,11 +123,50 @@ spec:
124123 imagePullPolicy : IfNotPresent
125124 name : create-vllm
126125 envFrom :
127- - secretRef :
128- name : minio-secret
129126 - secretRef :
130127 name : huggingface-secret
131128 initContainers :
129+ - args :
130+ - -ec
131+ - |-
132+ pip install huggingface_hub;
133+ export HF_HOME=/tmp/cache/
134+ cat << 'EOF' | python3
135+ from huggingface_hub import snapshot_download
136+ from pathlib import Path
137+ from huggingface_hub import login
138+ import subprocess, os
139+
140+ # Get the environment variable 'hftoken'
141+ hf_token = os.getenv('hftoken')
142+ # Get model id
143+ modelid = os.getenv('modelId')
144+ model_id = modelid.split('/')[-1]
145+
146+ def run_command(command):
147+ """Run a shell command and check for errors."""
148+ result = subprocess.run(command, shell=True, check=True, text=True, capture_output=True)
149+ print(result.stdout)
150+ if result.stderr:
151+ print(result.stderr)
152+
153+ if hf_token is not None and hf_token.strip() != "None":
154+ print("hftoken is set.")
155+ login(token=hf_token)
156+ mistral_models_path = "/cache/models"
157+ snapshot_download(repo_id=modelid, local_dir=mistral_models_path)
158+ EOF
159+ command :
160+ - /bin/bash
161+ envFrom :
162+ - secretRef :
163+ name : huggingface-secret
164+ image : registry.access.redhat.com/ubi9/python-39
165+ imagePullPolicy : IfNotPresent
166+ name : download-model
167+ volumeMounts :
168+ - mountPath : /cache/models
169+ name : models
132170 - args :
133171 - -ec
134172 - |-
@@ -143,12 +181,16 @@ spec:
143181 oc wait --for=jsonpath='{.status.phase}'=Ready --timeout=900s -n redhat-ods-operator dscinitialization/default-dsci
144182 sleep 10
145183 echo -n 'dscinitialization/default-dsci initialized';echo
146- sleep 120
184+ sleep 30
147185 command :
148186 - /bin/bash
149187 image : image-registry.openshift-image-registry.svc:5000/openshift/tools:latest
150188 imagePullPolicy : IfNotPresent
151189 name : wait-for-openshift
152- restartPolicy : Never
190+ volumes :
191+ - name : models
192+ persistentVolumeClaim :
193+ claimName : model-pvc
194+ restartPolicy : OnFailure
153195 serviceAccount : demo-setup
154196 serviceAccountName : demo-setup
0 commit comments