@@ -118,32 +118,41 @@ spec:
118118 echo "[mapt] Spot: $(params.spot)"
119119 echo "[mapt] =================================="
120120
121- MAPT_COMMON_ARGS="--project-name mapt-rhel-ai-${RUN_ID} \
122- --backed-url s3://${BUCKET}/mapt/rhel-ai/${RUN_ID} \
121+ VLLM_EXTRA="--max-model-len 131072 --enable-auto-tool-choice --tool-call-parser llama3_json --chat-template /opt/app-root/template/tool_chat_template_llama3.1_json.jinja"
122+ CREATED=0
123+
124+ mapt_create() {
125+ mapt aws rhel-ai create \
126+ --project-name "mapt-rhel-ai-${RUN_ID}" \
127+ --backed-url "s3://${BUCKET}/mapt/rhel-ai/${RUN_ID}" \
123128 --conn-details-output /opt/host-info \
124- --compute-sizes $(params.instance-type) \
125- --version $(params.rhelai-version) \
129+ --compute-sizes " $(params.instance-type)" \
130+ --version " $(params.rhelai-version)" \
126131 --auto-start \
127- --model $(params.model) \
128- --hf-token ${HF_TOKEN} \
129- --api-key ${VLLM_API_KEY} \
132+ --model " $(params.model)" \
133+ --hf-token " ${HF_TOKEN}" \
134+ --api-key " ${VLLM_API_KEY}" \
130135 --expose-ports 8000 \
131- --vllm-extra-args '--max-model-len 131072 --enable-auto-tool-choice --tool-call-parser llama3_json --chat-template /opt/app-root/template/tool_chat_template_llama3.1_json.jinja' \
132- --tags project=lightspeed-core,environment=konflux-ci"
136+ --vllm-extra-args "${VLLM_EXTRA}" \
137+ --tags "project=lightspeed-core,environment=konflux-ci" \
138+ "$@"
139+ }
133140
134- CREATED=0
141+ mapt_destroy() {
142+ mapt aws rhel-ai destroy \
143+ --project-name "mapt-rhel-ai-${RUN_ID}" \
144+ --backed-url "s3://${BUCKET}/mapt/rhel-ai/${RUN_ID}" \
145+ --force-destroy 2>/dev/null || true
146+ }
135147
136148 # Try spot first
137149 echo "[mapt] Trying spot instances..."
138150 export AWS_DEFAULT_REGION="us-east-1"
139- if mapt aws rhel-ai create $MAPT_COMMON_ARGS --spot --spot-eviction-tolerance highest; then
151+ if mapt_create --spot --spot-eviction-tolerance highest; then
140152 CREATED=1
141153 else
142154 echo "[mapt] Spot failed, cleaning up..."
143- mapt aws rhel-ai destroy \
144- --project-name "mapt-rhel-ai-${RUN_ID}" \
145- --backed-url "s3://${BUCKET}/mapt/rhel-ai/${RUN_ID}" \
146- --force-destroy 2>/dev/null || true
155+ mapt_destroy
147156 fi
148157
149158 # Fall back to on-demand with region rotation
@@ -155,16 +164,13 @@ spec:
155164 echo "[mapt] Trying on-demand in ${REGION}..."
156165 export AWS_DEFAULT_REGION="$REGION"
157166
158- if timeout $TIMEOUT mapt aws rhel-ai create $MAPT_COMMON_ARGS ; then
167+ if timeout $TIMEOUT mapt_create ; then
159168 CREATED=1
160169 break
161170 fi
162171
163172 echo "[mapt] Failed in ${REGION}, cleaning up..."
164- mapt aws rhel-ai destroy \
165- --project-name "mapt-rhel-ai-${RUN_ID}" \
166- --backed-url "s3://${BUCKET}/mapt/rhel-ai/${RUN_ID}" \
167- --force-destroy 2>/dev/null || true
173+ mapt_destroy
168174 done
169175 fi
170176
0 commit comments