config.yml 34.5 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
82
83
84
85
86
87
88
89
90
                if [ -f test_list.txt ]; then
                    mv test_list.txt test_preparation/test_list.txt
                else
                    touch test_preparation/test_list.txt
                fi

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

Sylvain Gugger's avatar
Sylvain Gugger committed
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
    # 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

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

    run_tests_torch_and_tf:
109
110
        working_directory: ~/transformers
        docker:
111
            - image: cimg/python:3.7.12
112
113
114
115
        environment:
            OMP_NUM_THREADS: 1
            RUN_PT_TF_CROSS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
116
            PYTEST_TIMEOUT: 120
117
118
119
120
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
121
122
123
124
125
126
127
            - attach_workspace:
                at: ~/transformers/test_preparation
            - run: |
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
128
129
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
130
131
                      - v0.5-torch_and_tf-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
132
133
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng git-lfs
            - run: git lfs install
134
            - run: pip install --upgrade pip
135
            - run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision]
136
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
Kamal Raj's avatar
Kamal Raj committed
137
            - run: pip install tensorflow_probability
138
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
139
            - run: pip install git+https://github.com/huggingface/accelerate
140
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
141
                key: v0.5-{{ checksum "setup.py" }}
142
143
                paths:
                    - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
144
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_torch_and_tf $(cat test_preparation/test_list.txt) -m is_pt_tf_cross_test --durations=0 | tee tests_output.txt
145
146
147
148
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
149

150
151
152
    run_tests_torch_and_flax:
        working_directory: ~/transformers
        docker:
153
            - image: cimg/python:3.7.12
154
155
        environment:
            OMP_NUM_THREADS: 1
156
157
            RUN_PT_FLAX_CROSS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
158
            PYTEST_TIMEOUT: 120
159
160
161
162
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
163
164
            - attach_workspace:
                at: ~/transformers/test_preparation
165
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
166
167
168
169
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
170
171
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
172
173
                      - v0.5-torch_and_flax-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
174
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
175
            - run: pip install --upgrade pip
176
            - run: pip install .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision]
177
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
178
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
179
            - run: pip install git+https://github.com/huggingface/accelerate
180
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
181
                key: v0.5-{{ checksum "setup.py" }}
182
183
                paths:
                    - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
184
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_torch_and_flax $(cat test_preparation/test_list.txt) -m is_pt_flax_cross_test --durations=0 | tee tests_output.txt
185
186
187
188
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
189

Aymeric Augustin's avatar
Aymeric Augustin committed
190
    run_tests_torch:
191
        working_directory: ~/transformers
Julien Chaumond's avatar
Julien Chaumond committed
192
        docker:
193
            - image: cimg/python:3.7.12
194
195
        environment:
            OMP_NUM_THREADS: 1
196
            TRANSFORMERS_IS_CI: yes
197
            PYTEST_TIMEOUT: 120
198
        resource_class: xlarge
199
        parallelism: 1
Julien Chaumond's avatar
Julien Chaumond committed
200
201
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
202
203
            - attach_workspace:
                at: ~/transformers/test_preparation
204
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
205
206
207
208
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
209
210
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
211
212
                      - v0.5-torch-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
Sylvain Gugger's avatar
Sylvain Gugger committed
213
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng time
214
            - run: pip install --upgrade pip
215
            - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
216
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
217
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
218
            - run: pip install git+https://github.com/huggingface/accelerate
219
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
220
                  key: v0.5-torch-{{ checksum "setup.py" }}
221
222
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
223
            - run: python -m pytest -n 3 --max-worker-restart=0 --dist=loadfile -s --make-reports=tests_torch $(cat test_preparation/test_list.txt) | tee tests_output.txt
224
225
226
227
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
Lysandre Debut's avatar
Lysandre Debut committed
228

Aymeric Augustin's avatar
Aymeric Augustin committed
229
    run_tests_tf:
230
        working_directory: ~/transformers
thomwolf's avatar
thomwolf committed
231
        docker:
232
            - image: cimg/python:3.7.12
233
234
        environment:
            OMP_NUM_THREADS: 1
235
            TRANSFORMERS_IS_CI: yes
236
            PYTEST_TIMEOUT: 120
thomwolf's avatar
thomwolf committed
237
238
239
240
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
241
242
            - attach_workspace:
                at: ~/transformers/test_preparation
243
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
244
245
246
247
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
248
249
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
250
251
                      - v0.5-tf-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
252
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
253
            - run: pip install --upgrade pip
254
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision]
Kamal Raj's avatar
Kamal Raj committed
255
            - run: pip install tensorflow_probability
