#!/bin/sh
# SPDX-License-Identifier: Apache-2.0
# The GPU queue's CLI (docs/gpu-queue.md): `scripts/gpu submit ...`, `scripts/gpu list`.
# Runs under the first interpreter with tomllib and tarfile extraction filters (3.11.4+); python3 alone may be older.
# GPU_QUEUE_KUBECONFIG_FILE: the GPU queue's own kubeconfig (the dev box sets it in its profile: the queue is on the
# kubeadm cluster while every other kubectl still uses MicroK8s). When set it wins over KUBECONFIG for this command only.
[ -n "${GPU_QUEUE_KUBECONFIG_FILE:-}" ] && export KUBECONFIG="$GPU_QUEUE_KUBECONFIG_FILE"
for py in python3.13 python3.12 python3.11 python3; do
  if command -v "$py" >/dev/null 2>&1 && "$py" -c 'import tarfile, tomllib; tarfile.data_filter' 2>/dev/null; then
    exec "$py" "$(dirname "$0")/gpu_submit.py" "$@"
  fi
done
echo "scripts/gpu: no python3 with tomllib and tarfile extraction filters (3.11.4+) on PATH" >&2
exit 70
