-
Notifications
You must be signed in to change notification settings - Fork 127
130 lines (116 loc) · 4.44 KB
/
unit-tests-recipes.yml
File metadata and controls
130 lines (116 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
name: "BioNeMo Recipes CI"
on:
push:
branches:
- "pull-request/[0-9]+"
- "dependabot/**"
merge_group:
types: [checks_requested]
schedule:
- cron: "0 9 * * *" # Runs at 9 AM UTC daily (2 AM MST)
defaults:
run:
shell: bash -x -e -u -o pipefail {0}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
changed-dirs:
runs-on: ubuntu-latest
outputs:
any_changed: ${{ steps.changed-files.outputs.any_changed }}
all_changed_files: ${{ steps.changed-files.outputs.all_changed_files }}
dirs: ${{ steps.set-dirs.outputs.dirs }}
steps:
- id: get-pr-info
uses: nv-gha-runners/get-pr-info@main
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get changed files
id: changed-files
uses: step-security/changed-files@v46
with:
json: true
matrix: true
base_sha: ${{ fromJSON(steps.get-pr-info.outputs.pr-info).base.ref }}
dir_names: true
dir_names_max_depth: 2
files: |
models/**
recipes/**
- id: set-dirs
run: |
# Get all recipe and model directories
ALL_DIRS=$(ls -d recipes/*/ models/*/ 2>/dev/null | jq -R -s -c 'split("\n")[:-1] | map(rtrimstr("/"))')
# Determine which directories to run: all for schedule, filtered for other events
if [[ "${{ github.event_name }}" == "schedule" ]]; then
DIRS="$ALL_DIRS"
elif [[ '${{ steps.get-pr-info.outputs.pr-info }}' != 'null' ]] && echo '${{ steps.get-pr-info.outputs.pr-info }}' | jq -e '.labels[]? | select(.name == "INCLUDE_ALL_RECIPES")' > /dev/null 2>&1; then
echo "Found INCLUDE_ALL_RECIPES label - running all directories"
DIRS="$ALL_DIRS"
else
CHANGED_FILES='${{ steps.changed-files.outputs.all_changed_files }}'
# Filter directories to only those that have changed files
DIRS=$(echo "$ALL_DIRS" | jq -c --argjson changed "$CHANGED_FILES" '
map(select(. as $dir | $changed | index($dir) != null))
')
fi
# Assign Docker images to the selected directories
# Currently, AMPLIFY is the only folder that needs a custom base image, since we have to support both TE and
# xformers-based models for golden value testing. The rest of the models use the default pytorch image.
DIRS_WITH_IMAGES=$(echo "$DIRS" | jq -c '
map({
dir: .,
image: (
if . == "models/amplify" then
"svcbionemo023/bionemo-framework:amplify-model-devcontainer-082025"
else
"nvcr.io/nvidia/pytorch:25.06-py3"
end
)
})
')
echo "dirs=$DIRS_WITH_IMAGES" >> $GITHUB_OUTPUT
- name: Show output
run: |
echo '${{ toJSON(steps.changed-files.outputs) }}'
echo '${{ toJSON(steps.set-dirs.outputs) }}'
echo '${{ toJSON(steps.get-pr-info.outputs.pr-info) }}'
shell:
bash
unit-tests:
needs: changed-dirs
runs-on: linux-amd64-gpu-l4-latest-1
if: ${{ needs.changed-dirs.outputs.any_changed == 'true' }}
container:
image: ${{ matrix.recipe.image }}
strategy:
matrix:
recipe: ${{ fromJson(needs.changed-dirs.outputs.dirs) }}
fail-fast: false
steps:
- name: Setup proxy cache
uses: nv-gha-runners/setup-proxy-cache@main
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: '${{ matrix.recipe.dir }}'
sparse-checkout-cone-mode: false
- name: Install dependencies
working-directory: ${{ matrix.recipe.dir }}
#
run: |
if [ -f pyproject.toml ] || [ -f setup.py ]; then
PIP_CONSTRAINT= pip install -e .
echo "Installed ${{ matrix.recipe.dir }} as editable package"
elif [ -f requirements.txt ]; then
PIP_CONSTRAINT= pip install -r requirements.txt
echo "Installed ${{ matrix.recipe.dir }} from requirements.txt"
else
echo "No pyproject.toml, setup.py, or requirements.txt found in ${{ matrix.recipe.dir }}"
exit 1
fi
- name: Run tests
working-directory: ${{ matrix.recipe.dir }}
run: pytest -v .