256
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
257
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
258
                  key: v0.5-tf-{{ checksum "setup.py" }}
259
260
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
261
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_tf $(cat test_preparation/test_list.txt) | tee tests_output.txt
262
263
264
265
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
266

267
268
269
    run_tests_flax:
        working_directory: ~/transformers
        docker:
270
            - image: cimg/python:3.7.12
271
272
        environment:
            OMP_NUM_THREADS: 1
273
            TRANSFORMERS_IS_CI: yes
274
            PYTEST_TIMEOUT: 120
275
276
277
278
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
279
280
            - attach_workspace:
                at: ~/transformers/test_preparation
281
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
282
283
284
285
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
286
287
            - restore_cache:
                keys:
Yih-Dar's avatar
Yih-Dar committed
288
289
                    - v0.5-flax-{{ checksum "setup.py" }}
                    - v0.5-{{ checksum "setup.py" }}
290
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
291
            - run: pip install --upgrade pip
Sylvain Gugger's avatar
Sylvain Gugger committed
292
            - run: pip install .[flax,testing,sentencepiece,flax-speech,vision]
293
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
294
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
295
                  key: v0.5-flax-{{ checksum "setup.py" }}
296
297
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
298
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_flax $(cat test_preparation/test_list.txt) | tee tests_output.txt
299
300
301
302
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
303

304
305
306
    run_tests_pipelines_torch:
        working_directory: ~/transformers
        docker:
307
            - image: cimg/python:3.7.12
308
309
        environment:
            OMP_NUM_THREADS: 1
310
311
            RUN_PIPELINE_TESTS: yes
            TRANSFORMERS_IS_CI: yes
312
            PYTEST_TIMEOUT: 120
313
314
315
316
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
317
318
            - attach_workspace:
                at: ~/transformers/test_preparation
319
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
320
321
322
323
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
324
325
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
326
327
                      - v0.5-torch-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
328
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
329
            - run: pip install --upgrade pip
330
            - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
331
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.12.0+cpu.html
332
            - run: pip install https://github.com/kpu/kenlm/archive/master.zip
333
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
334
                  key: v0.5-torch-{{ checksum "setup.py" }}
335
336
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
337
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_pipelines_torch -m is_pipeline_test $(cat test_preparation/test_list.txt) | tee tests_output.txt
338
339
340
341
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
342

343
344
345
    run_tests_pipelines_tf:
        working_directory: ~/transformers
        docker:
346
            - image: cimg/python:3.7.12
347
348
        environment:
            OMP_NUM_THREADS: 1
349
350
            RUN_PIPELINE_TESTS: yes
            TRANSFORMERS_IS_CI: yes
351
            PYTEST_TIMEOUT: 120
352
353
354
355
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
356
357
            - attach_workspace:
                at: ~/transformers/test_preparation
358
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
359
360
361
362
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
363
364
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
365
366
                      - v0.5-tf-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
367
368
            - run: pip install --upgrade pip
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece]
Kamal Raj's avatar
Kamal Raj committed
369
            - run: pip install tensorflow_probability
370
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
371
                  key: v0.5-tf-{{ checksum "setup.py" }}
372
373
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
374
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -rA -s --make-reports=tests_pipelines_tf $(cat test_preparation/test_list.txt) -m is_pipeline_test | tee tests_output.txt
375
376
377
378
379
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
380
    run_tests_custom_tokenizers:
381
382
        working_directory: ~/transformers
        docker:
383
            - image: cimg/python:3.7.12
384
385
        environment:
            RUN_CUSTOM_TOKENIZERS: yes
386
            TRANSFORMERS_IS_CI: yes
387
            PYTEST_TIMEOUT: 120
388
389
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
390
391
            - attach_workspace:
                at: ~/transformers/test_preparation
392
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
393
394
395
396
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
            - restore_cache:
                  keys:
                      - v0.5-custom_tokenizers-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
            - 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
414
    run_examples_torch:
415
416
        working_directory: ~/transformers
        docker:
417
            - image: cimg/python:3.7.12
418
419
        environment:
            OMP_NUM_THREADS: 1
420
            TRANSFORMERS_IS_CI: yes
421
            PYTEST_TIMEOUT: 120
422
423
424
425
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
426
427
            - attach_workspace:
                at: ~/transformers/test_preparation
428
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
429
430
431
432
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
433
434
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
435
436
                      - v0.5-torch_examples-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
437
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev espeak-ng
438
            - run: pip install --upgrade pip
439
            - run: pip install .[sklearn,torch,sentencepiece,testing,torch-speech]
440
441
            - run: pip install -r examples/pytorch/_tests_requirements.txt
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
442
                  key: v0.5-torch_examples-{{ checksum "setup.py" }}
