config.yml 36 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
version: 2.1
orbs:
    gcp-gke: circleci/gcp-gke@1.0.4
    go: circleci/go@1.3.0

# TPU REFERENCES
references:
    checkout_ml_testing: &checkout_ml_testing
        run:
            name: Checkout ml-testing-accelerators
            command: |
                git clone https://github.com/GoogleCloudPlatform/ml-testing-accelerators.git
                cd ml-testing-accelerators
                git fetch origin 5e88ac24f631c27045e62f0e8d5dfcf34e425e25:stable
                git checkout stable
    build_push_docker: &build_push_docker
        run:
            name: Configure Docker
            command: |
                gcloud --quiet auth configure-docker
                cd docker/transformers-pytorch-tpu
22
                if [ -z "$CIRCLE_PR_NUMBER" ]; then docker build --tag "$GCR_IMAGE_PATH:$CIRCLE_WORKFLOW_JOB_ID" -f Dockerfile --build-arg "TEST_IMAGE=1" . ; else docker build --tag "$GCR_IMAGE_PATH:$CIRCLE_WORKFLOW_JOB_ID" -f Dockerfile --build-arg "TEST_IMAGE=1" --build-arg "GITHUB_REF=pull/$CIRCLE_PR_NUMBER/head" . ; fi
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
                docker push "$GCR_IMAGE_PATH:$CIRCLE_WORKFLOW_JOB_ID"
    deploy_cluster: &deploy_cluster
        run:
            name: Deploy the job on the kubernetes cluster
            command: |
                go get github.com/google/go-jsonnet/cmd/jsonnet && \
                export PATH=$PATH:$HOME/go/bin && \
                kubectl create -f docker/transformers-pytorch-tpu/dataset.yaml || true && \
                job_name=$(jsonnet -J ml-testing-accelerators/ docker/transformers-pytorch-tpu/bert-base-cased.jsonnet --ext-str image=$GCR_IMAGE_PATH --ext-str image-tag=$CIRCLE_WORKFLOW_JOB_ID | kubectl create -f -) && \
                job_name=${job_name#job.batch/} && \
                job_name=${job_name% created} && \
                echo "Waiting on kubernetes job: $job_name" && \
                i=0 && \
                # 30 checks spaced 30s apart = 900s total.
                max_checks=30 && \
                status_code=2 && \
                # Check on the job periodically. Set the status code depending on what
                # happened to the job in Kubernetes. If we try max_checks times and
                # still the job hasn't finished, give up and return the starting
                # non-zero status code.
                while [ $i -lt $max_checks ]; do ((i++)); if kubectl get jobs $job_name -o jsonpath='Failed:{.status.failed}' | grep "Failed:1"; then status_code=1 && break; elif kubectl get jobs $job_name -o jsonpath='Succeeded:{.status.succeeded}' | grep "Succeeded:1" ; then status_code=0 && break; else echo "Job not finished yet"; fi; sleep 30; done && \
                echo "Done waiting. Job status code: $status_code" && \
45
46
47
                pod_name=$(kubectl get po -l controller-uid=`kubectl get job $job_name -o "jsonpath={.metadata.labels.controller-uid}"` | awk 'match($0,!/NAME/) {print $1}') && \
                echo "GKE pod name: $pod_name" && \
                kubectl logs -f $pod_name --container=train
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
                echo "Done with log retrieval attempt." && \
                gcloud container images delete "$GCR_IMAGE_PATH:$CIRCLE_WORKFLOW_JOB_ID" --force-delete-tags && \
                exit $status_code
    delete_gke_jobs: &delete_gke_jobs
        run:
            name: Delete GKE Jobs
            command: |
                # Match jobs whose age matches patterns like '1h' or '1d', i.e. any job
                # that has been around longer than 1hr. First print all columns for
                # matches, then execute the delete.
                kubectl get job | awk 'match($4,/[0-9]+[dh]/) {print $0}'
                kubectl delete job $(kubectl get job | awk 'match($4,/[0-9]+[dh]/) {print $1}')




Julien Chaumond's avatar
Julien Chaumond committed
64
jobs:
Sylvain Gugger's avatar
Sylvain Gugger committed
65
66
    # Fetch the tests to run
    fetch_tests:
67
        working_directory: ~/transformers
68
        docker:
69
            - image: cimg/python:3.7.12
70
71
72
        parallelism: 1
        steps:
            - checkout
73
            - run: pip install --upgrade pip
Sylvain Gugger's avatar
Sylvain Gugger committed
74
75
76
77
            - run: pip install GitPython
            - run: pip install .
            - run: mkdir -p test_preparation
            - run: python utils/tests_fetcher.py | tee tests_fetched_summary.txt
78
            - store_artifacts:
Sylvain Gugger's avatar
Sylvain Gugger committed
79
                path: ~/transformers/tests_fetched_summary.txt
80
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
81
                if [ -f test_list.txt ]; then
82
                    cp test_list.txt test_preparation/test_list.txt
Sylvain Gugger's avatar
Sylvain Gugger committed
83
84
85
                else
                    touch test_preparation/test_list.txt
                fi
86
87
88
89
90
91
92
93
94
            - run: python utils/tests_fetcher.py --filter_pipeline_tests
            - run: |
                if [ -f test_list.txt ]; then
                    mv test_list.txt test_preparation/filtered_test_list.txt
                else
                    touch test_preparation/filtered_test_list.txt
                fi
            - store_artifacts:
                  path: ~/transformers/test_preparation/filtered_test_list.txt
95
96
97
98
99
100
101
102
103
            - run: python utils/tests_fetcher.py --filters tests examples | tee examples_tests_fetched_summary.txt
            - store_artifacts:
                path: ~/transformers/examples_tests_fetched_summary.txt
            - run: |
                if [ -f test_list.txt ]; then
                    mv test_list.txt test_preparation/examples_test_list.txt
                else
                    touch test_preparation/examples_test_list.txt
                fi
Sylvain Gugger's avatar
Sylvain Gugger committed
104
105
106
107
108

            - persist_to_workspace:
                root: test_preparation/
                paths:
                    test_list.txt
109
                    filtered_test_list.txt
110
                    examples_test_list.txt
111

Sylvain Gugger's avatar
Sylvain Gugger committed
112
113
114
115
116
117
118
119
120
121
    # To run all tests for the nightly build
    fetch_all_tests:
        working_directory: ~/transformers
        docker:
            - image: cimg/python:3.7.12
        parallelism: 1
        steps:
            - run: |
                  mkdir test_preparation
                  echo "tests" > test_preparation/test_list.txt
122
                  echo "tests" > test_preparation/examples_test_list.txt
123
124
            - run: python utils/tests_fetcher.py --filter_pipeline_tests
            - run: mv test_list.txt test_preparation/filtered_test_list.txt
Sylvain Gugger's avatar
Sylvain Gugger committed
125
126
127
128
129
130
131

            - persist_to_workspace:
                  root: test_preparation/
                  paths:
                      test_list.txt

    run_tests_torch_and_tf:
132
133
        working_directory: ~/transformers
        docker:
134
            - image: cimg/python:3.7.12
135
136
137
138
        environment:
            OMP_NUM_THREADS: 1
            RUN_PT_TF_CROSS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
139
            PYTEST_TIMEOUT: 120
140
141
142
143
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
144
145
146
            - attach_workspace:
                at: ~/transformers/test_preparation
            - run: |
147
                if [ ! -s test_preparation/filtered_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
148
149
150
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
151
152
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
153
                      - v0.5-torch_and_tf-{{ checksum "setup.py" }}
154
                      - v0.5-torch_and_tf-
155
156
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng git-lfs
            - run: git lfs install
157
            - run: pip install --upgrade pip
158
            - run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision]
159
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
Kamal Raj's avatar
Kamal Raj committed
160
            - run: pip install tensorflow_probability
161
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
162
            - run: pip install git+https://github.com/huggingface/accelerate
163
            - save_cache:
164
                key: v0.5-torch_and_tf-{{ checksum "setup.py" }}
165
166
                paths:
                    - '~/.cache/pip'
167
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_torch_and_tf $(cat test_preparation/filtered_test_list.txt) -m is_pt_tf_cross_test --durations=0 | tee tests_output.txt
168
169
170
171
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
172

173
174
175
    run_tests_torch_and_flax:
        working_directory: ~/transformers
        docker:
176
            - image: cimg/python:3.7.12
177
178
        environment:
            OMP_NUM_THREADS: 1
179
180
            RUN_PT_FLAX_CROSS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
181
            PYTEST_TIMEOUT: 120
182
183
184
185
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
186
187
            - attach_workspace:
                at: ~/transformers/test_preparation
188
            - run: |
189
                if [ ! -s test_preparation/filtered_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
190
191
192
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
193
194
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
195
                      - v0.5-torch_and_flax-{{ checksum "setup.py" }}
196
                      - v0.5-torch_and_flax-
197
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
198
            - run: pip install --upgrade pip
199
            - run: pip install .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision]
200
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
201
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
202
            - run: pip install git+https://github.com/huggingface/accelerate
203
            - save_cache:
204
                key: v0.5-torch_and_flax-{{ checksum "setup.py" }}
205
206
                paths:
                    - '~/.cache/pip'
207
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_torch_and_flax $(cat test_preparation/filtered_test_list.txt) -m is_pt_flax_cross_test --durations=0 | tee tests_output.txt
208
209
210
211
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
212

Aymeric Augustin's avatar
Aymeric Augustin committed
213
    run_tests_torch:
214
        working_directory: ~/transformers
Julien Chaumond's avatar
Julien Chaumond committed
215
        docker:
216
            - image: cimg/python:3.7.12
217
218
        environment:
            OMP_NUM_THREADS: 1
219
            TRANSFORMERS_IS_CI: yes
220
            PYTEST_TIMEOUT: 120
221
        resource_class: xlarge
222
        parallelism: 1
Julien Chaumond's avatar
Julien Chaumond committed
223
224
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
225
226
            - attach_workspace:
                at: ~/transformers/test_preparation
227
            - run: |
228
                if [ ! -s test_preparation/filtered_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
229
230
231
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
232
233
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
234
                      - v0.5-torch-{{ checksum "setup.py" }}
235
                      - v0.5-torch-
Sylvain Gugger's avatar
Sylvain Gugger committed
236
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng time
237
            - run: pip install --upgrade pip
238
            - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
239
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
240
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
241
            - run: pip install git+https://github.com/huggingface/accelerate
242
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
243
                  key: v0.5-torch-{{ checksum "setup.py" }}
244
245
                  paths:
                      - '~/.cache/pip'
246
            - run: python -m pytest -n 3 --max-worker-restart=0 --dist=loadfile -s --make-reports=tests_torch $(cat test_preparation/filtered_test_list.txt) | tee tests_output.txt
247
248
249
250
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
Lysandre Debut's avatar
Lysandre Debut committed
251

Aymeric Augustin's avatar
Aymeric Augustin committed
252
    run_tests_tf:
253
        working_directory: ~/transformers
thomwolf's avatar
thomwolf committed
254
        docker:
255
            - image: cimg/python:3.7.12
256
257
        environment:
            OMP_NUM_THREADS: 1
258
            TRANSFORMERS_IS_CI: yes
259
            PYTEST_TIMEOUT: 120
thomwolf's avatar
thomwolf committed
260
261
262
263
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
264
265
            - attach_workspace:
                at: ~/transformers/test_preparation
266
            - run: |
267
                if [ ! -s test_preparation/filtered_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
268
269
270
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
271
272
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
273
                      - v0.5-tf-{{ checksum "setup.py" }}
274
                      - v0.5-tf-
275
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
276
            - run: pip install --upgrade pip
277
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision]
Kamal Raj's avatar
Kamal Raj committed
278
            - run: pip install tensorflow_probability
279
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
280
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
281
                  key: v0.5-tf-{{ checksum "setup.py" }}
282
283
                  paths:
                      - '~/.cache/pip'
284
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_tf $(cat test_preparation/filtered_test_list.txt) | tee tests_output.txt
285
286
287
288
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
289

290
291
292
    run_tests_flax:
        working_directory: ~/transformers
        docker:
293
            - image: cimg/python:3.7.12
294
295
        environment:
            OMP_NUM_THREADS: 1
296
            TRANSFORMERS_IS_CI: yes
297
            PYTEST_TIMEOUT: 120
298
299
300
301
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
302
303
            - attach_workspace:
                at: ~/transformers/test_preparation
304
            - run: |
305
                if [ ! -s test_preparation/filtered_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
306
307
308
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
309
310
            - restore_cache:
                keys:
Yih-Dar's avatar
Yih-Dar committed
311
                    - v0.5-flax-{{ checksum "setup.py" }}
312
                    - v0.5-flax-
313
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
314
            - run: pip install --upgrade pip
Sylvain Gugger's avatar
Sylvain Gugger committed
315
            - run: pip install .[flax,testing,sentencepiece,flax-speech,vision]
316
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
317
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
318
                  key: v0.5-flax-{{ checksum "setup.py" }}
319
320
                  paths:
                      - '~/.cache/pip'
321
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_flax $(cat test_preparation/filtered_test_list.txt) | tee tests_output.txt
322
323
324
325
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
326

327
328
329
    run_tests_pipelines_torch:
        working_directory: ~/transformers
        docker:
330
            - image: cimg/python:3.7.12
331
332
        environment:
            OMP_NUM_THREADS: 1
333
            TRANSFORMERS_IS_CI: yes
334
            PYTEST_TIMEOUT: 120
335
336
337
338
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
339
340
            - attach_workspace:
                at: ~/transformers/test_preparation
341
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
342
343
344
345
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
346
347
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
348
                      - v0.5-torch-{{ checksum "setup.py" }}
349
                      - v0.5-torch-
350
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
351
            - run: pip install --upgrade pip
352
            - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
353
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
354
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
355
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
356
                  key: v0.5-torch-{{ checksum "setup.py" }}
357
358
                  paths:
                      - '~/.cache/pip'
359
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_pipelines_torch tests/pipelines | tee tests_output.txt
360
361
362
363
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
364

365
366
367
    run_tests_pipelines_tf:
        working_directory: ~/transformers
        docker:
368
            - image: cimg/python:3.7.12
369
370
        environment:
            OMP_NUM_THREADS: 1
371
            TRANSFORMERS_IS_CI: yes
372
            PYTEST_TIMEOUT: 120
373
374
375
376
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
377
378
            - attach_workspace:
                at: ~/transformers/test_preparation
379
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
380
381
382
383
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
384
385
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
386
                      - v0.5-tf-{{ checksum "setup.py" }}
387
                      - v0.5-tf-
388
389
            - run: pip install --upgrade pip
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece]
Kamal Raj's avatar
Kamal Raj committed
390
            - run: pip install tensorflow_probability
391
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
392
                  key: v0.5-tf-{{ checksum "setup.py" }}
393
394
                  paths:
                      - '~/.cache/pip'
395
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_pipelines_tf tests/pipelines | tee tests_output.txt
396
397
398
399
400
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
401
    run_tests_custom_tokenizers:
402
403
        working_directory: ~/transformers
        docker:
404
            - image: cimg/python:3.7.12
405
406
        environment:
            RUN_CUSTOM_TOKENIZERS: yes
407
            TRANSFORMERS_IS_CI: yes
408
            PYTEST_TIMEOUT: 120
409
410
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
411
412
            - attach_workspace:
                at: ~/transformers/test_preparation
413
            - run: |
414
                if [ ! -s test_preparation/filtered_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
415
416
417
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
418
419
420
            - restore_cache:
                  keys:
                      - v0.5-custom_tokenizers-{{ checksum "setup.py" }}
421
                      - v0.5-custom_tokenizers-
422
423
424
425
426
427
428
429
430
431
            - run: sudo apt-get -y update && sudo apt-get install -y cmake
            - run:
                name: install jumanpp
                command: |
                    wget https://github.com/ku-nlp/jumanpp/releases/download/v2.0.0-rc3/jumanpp-2.0.0-rc3.tar.xz
                    tar xvf jumanpp-2.0.0-rc3.tar.xz
                    mkdir jumanpp-2.0.0-rc3/bld
                    cd jumanpp-2.0.0-rc3/bld
                    sudo cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local
                    sudo make install
432
433
434
435
436
437
438
439
440
441
442
443
444
            - run: pip install --upgrade pip
            - run: pip install .[ja,testing,sentencepiece,jieba,spacy,ftfy,rjieba]
            - run: python -m unidic download
            - save_cache:
                  key: v0.5-custom_tokenizers-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: python -m pytest --max-worker-restart=0 -s --make-reports=tests_custom_tokenizers ./tests/models/bert_japanese/test_tokenization_bert_japanese.py ./tests/models/openai/test_tokenization_openai.py ./tests/models/clip/test_tokenization_clip.py | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
445
    run_examples_torch:
446
447
        working_directory: ~/transformers
        docker:
448
            - image: cimg/python:3.7.12
449
450
        environment:
            OMP_NUM_THREADS: 1
451
            TRANSFORMERS_IS_CI: yes
452
            PYTEST_TIMEOUT: 120
453
454
455
456
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
457
458
            - attach_workspace:
                at: ~/transformers/test_preparation
459
            - run: |
460
                if [ ! -s test_preparation/examples_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
461
462
463
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
464
465
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
466
                      - v0.5-torch_examples-{{ checksum "setup.py" }}
467
                      - v0.5-torch_examples-
468
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
469
            - run: pip install --upgrade pip
470
            - run: pip install .[sklearn,torch,sentencepiece,testing,torch-speech]
471
472
            - run: pip install -r examples/pytorch/_tests_requirements.txt
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
473
                  key: v0.5-torch_examples-{{ checksum "setup.py" }}
474
475
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
476
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -s --make-reports=examples_torch ./examples/pytorch/ | tee tests_output.txt
477
478
479
480
            - store_artifacts:
                  path: ~/transformers/examples_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
481

Matt's avatar
Matt committed
482
483
484
485
486
487
488
489
490
491
492
493
    run_examples_tensorflow:
        working_directory: ~/transformers
        docker:
            - image: cimg/python:3.7.12
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
            PYTEST_TIMEOUT: 120
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
494
495
            - attach_workspace:
                at: ~/transformers/test_preparation
Matt's avatar
Matt committed
496
            - run: |
497
                if [ ! -s test_preparation/examples_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
498
499
500
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
Matt's avatar
Matt committed
501
502
503
            - restore_cache:
                  keys:
                      - v0.5-tensorflow_examples-{{ checksum "setup.py" }}
504
                      - v0.5-tensorflow_examples-
Matt's avatar
Matt committed
505
506
507
508
509
510
511
            - run: pip install --upgrade pip
            - run: pip install .[sklearn,tensorflow,sentencepiece,testing]
            - run: pip install -r examples/tensorflow/_tests_requirements.txt
            - save_cache:
                  key: v0.5-tensorflow_examples-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
512
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -s --make-reports=examples_tensorflow ./examples/tensorflow/ | tee tests_output.txt
Matt's avatar
Matt committed
513
514
515
516
517
            - store_artifacts:
                  path: ~/transformers/tensorflow_examples_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Suraj Patil's avatar
Suraj Patil committed
518
519
520
    run_examples_flax:
        working_directory: ~/transformers
        docker:
521
            - image: cimg/python:3.7.12
Suraj Patil's avatar
Suraj Patil committed
522
523
524
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
525
            PYTEST_TIMEOUT: 120
Suraj Patil's avatar
Suraj Patil committed
526
527
528
529
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
530
531
            - attach_workspace:
                at: ~/transformers/test_preparation
Suraj Patil's avatar
Suraj Patil committed
532
            - run: |
533
                if [ ! -s test_preparation/examples_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
534
535
536
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
Suraj Patil's avatar
Suraj Patil committed
537
538
            - restore_cache:
                keys:
Yih-Dar's avatar
Yih-Dar committed
539
                    - v0.5-flax_examples-{{ checksum "setup.py" }}
540
                    - v0.5-flax_examples-
Suraj Patil's avatar
Suraj Patil committed
541
            - run: pip install --upgrade pip
542
            - run: pip install .[flax,testing,sentencepiece]
Suraj Patil's avatar
Suraj Patil committed
543
544
            - run: pip install -r examples/flax/_tests_requirements.txt
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
545
                  key: v0.5-flax_examples-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
546
547
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
548
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -s --make-reports=examples_flax ./examples/flax/ | tee tests_output.txt
Suraj Patil's avatar
Suraj Patil committed
549
550
551
552
553
            - store_artifacts:
                  path: ~/transformers/flax_examples_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Sylvain Gugger's avatar
Sylvain Gugger committed
554
    run_tests_hub:
555
556
        working_directory: ~/transformers
        docker:
557
            - image: cimg/python:3.7.12
558
        environment:
Sylvain Gugger's avatar
Sylvain Gugger committed
559
            HUGGINGFACE_CO_STAGING: yes
560
561
            RUN_GIT_LFS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
562
            PYTEST_TIMEOUT: 120
563
564
565
566
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
567
568
            - attach_workspace:
                at: ~/transformers/test_preparation
569
            - run: |
570
                if [ ! -s test_preparation/filtered_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
571
572
573
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
574
575
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
576
                      - v0.5-hub-{{ checksum "setup.py" }}
577
                      - v0.5-hub-
578
            - run: sudo apt-get -y update && sudo apt-get install git-lfs
579
580
581
582
583
584
            - run: |
                git config --global user.email "ci@dummy.com"
                git config --global user.name "ci"
            - run: pip install --upgrade pip
            - run: pip install .[torch,sentencepiece,testing]
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
585
                  key: v0.5-hub-{{ checksum "setup.py" }}
586
587
                  paths:
                      - '~/.cache/pip'
588
            - run: python -m pytest --max-worker-restart=0 -sv --make-reports=tests_hub $(cat test_preparation/filtered_test_list.txt) -m is_staging_test | tee tests_output.txt
589
590
591
592
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
593

594
595
596
    run_tests_onnxruntime:
        working_directory: ~/transformers
        docker:
597
            - image: cimg/python:3.7.12
598
599
600
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
601
            PYTEST_TIMEOUT: 120
602
603
604
605
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
606
607
608
            - attach_workspace:
                at: ~/transformers/test_preparation
            - run: |
609
                if [ ! -s test_preparation/filtered_test_list.txt ]; then
Sylvain Gugger's avatar
Sylvain Gugger committed
610
611
612
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
613
614
            - restore_cache:
                  keys:
615
616
                      - v0.5-onnx-{{ checksum "setup.py" }}
                      - v0.5-onnx-
617
            - run: pip install --upgrade pip
618
            - run: pip install .[torch,tf,testing,sentencepiece,onnxruntime,vision,rjieba]
619
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
620
                  key: v0.5-onnx-{{ checksum "setup.py" }}
621
622
                  paths:
                      - '~/.cache/pip'
623
            - run: python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile -s --make-reports=tests_onnx $(cat test_preparation/filtered_test_list.txt) -k onnx | tee tests_output.txt
624

625
626
627
628
629
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
630
631
632
    check_code_quality:
        working_directory: ~/transformers
        docker:
633
            - image: cimg/python:3.7.12
Lysandre's avatar
Lysandre committed
634
        resource_class: large
635
636
        environment:
            TRANSFORMERS_IS_CI: yes
637
            PYTEST_TIMEOUT: 120
Aymeric Augustin's avatar
Aymeric Augustin committed
638
639
640
        parallelism: 1
        steps:
            - checkout
641
642
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
643
                      - v0.5-code_quality-{{ checksum "setup.py" }}
644
                      - v0.5-code_quality-
645
            - run: pip install --upgrade pip
646
            - run: pip install .[all,quality]
647
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
648
                  key: v0.5-code_quality-{{ checksum "setup.py" }}
649
650
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
651
            - run: black --check --preview examples tests src utils
652
            - run: isort --check-only examples tests src utils
Sylvain Gugger's avatar
Sylvain Gugger committed
653
            - run: python utils/custom_init_isort.py --check_only
654
            - run: python utils/sort_auto_mappings.py --check_only
655
            - run: flake8 examples tests src utils
656
            - run: doc-builder style src/transformers docs/source --max_len 119 --check_only --path_to_docs docs/source
Sylvain Gugger's avatar
Sylvain Gugger committed
657
            - run: python utils/check_doc_toc.py
658

659
    check_repository_consistency:
R茅mi Louf's avatar
R茅mi Louf committed
660
661
        working_directory: ~/transformers
        docker:
662
            - image: cimg/python:3.7.12
Sylvain Gugger's avatar
Sylvain Gugger committed
663
664
665
        resource_class: large
        environment:
            TRANSFORMERS_IS_CI: yes
666
            PYTEST_TIMEOUT: 120
R茅mi Louf's avatar
R茅mi Louf committed
667
668
669
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
670
671
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
672
                      - v0.5-repository_consistency-{{ checksum "setup.py" }}
673
                      - v0.5-repository_consistency-
Sylvain Gugger's avatar
Sylvain Gugger committed
674
675
676
            - run: pip install --upgrade pip
            - run: pip install .[all,quality]
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
677
                  key: v0.5-repository_consistency-{{ checksum "setup.py" }}
Sylvain Gugger's avatar
Sylvain Gugger committed
678
679
680
681
682
683
684
                  paths:
                      - '~/.cache/pip'
            - run: python utils/check_copies.py
            - run: python utils/check_table.py
            - run: python utils/check_dummies.py
            - run: python utils/check_repo.py
            - run: python utils/check_inits.py
685
            - run: python utils/check_config_docstrings.py
Sylvain Gugger's avatar
Sylvain Gugger committed
686
687
            - run: make deps_table_check_updated
            - run: python utils/tests_fetcher.py --sanity_check
688
            - run: python utils/update_metadata.py --check-only
689

NielsRogge's avatar
NielsRogge committed
690
    run_tests_layoutlmv2_and_v3:
691
692
        working_directory: ~/transformers
        docker:
693
            - image: cimg/python:3.7.12
694
695
696
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
697
            PYTEST_TIMEOUT: 120
698
699
700
701
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
702
            - attach_workspace:
703
                at: ~/transformers/filtered_test_list.txt
704
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
705
706
707
708
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
709
710
711
            - restore_cache:
                  keys:
                      - v0.5-torch-{{ checksum "setup.py" }}
712
                      - v0.5-torch-
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
            - run: pip install --upgrade pip
            - run: pip install .[torch,testing,vision]
            - run: pip install torchvision
            # The commit `36a65a0907d90ed591479b2ebaa8b61cfa0b4ef0` in `detectron2` break things.
            # See https://github.com/facebookresearch/detectron2/commit/36a65a0907d90ed591479b2ebaa8b61cfa0b4ef0#comments.
            # TODO: Revert this change back once the above issue is fixed.
            - run: python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
            - run: sudo apt install tesseract-ocr
            - run: pip install pytesseract
            - save_cache:
                  key: v0.5-torch-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: python -m pytest -n 1 --max-worker-restart=0 tests/models/*layoutlmv* --dist=loadfile -s --make-reports=tests_layoutlmv2_and_v3 --durations=100
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

733
734
735
# TPU JOBS
    run_examples_tpu:
        docker:
736
            - image: cimg/python:3.7.12
737
738
        environment:
            OMP_NUM_THREADS: 1
739
            TRANSFORMERS_IS_CI: yes
740
741
742
743
744
745
746
747
748
749
750
751
752
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - go/install
            - *checkout_ml_testing
            - gcp-gke/install
            - gcp-gke/update-kubeconfig-with-credentials:
                  cluster: $GKE_CLUSTER
                  perform-login: true
            - setup_remote_docker
            - *build_push_docker
            - *deploy_cluster
753

754
755
    cleanup-gke-jobs:
        docker:
756
            - image: cimg/python:3.7.12
757
758
759
760
761
762
        steps:
            - gcp-gke/install
            - gcp-gke/update-kubeconfig-with-credentials:
                  cluster: $GKE_CLUSTER
                  perform-login: true
            - *delete_gke_jobs
763

LysandreJik's avatar
LysandreJik committed
764
765
766
767
workflow_filters: &workflow_filters
    filters:
        branches:
            only:
768
                - main
769
workflows:
LysandreJik's avatar
LysandreJik committed
770
771
772
    version: 2
    build_and_test:
        jobs:
Aymeric Augustin's avatar
Aymeric Augustin committed
773
            - check_code_quality
774
            - check_repository_consistency
Sylvain Gugger's avatar
Sylvain Gugger committed
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
            - fetch_tests
            - run_examples_torch:
                requires:
                  - fetch_tests
            - run_examples_tensorflow:
                requires:
                  - fetch_tests
            - run_examples_flax:
                requires:
                  - fetch_tests
            - run_tests_custom_tokenizers:
                requires:
                  - fetch_tests
            - run_tests_torch_and_tf:
                requires:
                  - fetch_tests
            - run_tests_torch_and_flax:
                requires:
                  - fetch_tests
            - run_tests_torch:
                requires:
                  - fetch_tests
            - run_tests_tf:
                requires:
                  - fetch_tests
            - run_tests_flax:
                requires:
                  - fetch_tests
            - run_tests_pipelines_torch:
                requires:
                  - fetch_tests
            - run_tests_pipelines_tf:
                requires:
                  - fetch_tests
            - run_tests_onnxruntime:
                requires:
                  - fetch_tests
            - run_tests_hub:
                requires:
                  - fetch_tests
            - run_tests_layoutlmv2_and_v3:
                requires:
                  - fetch_tests
818
819
820
821
822
823
824
    nightly:
        triggers:
            - schedule:
                cron: "0 0 * * *"
                filters:
                    branches:
                        only:
825
                            - main
826
        jobs:
Sylvain Gugger's avatar
Sylvain Gugger committed
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
            - fetch_all_tests
            - run_examples_torch:
                requires:
                  - fetch_all_tests
            - run_examples_tensorflow:
                requires:
                  - fetch_all_tests
            - run_examples_flax:
                requires:
                  - fetch_all_tests
            - run_tests_custom_tokenizers:
                requires:
                  - fetch_all_tests
            - run_tests_torch_and_tf:
                requires:
                  - fetch_all_tests
            - run_tests_torch_and_flax:
                requires:
                  - fetch_all_tests
            - run_tests_torch:
                requires:
                  - fetch_all_tests
            - run_tests_tf:
                requires:
                  - fetch_all_tests
            - run_tests_flax:
                requires:
                  - fetch_all_tests
            - run_tests_pipelines_torch:
                requires:
                  - fetch_all_tests
            - run_tests_pipelines_tf:
                requires:
                  - fetch_all_tests
            - run_tests_onnxruntime:
                requires:
                  - fetch_all_tests
            - run_tests_hub:
                requires:
                  - fetch_all_tests
            - run_tests_layoutlmv2_and_v3:
                requires:
                  - fetch_all_tests
870

871
872
873
874
875
876
877
878
#    tpu_testing_jobs:
#        triggers:
#            - schedule:
#                # Set to run at the first minute of every hour.
#                cron: "0 8 * * *"
#                filters:
#                    branches:
#                        only:
879
#                            - main
880
881
882
#        jobs:
#            - cleanup-gke-jobs
#            - run_examples_tpu