46
46
convert_notebooks :
47
47
type : boolean
48
48
description : " Convert notebooks to markdown files before building docs."
49
- # Docker image to use for the build. Set custom_container="" if you don't need any.
50
- # Default containers is "huggingface/transformers-doc-builder" which has all the necessary dependencies (torch,
51
- # transformers, tensorflow, etc.) but is quite heavy to download.
49
+ # Docker image to use for the build. Set custom_container="huggingface/transformers-doc-builder" if you need
50
+ # a complete install. Default to `""` which means CI will run on the runner directly.
52
51
custom_container :
53
52
type : string
54
- default : " huggingface/transformers-doc-builder "
53
+ default : " "
55
54
description : " Docker image to use for the build."
56
55
secrets :
57
56
hf_token :
64
63
runs-on : ubuntu-latest
65
64
container :
66
65
${{ inputs.custom_container }}
66
+ env :
67
+ UV_HTTP_TIMEOUT : 900 # max 15min to install deps (shouldn't take more than 5min)
67
68
68
69
steps :
69
70
- uses : actions/checkout@v2
88
89
node-version : ' 20'
89
90
cache-dependency-path : " kit/package-lock.json"
90
91
92
+ - name : Export ROOT_APT_GET ('apt-get' or 'sudo apt-get')
93
+ # Use `sudo` only if running on the base runner.
94
+ # When using a container, `sudo` is not needed (and not installed)
95
+ run : |
96
+ if [ -z "${{ inputs.custom_container }}" ]
97
+ then
98
+ echo "ROOT_APT_GET=sudo apt-get" >> $GITHUB_ENV
99
+ else
100
+ echo "ROOT_APT_GET=apt-get" >> $GITHUB_ENV
101
+ fi
102
+
103
+ - name : Export PIP_OR_UV ('pip' or 'uv pip')
104
+ # Use `uv` only if running on the base runner.
105
+ # When using a container, `pip` has already been used to installed existing deps
106
+ # and is therefore quicker to resolve (already have some cached stuff).
107
+ run : |
108
+ if [ -z "${{ inputs.custom_container }}" ]
109
+ then
110
+ echo "PIP_OR_UV=uv pip" >> $GITHUB_ENV
111
+ else
112
+ echo "PIP_OR_UV=pip" >> $GITHUB_ENV
113
+ fi
114
+
91
115
- name : Set env variables
92
116
run : |
93
117
if [ -z "${{ inputs.path_to_docs }}" ]
@@ -107,35 +131,44 @@ jobs:
107
131
108
132
# Needed to upload zips to hf.co
109
133
- name : Install zip
110
- run : apt-get install -y zip
134
+ # Use sudo only if running on the base runner.
135
+ # When using a container, `sudo` is not needed (and not installed).
136
+ run : $ROOT_APT_GET install -y zip
111
137
112
138
- name : Install libgl1
113
139
if : inputs.install_libgl1
114
- run : apt-get install -y libgl1
140
+ run : $ROOT_APT_GET install -y libgl1
115
141
116
142
- name : Install Rust
117
143
uses : actions-rs/toolchain@v1
118
144
if : inputs.install_rust
119
145
with :
120
146
toolchain : stable
121
147
148
+ # Use venv in both cases
149
+ - name : Install uv
150
+ run : |
151
+ pip install -U uv
152
+ uv venv
153
+
122
154
- name : Setup environment
123
155
shell : bash
124
156
run : |
125
- pip uninstall -y doc-builder
157
+ source .venv/bin/activate
158
+ $PIP_OR_UV uninstall doc-builder
126
159
cd doc-builder
127
160
git pull origin main
128
- pip install .
161
+ $PIP_OR_UV install .
129
162
cd ..
130
163
131
164
if [[ -n "${{ inputs.package_path }}" ]]
132
165
then
133
166
cd ${{ inputs.package_path }}
134
- pip install .[dev]
167
+ $PIP_OR_UV install .[dev]
135
168
elif [[ "${{ inputs.additional_args }}" != *"--not_python_module"* ]];
136
169
then
137
170
cd ${{ inputs.package }}
138
- pip install .[dev]
171
+ $PIP_OR_UV install .[dev]
139
172
fi
140
173
cd ..
141
174
@@ -162,6 +195,7 @@ jobs:
162
195
- name : Convert notebooks to markdown files
163
196
if : inputs.convert_notebooks
164
197
run : |
198
+ source .venv/bin/activate
165
199
branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
166
200
remaining_part=$(echo "${{ env.doc_folder }}" | perl -pe 's|^[^/]+||')
167
201
remaining_part=${remaining_part%/}
@@ -174,6 +208,7 @@ jobs:
174
208
env :
175
209
NODE_OPTIONS : --max-old-space-size=6656
176
210
run : |
211
+ source .venv/bin/activate
177
212
echo "doc_folder has been set to ${{ env.doc_folder }}"
178
213
cd doc-builder
179
214
args="--build_dir ../build_dir --clean --html ${{ inputs.additional_args }} --repo_owner ${{ inputs.repo_owner }} --repo_name ${{ inputs.package }} --version_tag_suffix=${{ inputs.version_tag_suffix }}"
0 commit comments