443
444
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
445
            - run: python -m pytest -n 8 --max-worker-restart=0 --dist=loadfile -s --make-reports=examples_torch ./examples/pytorch/ | tee tests_output.txt
446
447
448
449
            - store_artifacts:
                  path: ~/transformers/examples_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
450

Matt's avatar
Matt committed
451
452
453
454
455
456
457
458
459
460
461
462
    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
463
464
            - attach_workspace:
                at: ~/transformers/test_preparation
Matt's avatar
Matt committed
465
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
466
467
468
469
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
Matt's avatar
Matt committed
470
471
472
473
474
475
476
477
478
479
480
            - restore_cache:
                  keys:
                      - v0.5-tensorflow_examples-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
            - 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
481
            - 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
482
483
484
485
486
            - store_artifacts:
                  path: ~/transformers/tensorflow_examples_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Suraj Patil's avatar
Suraj Patil committed
487
488
489
    run_examples_flax:
        working_directory: ~/transformers
        docker:
490
            - image: cimg/python:3.7.12
Suraj Patil's avatar
Suraj Patil committed
491
492
493
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
494
            PYTEST_TIMEOUT: 120
Suraj Patil's avatar
Suraj Patil committed
495
496
497
498
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
499
500
            - attach_workspace:
                at: ~/transformers/test_preparation
Suraj Patil's avatar
Suraj Patil committed
501
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
502
503
504
505
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
Suraj Patil's avatar
Suraj Patil committed
506
507
            - restore_cache:
                keys:
Yih-Dar's avatar
Yih-Dar committed
508
509
                    - v0.5-flax_examples-{{ checksum "setup.py" }}
                    - v0.5-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
510
            - run: pip install --upgrade pip
511
            - run: pip install .[flax,testing,sentencepiece]
Suraj Patil's avatar
Suraj Patil committed
512
513
            - run: pip install -r examples/flax/_tests_requirements.txt
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
514
                  key: v0.5-flax_examples-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
515
516
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
517
            - 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
518
519
520
521
522
            - store_artifacts:
                  path: ~/transformers/flax_examples_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Sylvain Gugger's avatar
Sylvain Gugger committed
523
    run_tests_hub:
524
525
        working_directory: ~/transformers
        docker:
526
            - image: cimg/python:3.7.12
527
        environment:
Sylvain Gugger's avatar
Sylvain Gugger committed
528
            HUGGINGFACE_CO_STAGING: yes
529
530
            RUN_GIT_LFS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
531
            PYTEST_TIMEOUT: 120
532
533
534
535
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
536
537
            - attach_workspace:
                at: ~/transformers/test_preparation
538
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
539
540
541
542
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
543
544
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
545
546
                      - v0.5-hub-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
547
            - run: sudo apt-get -y update && sudo apt-get install git-lfs
548
549
550
551
552
553
            - 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
554
                  key: v0.5-hub-{{ checksum "setup.py" }}
555
556
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
557
            - run: python -m pytest --max-worker-restart=0 -sv --make-reports=tests_hub $(cat test_preparation/test_list.txt) -m is_staging_test | tee tests_output.txt
558
559
560
561
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
562

563
564
565
    run_tests_onnxruntime:
        working_directory: ~/transformers
        docker:
566
            - image: cimg/python:3.7.12
567
568
569
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
570
            PYTEST_TIMEOUT: 120
571
572
573
574
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
575
576
577
578
579
580
581
            - attach_workspace:
                at: ~/transformers/test_preparation
            - run: |
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
582
583
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
584
585
                      - v0.5-torch-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
586
            - run: pip install --upgrade pip
587
            - run: pip install .[torch,tf,testing,sentencepiece,onnxruntime,vision,rjieba]
588
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
589
                  key: v0.5-onnx-{{ checksum "setup.py" }}
590
591
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
592
            - run: python -m pytest -n 1 --max-worker-restart=0 --dist=loadfile -s --make-reports=tests_onnx $(cat test_preparation/test_list.txt) -k onnx | tee tests_output.txt
593

594
595
596
597
598
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
599
600
601
    check_code_quality:
        working_directory: ~/transformers
        docker:
602
            - image: cimg/python:3.7.12
Lysandre's avatar
Lysandre committed
603
        resource_class: large
604
605
        environment:
            TRANSFORMERS_IS_CI: yes
606
            PYTEST_TIMEOUT: 120
Aymeric Augustin's avatar
Aymeric Augustin committed
607
608
609
        parallelism: 1
        steps:
            - checkout
610
611
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
612
613
                      - v0.5-code_quality-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
614
            - run: pip install --upgrade pip
