4141 storage : 50Gi
4242 volumeMode : Filesystem
4343---
44- kind : Secret
45- apiVersion : v1
46- metadata :
47- name : minio-secret
48- stringData :
49- MINIO_ROOT_USER : minio
50- MINIO_ROOT_PASSWORD : {{ randAlphaNum 10 | b64enc }}
51- ---
5244kind : Deployment
5345apiVersion : apps/v1
5446metadata :
@@ -213,26 +205,32 @@ spec:
213205 - args :
214206 - -ec
215207 - |-
216- oc get secret minio-secret
217208 env | grep MINIO
209+ pip install minio;
218210 cat << 'EOF' | python3
219- import boto3, os
220-
221- s3 = boto3.client("s3",
222- endpoint_url="http://minio-service:9000",
223- aws_access_key_id=os.getenv("MINIO_ROOT_USER"),
224- aws_secret_access_key=os.getenv("MINIO_ROOT_PASSWORD"))
211+ from minio import Minio
212+ import os
213+ client = Minio(
214+ "minio-service:9000",
215+ access_key=os.getenv("MINIO_ROOT_USER"),
216+ secret_key=os.getenv("MINIO_ROOT_PASSWORD"),
217+ secure=False
218+ )
225219 bucket = 'models'
220+
226221 print('creating models bucket')
227- if bucket not in [bu["Name"] for bu in s3.list_buckets()["Buckets"]]:
228- s3.create_bucket(Bucket=bucket)
222+ if client.bucket_exists(bucket):
223+ print("bucket 'models' exists")
224+ else:
225+ client.make_bucket(bucket)
226+ print("bucket 'models' created successfully")
229227 EOF
230228 command :
231229 - /bin/bash
232230 envFrom :
233231 - secretRef :
234232 name : minio-secret
235- image : image- registry.openshift-image-registry.svc:5000/ redhat-ods-applications/s2i-generic-data-science-notebook:2024.1
233+ image : registry.access. redhat.com/ubi8/python-38
236234 imagePullPolicy : IfNotPresent
237235 name : create-buckets
238236 initContainers :
@@ -242,22 +240,16 @@ spec:
242240 echo -n 'Waiting for minio root user secret'
243241 while ! oc get secret minio-secret 2>/dev/null | grep -qF minio-secret; do
244242 echo -n .
245- sleep 15
243+ sleep 5
246244 done; echo
247245
248246 echo -n 'Waiting for minio deployment'
249247 while ! oc get deployment minio 2>/dev/null | grep -qF minio; do
250248 echo -n .
251- sleep 15
249+ sleep 5
252250 done; echo
253251 oc wait --for=condition=available --timeout=60s deployment/minio
254252 sleep 10
255-
256- echo -n 'Waiting for openshift ai initialize'
257- while ! oc describe sub rhods-operator -n redhat-ods-operator 2>/dev/null | grep -qF rhods-operator; do
258- echo -n .
259- sleep 15
260- done; echo
261253 command :
262254 - /bin/bash
263255 image : image-registry.openshift-image-registry.svc:5000/openshift/tools:latest
@@ -291,7 +283,7 @@ spec:
291283 - args :
292284 - -ec
293285 - |-
294- pip install huggingface_hub;
286+ pip install huggingface_hub boto3 ;
295287 cat << 'EOF' | python3
296288 import boto3, os, botocore, subprocess
297289 from huggingface_hub import snapshot_download
@@ -352,34 +344,14 @@ spec:
352344 print(obj.key)
353345
354346 if hf_token is not None and hf_token.strip() != "None":
355- # If 'hftoken' is not None and not empty, execute this code
356- print("hftoken is set.")
357- login(token=hf_token)
358- mistral_models_path = Path.home().joinpath(model_id)
359- mistral_models_path.mkdir(parents=True, exist_ok=True)
360- snapshot_download(repo_id="mistralai/" + model_id, allow_patterns=["config.json", "consolidated.safetensors", "generation_config.json", "model*", "special_tokens_map.json", "tokenizer*", "params.json"], local_dir=mistral_models_path)
361-
362- else:
363- # If 'hftoken' is None or an empty string, execute this code
364- print("hftoken is not set or is empty.")
365- print("Performing default action due to missing hftoken.")
366- try:
367- # Step 1: Install Git LFS
368- run_command("git lfs install")
369-
370- # Step 2: Clone the specified repository from Hugging Face
371- run_command("git clone https://huggingface.co/mistral-community/" + model_id)
372-
373- # Step 3: Remove the .git directory to save space
374- run_command("rm -rf " + model_id + "/.git")
375-
376- print("Commands executed successfully.")
377-
378- except subprocess.CalledProcessError as e:
379- print(f"An error occurred while running the command: {e}")
347+ # If 'hftoken' is not None and not empty, execute this code
348+ print("hftoken is set.")
349+ login(token=hf_token)
350+ mistral_models_path = Path.home().joinpath(model_id)
351+ mistral_models_path.mkdir(parents=True, exist_ok=True)
352+ snapshot_download(repo_id=modelid, local_dir=mistral_models_path)
380353
381354 list_objects("models")
382-
383355 print(model_id)
384356 num_files = upload_directory_to_s3(model_id, "llm-models/" + model_id)
385357
@@ -396,7 +368,7 @@ spec:
396368 name : minio-secret
397369 - secretRef :
398370 name : huggingface-secret
399- image : image- registry.openshift-image-registry.svc:5000/ redhat-ods-applications/s2i-generic-data-science-notebook:2024.1
371+ image : registry.access. redhat.com/ubi8/python-38
400372 imagePullPolicy : IfNotPresent
401373 name : download-model
402374 initContainers :
@@ -406,26 +378,16 @@ spec:
406378 echo -n 'Waiting for minio root user secret'
407379 while ! oc get secret minio-secret 2>/dev/null | grep -qF minio-secret; do
408380 echo -n .
409- sleep 15
381+ sleep 5
410382 done; echo
411383
412384 echo -n 'Waiting for minio deployment'
413385 while ! oc get deployment minio 2>/dev/null | grep -qF minio; do
414386 echo -n .
415- sleep 15
387+ sleep 5
416388 done; echo
417389 oc wait --for=condition=available --timeout=600s deployment/minio
418390 sleep 10
419-
420- echo -n 'Waiting for openshift ai initialize'
421- while ! oc describe sub rhods-operator -n redhat-ods-operator 2>/dev/null | grep -qF rhods-operator; do
422- echo -n .
423- sleep 15
424- done; echo
425-
426- oc wait --for=condition=CatalogSourcesUnhealthy=False subscription/rhods-operator --timeout=600s -n redhat-ods-operator
427- oc wait --for=jsonpath='{.status.phase}'=Ready --timeout=600s -n redhat-ods-operator dscinitialization/default-dsci
428- sleep 10
429391 command :
430392 - /bin/bash
431393 image : image-registry.openshift-image-registry.svc:5000/openshift/tools:latest
0 commit comments