Skip to content

Commit 8c2ff73

Browse files
authored
[MISC] Migrate from pip to uv for unit tests venv in production CI. (#2195)
1 parent b96a884 commit 8c2ff73

2 files changed

Lines changed: 56 additions & 39 deletions

File tree

.github/workflows/production.yml

Lines changed: 47 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -45,49 +45,59 @@ jobs:
4545
steps:
4646
- name: Checkout code
4747
uses: actions/checkout@v4
48-
- name: Run unit tests
48+
- name: Start container
4949
if: github.event_name == 'pull_request'
5050
run: |
5151
SLURM_JOB_NAME="$(uuidgen)_$(date +%Y%m%d_%H%M%S)"
52+
CONTAINER_NAME="${SLURM_JOB_NAME}"
53+
SRUN_CONTAINER_OPTS="--container-name=${CONTAINER_NAME} \
54+
--container-mounts=${{ github.workspace }}:/root/workspace,${HOME}/.cache/uv:/root/.cache/uv \
55+
--no-container-mount-home \
56+
--container-workdir=/root/workspace"
57+
SLURM_ENV_VARS="NVIDIA_DRIVER_CAPABILITIES=all,BASH_ENV=/root/.bashrc,HF_TOKEN,GS_ENABLE_NDARRAY=${GS_ENABLE_NDARRAY}"
58+
59+
JOBID_FIFO="${{ github.workspace }}/.slurm_job_id_fifo"
60+
[[ -e "$JOBID_FIFO" ]] && rm -f "$JOBID_FIFO"
61+
mkfifo "$JOBID_FIFO"
62+
salloc --job-name="${SLURM_JOB_NAME}" \
63+
--partition=hpc-mid --nodes=1 --gpus=8 --exclusive \
64+
--time="${TIMEOUT_MINUTES}" \
65+
bash -c "echo \$SLURM_JOB_ID > $JOBID_FIFO; sleep ${TIMEOUT_MINUTES}m" &
66+
SLURM_JOB_ID=$(cat "$JOBID_FIFO")
67+
rm -f "$JOBID_FIFO"
68+
SRUN_COMMON="--overlap --jobid=${SLURM_JOB_ID} ${SRUN_CONTAINER_OPTS} --export=${SLURM_ENV_VARS}"
69+
srun --jobid=${SLURM_JOB_ID} \
70+
--container-image=/mnt/data/images/genesis-v${GENESIS_IMAGE_VER}.sqsh \
71+
${SRUN_CONTAINER_OPTS} \
72+
--export=${SLURM_ENV_VARS} \
73+
echo "Container ready"
74+
5275
echo "SLURM_JOB_NAME=${SLURM_JOB_NAME}" >> $GITHUB_ENV
76+
echo "SRUN_COMMON=${SRUN_COMMON}" >> "$GITHUB_ENV"
77+
78+
- name: Build
79+
if: github.event_name == 'pull_request'
80+
run: |
81+
srun ${SRUN_COMMON} \
82+
bash .github/workflows/scripts/production_build.sh
5383
54-
mkdir -p "${HOME}/.cache" "${HOME}/.venv"
55-
56-
# TODO: USD baking does not currently support Python 3.11 since
57-
# NVIDIA does not currently release `omniverse-kit==107.3` on PyPI.
58-
# See: https://github.com/Genesis-Embodied-AI/Genesis/pull/1300
59-
srun \
60-
--container-image="/mnt/data/images/genesis-v${GENESIS_IMAGE_VER}.sqsh" \
61-
--container-mounts=\
62-
"${HOME}/.venv":/root/.venv,\
63-
"${HOME}/.cache":/root/.cache,\
64-
"${{ github.workspace }}":/root/workspace \
65-
--no-container-mount-home --container-workdir=/root/workspace \
66-
--export=NVIDIA_DRIVER_CAPABILITIES=all,BASH_ENV=/root/.bashrc,HF_TOKEN,GS_ENABLE_NDARRAY=${GS_ENABLE_NDARRAY} \
67-
--partition=hpc-mid --nodes=1 --gpus=8 --exclusive --time="${TIMEOUT_MINUTES}" \
68-
--job-name=${SLURM_JOB_NAME} \
69-
bash -e -s << 'EOF'
70-
if test -n "$(find /root/.venv -maxdepth 0 -empty)"; then
71-
python3 -m venv --system-site-packages /root/.venv
72-
source /root/.venv/bin/activate
73-
pip install --no-input --upgrade pip pkg-info wheel
74-
pip install --no-input --ignore-installed --upgrade blinker pyparsing setuptools
75-
fi
76-
source /root/.venv/bin/activate
77-
78-
pip install --no-input --extra-index-url https://pypi.nvidia.com/ omniverse-kit
79-
pip install --no-input ".[dev,render,usd]"
80-
81-
# sudo apt update
82-
# sudo apt install -y tmate
83-
# tmate -S /tmp/tmate.sock new-session -d
84-
# tmate -S /tmp/tmate.sock wait tmate-ready
85-
# tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'
86-
87-
pytest -v -ra --backend gpu --dev --forked ./tests
88-
89-
# tmate -S /tmp/tmate.sock wait tmate-exit
84+
- name: Run benchmarks
85+
if: github.event_name == 'pull_request'
86+
run: |
87+
srun ${SRUN_COMMON} bash -e -s <<'EOF'
88+
source /venv/bin/activate
89+
90+
# sudo apt update
91+
# sudo apt install -y tmate
92+
# tmate -S /tmp/tmate.sock new-session -d
93+
# tmate -S /tmp/tmate.sock wait tmate-ready
94+
# tmate -S /tmp/tmate.sock display -p '#{tmate_ssh}'
95+
96+
pytest -v -ra --backend gpu --dev --forked ./tests
97+
98+
# tmate -S /tmp/tmate.sock wait tmate-exit
9099
EOF
100+
91101
- name: Kill srun job systematically
92102
if: always()
93103
run: |

.github/workflows/scripts/production_build.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
set -ex
44

55
curl -LsSf https://astral.sh/uv/install.sh | sh
6-
which uv
76
uv --version
87

8+
# TODO: USD baking does not currently support Python 3.11 since
9+
# NVIDIA does not currently release `omniverse-kit==107.3` on PyPI.
10+
# See: https://github.com/Genesis-Embodied-AI/Genesis/pull/1300
911
uv venv --python '3.10' /venv
1012
source /venv/bin/activate
13+
# Note: the version of cuda must tightly align with what is being installed
14+
# in the Slurm container image, otherwise poorly packaged libraries, such as
15+
# libuipc, may fail to import.
1116
uv pip install torch --index-url https://download.pytorch.org/whl/cu129
12-
uv pip install ".[dev,render]"
17+
uv pip install --upgrade pip setuptools wheel
18+
uv pip install omniverse-kit --index-url https://pypi.nvidia.com/
19+
uv pip install ".[dev,render,usd]"

0 commit comments

Comments
 (0)