615
            - run: pip install .[all,quality]
616
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
617
                  key: v0.5-code_quality-{{ checksum "setup.py" }}
618
619
                  paths:
                      - '~/.cache/pip'
Sylvain Gugger's avatar
Sylvain Gugger committed
620
            - run: black --check --preview examples tests src utils
621
            - run: isort --check-only examples tests src utils
Sylvain Gugger's avatar
Sylvain Gugger committed
622
            - run: python utils/custom_init_isort.py --check_only
623
            - run: python utils/sort_auto_mappings.py --check_only
624
            - run: flake8 examples tests src utils
625
            - 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
626
            - run: python utils/check_doc_toc.py
627

628
    check_repository_consistency:
R茅mi Louf's avatar
R茅mi Louf committed
629
630
        working_directory: ~/transformers
        docker:
631
            - image: cimg/python:3.7.12
Sylvain Gugger's avatar
Sylvain Gugger committed
632
633
634
        resource_class: large
        environment:
            TRANSFORMERS_IS_CI: yes
635
            PYTEST_TIMEOUT: 120
R茅mi Louf's avatar
R茅mi Louf committed
636
637
638
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
639
640
            - restore_cache:
                  keys:
Yih-Dar's avatar
Yih-Dar committed
641
642
                      - v0.5-repository_consistency-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
Sylvain Gugger's avatar
Sylvain Gugger committed
643
644
645
            - run: pip install --upgrade pip
            - run: pip install .[all,quality]
            - save_cache:
Yih-Dar's avatar
Yih-Dar committed
646
                  key: v0.5-repository_consistency-{{ checksum "setup.py" }}
Sylvain Gugger's avatar
Sylvain Gugger committed
647
648
649
650
651
652
653
                  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
654
            - run: python utils/check_config_docstrings.py
Sylvain Gugger's avatar
Sylvain Gugger committed
655
656
            - run: make deps_table_check_updated
            - run: python utils/tests_fetcher.py --sanity_check
657
            - run: python utils/update_metadata.py --check-only
658

NielsRogge's avatar
NielsRogge committed
659
    run_tests_layoutlmv2_and_v3:
660
661
        working_directory: ~/transformers
        docker:
662
            - image: cimg/python:3.7.12
663
664
665
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
666
            PYTEST_TIMEOUT: 120
667
668
669
670
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
671
672
            - attach_workspace:
                at: ~/transformers/test_preparation
673
            - run: |
Sylvain Gugger's avatar
Sylvain Gugger committed
674
675
676
677
                if [ ! -s test_preparation/test_list.txt ]; then
                    echo "No tests to run, exiting early!"
                    circleci-agent step halt
                fi
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
            - restore_cache:
                  keys:
                      - v0.5-torch-{{ checksum "setup.py" }}
                      - v0.5-{{ checksum "setup.py" }}
            - 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

702
703
704
# TPU JOBS
    run_examples_tpu:
        docker:
705
            - image: cimg/python:3.7.12
706
707
        environment:
            OMP_NUM_THREADS: 1
708
            TRANSFORMERS_IS_CI: yes
709
710
711
712
713
714
715
716
717
718
719
720
721
        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
722

723
724
    cleanup-gke-jobs:
        docker:
725
            - image: cimg/python:3.7.12
726
727
728
729
730
731
        steps:
            - gcp-gke/install
            - gcp-gke/update-kubeconfig-with-credentials:
                  cluster: $GKE_CLUSTER
                  perform-login: true
            - *delete_gke_jobs
732

LysandreJik's avatar
LysandreJik committed
733
734
735
736
workflow_filters: &workflow_filters
    filters:
        branches:
            only:
737
                - main
738
workflows:
LysandreJik's avatar
LysandreJik committed
739
740
741
    version: 2
    build_and_test:
        jobs:
Aymeric Augustin's avatar
Aymeric Augustin committed
742
            - check_code_quality
743
            - check_repository_consistency
Sylvain Gugger's avatar
Sylvain Gugger committed
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
            - 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
787
788
789
790
791
792
793
    nightly:
        triggers:
            - schedule:
                cron: "0 0 * * *"
                filters:
                    branches:
                        only:
794
                            - main
795
        jobs:
Sylvain Gugger's avatar
Sylvain Gugger committed
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
            - 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
839

840
841
842
843
844
845
846
847
#    tpu_testing_jobs:
#        triggers:
#            - schedule:
#                # Set to run at the first minute of every hour.
#                cron: "0 8 * * *"
#                filters:
#                    branches:
#                        only:
848
#                            - main
849
850
851
#        jobs:
#            - cleanup-gke-jobs
#            - run_examples_tpu