From d1cccf8a880bb9294cc9825a76d46755adce69f2 Mon Sep 17 00:00:00 2001 From: Lianhao Lu Date: Thu, 12 Dec 2024 08:44:49 +0000 Subject: [PATCH] Workaround to acknowledge HF_TOKEN in model-downloader Signed-off-by: Lianhao Lu --- .../common/speecht5/templates/deployment.yaml | 16 ++++++++++++---- helm-charts/common/tei/templates/deployment.yaml | 16 ++++++++++++---- .../common/teirerank/templates/deployment.yaml | 16 ++++++++++++---- helm-charts/common/tgi/templates/deployment.yaml | 16 ++++++++++++---- .../common/vllm/templates/deployment.yaml | 14 +++++++++++--- .../common/whisper/templates/deployment.yaml | 14 +++++++++++--- 6 files changed, 70 insertions(+), 22 deletions(-) diff --git a/helm-charts/common/speecht5/templates/deployment.yaml b/helm-charts/common/speecht5/templates/deployment.yaml index 0db70e67..1a926000 100644 --- a/helm-charts/common/speecht5/templates/deployment.yaml +++ b/helm-charts/common/speecht5/templates/deployment.yaml @@ -35,8 +35,8 @@ spec: - configMapRef: name: {{ include "speecht5.fullname" . }}-config securityContext: - allowPrivilegeEscalation: false readOnlyRootFilesystem: true + allowPrivilegeEscalation: false {{- if hasKey .Values.securityContext "runAsGroup" }} runAsGroup: {{ .Values.securityContext.runAsGroup }} {{- end }} @@ -51,16 +51,24 @@ spec: seccompProfile: type: RuntimeDefault image: huggingface/downloader:0.17.3 - command: ['sh', '-c'] + command: ['sh', '-ec'] args: - | - huggingface-cli download --cache-dir /data --token $(HF_TOKEN) {{ .Values.TTS_MODEL_PATH | quote }}; - huggingface-cli download --cache-dir /data --token $(HF_TOKEN) {{ .Values.VOCODER_MODEL| quote }}; + echo "Huggingface log in ..."; + huggingface-cli login --token $(HF_TOKEN); + echo "Download models {{ .Values.TTS_MODEL_PATH }} {{ .Values.VOCODER_MODEL }} ... "; + huggingface-cli download --cache-dir /data {{ .Values.TTS_MODEL_PATH | quote }}; + huggingface-cli download --cache-dir /data {{ .Values.VOCODER_MODEL| quote }}; + echo "Change model files mode ..."; chmod -R g+w /data/models--{{ replace "/" "--" .Values.TTS_MODEL_PATH }}; chmod -R g+w /data/models--{{ replace "/" "--" .Values.VOCODER_MODEL }} + # NOTE: Buggy logout command; + # huggingface-cli logout; volumeMounts: - mountPath: /data name: model-volume + - mountPath: /tmp + name: tmp {{- end }} containers: - name: {{ .Release.Name }} diff --git a/helm-charts/common/tei/templates/deployment.yaml b/helm-charts/common/tei/templates/deployment.yaml index 10f13981..43e7c40d 100644 --- a/helm-charts/common/tei/templates/deployment.yaml +++ b/helm-charts/common/tei/templates/deployment.yaml @@ -38,8 +38,8 @@ spec: - configMapRef: name: {{ include "tei.fullname" . }}-config securityContext: - allowPrivilegeEscalation: false readOnlyRootFilesystem: true + allowPrivilegeEscalation: false {{- if hasKey .Values.securityContext "runAsGroup" }} runAsGroup: {{ .Values.securityContext.runAsGroup }} {{- end }} @@ -54,14 +54,22 @@ spec: seccompProfile: type: RuntimeDefault image: huggingface/downloader:0.17.3 - command: ['sh', '-c'] + command: ['sh', '-ec'] args: - | - huggingface-cli download --cache-dir /data --token $(HF_TOKEN) $(MODEL_ID); - chmod -R g+w /data/models--{{ replace "/" "--" .Values.EMBEDDING_MODEL_ID }} + echo "Huggingface log in ..."; + huggingface-cli login --token $(HF_TOKEN); + echo "Download model {{ .Values.EMBEDDING_MODEL_ID }} ... "; + huggingface-cli download --cache-dir /data {{ .Values.EMBEDDING_MODEL_ID | quote }}; + echo "Change model files mode ..."; + chmod -R g+w /data/models--{{ replace "/" "--" .Values.EMBEDDING_MODEL_ID }}; + # NOTE: Buggy logout command; + # huggingface-cli logout; volumeMounts: - mountPath: /data name: model-volume + - mountPath: /tmp + name: tmp {{- end }} containers: - name: {{ .Chart.Name }} diff --git a/helm-charts/common/teirerank/templates/deployment.yaml b/helm-charts/common/teirerank/templates/deployment.yaml index 3387fad0..6692d95d 100644 --- a/helm-charts/common/teirerank/templates/deployment.yaml +++ b/helm-charts/common/teirerank/templates/deployment.yaml @@ -38,8 +38,8 @@ spec: - configMapRef: name: {{ include "teirerank.fullname" . }}-config securityContext: - allowPrivilegeEscalation: false readOnlyRootFilesystem: true + allowPrivilegeEscalation: false {{- if hasKey .Values.securityContext "runAsGroup" }} runAsGroup: {{ .Values.securityContext.runAsGroup }} {{- end }} @@ -54,14 +54,22 @@ spec: seccompProfile: type: RuntimeDefault image: huggingface/downloader:0.17.3 - command: ['sh', '-c'] + command: ['sh', '-ec'] args: - | - huggingface-cli download --cache-dir /data --token $(HF_TOKEN) $(MODEL_ID); - chmod -R g+w /data/models--{{ replace "/" "--" .Values.RERANK_MODEL_ID }} + echo "Huggingface log in ..."; + huggingface-cli login --token $(HF_TOKEN); + echo "Download model {{ .Values.RERANK_MODEL_ID }} ... "; + huggingface-cli download --cache-dir /data {{ .Values.RERANK_MODEL_ID | quote }}; + echo "Change model files mode ..."; + chmod -R g+w /data/models--{{ replace "/" "--" .Values.RERANK_MODEL_ID }}; + # NOTE: Buggy logout command; + # huggingface-cli logout; volumeMounts: - mountPath: /data name: model-volume + - mountPath: /tmp + name: tmp {{- end }} containers: - name: {{ .Chart.Name }} diff --git a/helm-charts/common/tgi/templates/deployment.yaml b/helm-charts/common/tgi/templates/deployment.yaml index 66d62dda..17b68282 100644 --- a/helm-charts/common/tgi/templates/deployment.yaml +++ b/helm-charts/common/tgi/templates/deployment.yaml @@ -38,8 +38,8 @@ spec: - configMapRef: name: {{ include "tgi.fullname" . }}-config securityContext: - allowPrivilegeEscalation: false readOnlyRootFilesystem: true + allowPrivilegeEscalation: false {{- if hasKey .Values.securityContext "runAsGroup" }} runAsGroup: {{ .Values.securityContext.runAsGroup }} {{- end }} @@ -54,14 +54,22 @@ spec: seccompProfile: type: RuntimeDefault image: huggingface/downloader:0.17.3 - command: ['sh', '-c'] + command: ['sh', '-ec'] args: - | - huggingface-cli download --cache-dir /data --token $(HF_TOKEN) $(MODEL_ID); - chmod -R g+w /data/models--{{ replace "/" "--" .Values.LLM_MODEL_ID }} + echo "Huggingface log in ..."; + huggingface-cli login --token $(HF_TOKEN); + echo "Download model {{ .Values.LLM_MODEL_ID }} ... "; + huggingface-cli download --cache-dir /data {{ .Values.LLM_MODEL_ID | quote }}; + echo "Change model files mode ..."; + chmod -R g+w /data/models--{{ replace "/" "--" .Values.LLM_MODEL_ID }}; + # NOTE: Buggy logout command; + # huggingface-cli logout; volumeMounts: - mountPath: /data name: model-volume + - mountPath: /tmp + name: tmp {{- end }} containers: - name: {{ .Chart.Name }} diff --git a/helm-charts/common/vllm/templates/deployment.yaml b/helm-charts/common/vllm/templates/deployment.yaml index 71aef029..afa559cd 100644 --- a/helm-charts/common/vllm/templates/deployment.yaml +++ b/helm-charts/common/vllm/templates/deployment.yaml @@ -35,8 +35,8 @@ spec: - configMapRef: name: {{ include "vllm.fullname" . }}-config securityContext: - allowPrivilegeEscalation: false readOnlyRootFilesystem: true + allowPrivilegeEscalation: false capabilities: drop: - ALL @@ -48,14 +48,22 @@ spec: seccompProfile: type: RuntimeDefault image: huggingface/downloader:0.17.3 - command: ['sh', '-c'] + command: ['sh', '-ec'] args: - | - huggingface-cli download --cache-dir /data --token $(HF_TOKEN) {{ .Values.LLM_MODEL_ID | quote }}; + echo "Huggingface log in ..."; + huggingface-cli login --token $(HF_TOKEN); + echo "Download model {{ .Values.LLM_MODEL_ID }} ... "; + huggingface-cli download --cache-dir /data {{ .Values.LLM_MODEL_ID | quote }}; + echo "Change model files mode ..."; chmod -R g+w /data/models--{{ replace "/" "--" .Values.LLM_MODEL_ID }} + # NOTE: Buggy logout command; + # huggingface-cli logout; volumeMounts: - mountPath: /data name: model-volume + - mountPath: /tmp + name: tmp {{- end }} containers: - name: {{ .Chart.Name }} diff --git a/helm-charts/common/whisper/templates/deployment.yaml b/helm-charts/common/whisper/templates/deployment.yaml index 4d4503d9..2b965f39 100644 --- a/helm-charts/common/whisper/templates/deployment.yaml +++ b/helm-charts/common/whisper/templates/deployment.yaml @@ -35,8 +35,8 @@ spec: - configMapRef: name: {{ include "whisper.fullname" . }}-config securityContext: - allowPrivilegeEscalation: false readOnlyRootFilesystem: true + allowPrivilegeEscalation: false {{- if hasKey .Values.securityContext "runAsGroup" }} runAsGroup: {{ .Values.securityContext.runAsGroup }} {{- end }} @@ -51,14 +51,22 @@ spec: seccompProfile: type: RuntimeDefault image: huggingface/downloader:0.17.3 - command: ['sh', '-c'] + command: ['sh', '-ec'] args: - | - huggingface-cli download --cache-dir /data --token $(HF_TOKEN) {{ .Values.ASR_MODEL_PATH | quote }}; + echo "Huggingface log in ..."; + huggingface-cli login --token $(HF_TOKEN); + echo "Download model {{ .Values.ASR_MODEL_PATH }} ... "; + huggingface-cli download --cache-dir /data {{ .Values.ASR_MODEL_PATH | quote }}; + echo "Change model files mode ..."; chmod -R g+w /data/models--{{ replace "/" "--" .Values.ASR_MODEL_PATH }} + # NOTE: Buggy logout command; + # huggingface-cli logout; volumeMounts: - mountPath: /data name: model-volume + - mountPath: /tmp + name: tmp {{- end }} containers: - name: {{ .Release.Name }}