config.yml 39.1 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:
Aymeric Augustin's avatar
Aymeric Augustin committed
65
    run_tests_torch_and_tf:
66
        working_directory: ~/transformers
67
        docker:
Kamal Raj's avatar
Kamal Raj committed
68
            - image: circleci/python:3.7
69
70
        environment:
            OMP_NUM_THREADS: 1
71
72
            RUN_PT_TF_CROSS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
73
74
75
76
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
77
78
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
79
80
                      - v0.4-torch_and_tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
81
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
82
            - run: pip install --upgrade pip
83
            - run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision]
Lysandre Debut's avatar
Lysandre Debut committed
84
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html
Kamal Raj's avatar
Kamal Raj committed
85
            - run: pip install tensorflow_probability
86
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
87
                key: v0.4-{{ checksum "setup.py" }}
88
89
                paths:
                    - '~/.cache/pip'
90
91
92
93
94
95
96
            - run: python utils/tests_fetcher.py | tee test_preparation.txt
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
                    python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_torch_and_tf $(cat test_list.txt) -m is_pt_tf_cross_test --durations=0 | tee tests_output.txt
                  fi
97
            - store_artifacts:
98
99
100
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
    
    run_tests_torch_and_tf_all:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.6
        environment:
            OMP_NUM_THREADS: 1
            RUN_PT_TF_CROSS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-torch_and_tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
            - run: pip install --upgrade pip
120
            - run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,torch-speech,vision]
Lysandre Debut's avatar
Lysandre Debut committed
121
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html
Kamal Raj's avatar
Kamal Raj committed
122
            - run: pip install tensorflow_probability
123
124
125
126
127
128
129
130
131
132
            - save_cache:
                key: v0.4-{{ checksum "setup.py" }}
                paths:
                    - '~/.cache/pip'
            - run: |
                  python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_torch_and_tf tests -m is_pt_tf_cross_test --durations=0 | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
133

134
135
136
137
138
139
    run_tests_torch_and_flax:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.6
        environment:
            OMP_NUM_THREADS: 1
140
141
            RUN_PT_FLAX_CROSS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
142
143
144
145
146
147
148
149
150
151
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-torch_and_flax-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
            - run: pip install --upgrade pip
152
            - run: pip install .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision]
Lysandre Debut's avatar
Lysandre Debut committed
153
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html
154
155
156
157
            - save_cache:
                key: v0.4-{{ checksum "setup.py" }}
                paths:
                    - '~/.cache/pip'
158
159
160
161
162
163
164
            - run: python utils/tests_fetcher.py | tee test_preparation.txt
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
                    python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_torch_and_flax $(cat test_list.txt) -m is_pt_flax_cross_test --durations=0 | tee tests_output.txt
                  fi
165
166
167
168
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
    
    run_tests_torch_and_flax_all:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.6
        environment:
            OMP_NUM_THREADS: 1
            RUN_PT_FLAX_CROSS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-torch_and_flax-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
            - run: pip install --upgrade pip
188
            - run: pip install .[sklearn,flax,torch,testing,sentencepiece,torch-speech,vision]
Lysandre Debut's avatar
Lysandre Debut committed
189
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html
190
191
192
193
194
195
196
197
198
199
            - save_cache:
                key: v0.4-{{ checksum "setup.py" }}
                paths:
                    - '~/.cache/pip'
            - run: |
                  python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_torch_and_flax tests -m is_pt_flax_cross_test --durations=0 | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
200

Aymeric Augustin's avatar
Aymeric Augustin committed
201
    run_tests_torch:
202
        working_directory: ~/transformers
Julien Chaumond's avatar
Julien Chaumond committed
203
        docker:
204
            - image: circleci/python:3.7
205
206
        environment:
            OMP_NUM_THREADS: 1
207
            TRANSFORMERS_IS_CI: yes
208
        resource_class: xlarge
209
        parallelism: 1
Julien Chaumond's avatar
Julien Chaumond committed
210
211
        steps:
            - checkout
212
213
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
214
215
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
216
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
217
            - run: pip install --upgrade pip
218
            - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
Lysandre Debut's avatar
Lysandre Debut committed
219
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html
220
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
221
                  key: v0.4-torch-{{ checksum "setup.py" }}
222
223
                  paths:
                      - '~/.cache/pip'
224
225
226
227
228
229
230
            - run: python utils/tests_fetcher.py | tee test_preparation.txt
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
                    python -m pytest -n 3 --dist=loadfile -s --make-reports=tests_torch $(cat test_list.txt) | tee tests_output.txt
                  fi
231
            - store_artifacts:
232
233
234
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
    
    run_tests_torch_all:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
            - run: pip install --upgrade pip
253
            - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
Lysandre Debut's avatar
Lysandre Debut committed
254
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html
255
256
257
258
259
260
261
262
263
264
            - save_cache:
                  key: v0.4-torch-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: |
                  python -m pytest -n 3 --dist=loadfile -s --make-reports=tests_torch tests | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
Lysandre Debut's avatar
Lysandre Debut committed
265

Aymeric Augustin's avatar
Aymeric Augustin committed
266
    run_tests_tf:
267
        working_directory: ~/transformers
thomwolf's avatar
thomwolf committed
268
        docker:
269
            - image: circleci/python:3.7
270
271
        environment:
            OMP_NUM_THREADS: 1
272
            TRANSFORMERS_IS_CI: yes
thomwolf's avatar
thomwolf committed
273
274
275
276
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
277
278
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
279
280
                      - v0.4-tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
281
            - run: pip install --upgrade pip
282
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision]
Kamal Raj's avatar
Kamal Raj committed
283
            - run: pip install tensorflow_probability
284
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
285
                  key: v0.4-tf-{{ checksum "setup.py" }}
286
287
                  paths:
                      - '~/.cache/pip'
288
289
290
291
292
293
294
            - run: python utils/tests_fetcher.py | tee test_preparation.txt
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
                    python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_tf $(cat test_list.txt) | tee tests_output.txt
                  fi
295
            - store_artifacts:
296
297
298
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
    
    run_tests_tf_all:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: pip install --upgrade pip
316
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece,tf-speech,vision]
Kamal Raj's avatar
Kamal Raj committed
317
            - run: pip install tensorflow_probability
318
319
320
321
322
323
324
325
326
327
            - save_cache:
                  key: v0.4-tf-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: |
                  python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_tf tests | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
328

329
330
331
332
333
334
    run_tests_flax:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
335
            TRANSFORMERS_IS_CI: yes
336
337
338
339
340
341
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                keys:
Lysandre Debut's avatar
Lysandre Debut committed
342
343
                    - v0.4-flax-{{ checksum "setup.py" }}
                    - v0.4-{{ checksum "setup.py" }}
344
            - run: pip install --upgrade pip
345
            - run: sudo pip install .[flax,testing,sentencepiece,flax-speech,vision]
346
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
347
                  key: v0.4-flax-{{ checksum "setup.py" }}
348
349
                  paths:
                      - '~/.cache/pip'
350
351
352
353
354
355
356
            - run: python utils/tests_fetcher.py | tee test_preparation.txt
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
                    python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_flax $(cat test_list.txt) | tee tests_output.txt
                  fi
357
            - store_artifacts:
358
359
360
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
    
    run_tests_flax_all:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                keys:
                    - v0.4-flax-{{ checksum "setup.py" }}
                    - v0.4-{{ checksum "setup.py" }}
            - run: pip install --upgrade pip
378
            - run: sudo pip install .[flax,testing,sentencepiece,vision,flax-speech]
379
380
381
382
383
384
385
386
387
388
            - save_cache:
                  key: v0.4-flax-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: |
                  python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_flax tests | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
389

390
391
392
393
394
395
    run_tests_pipelines_torch:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
396
397
            RUN_PIPELINE_TESTS: yes
            TRANSFORMERS_IS_CI: yes
398
399
400
401
402
403
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
404
405
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
406
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
407
            - run: pip install --upgrade pip
408
            - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
Lysandre Debut's avatar
Lysandre Debut committed
409
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html
410
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
411
                  key: v0.4-torch-{{ checksum "setup.py" }}
412
413
                  paths:
                      - '~/.cache/pip'
414
415
416
417
418
419
420
            - run: python utils/tests_fetcher.py | tee test_preparation.txt
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
                    python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_pipelines_torch -m is_pipeline_test $(cat test_list.txt) | tee tests_output.txt
                  fi
421
            - store_artifacts:
422
423
424
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
    
    run_tests_pipelines_torch_all:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
            RUN_PIPELINE_TESTS: yes
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
            - run: pip install --upgrade pip
444
            - run: pip install .[sklearn,torch,testing,sentencepiece,torch-speech,vision,timm]
Lysandre Debut's avatar
Lysandre Debut committed
445
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html
446
447
448
449
450
451
452
453
454
455
            - save_cache:
                  key: v0.4-torch-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: |
                  python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_pipelines_torch -m is_pipeline_test tests | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
456

457
458
459
460
461
462
    run_tests_pipelines_tf:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
463
464
            RUN_PIPELINE_TESTS: yes
            TRANSFORMERS_IS_CI: yes
465
466
467
468
469
470
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
471
472
                      - v0.4-tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
473
            - run: pip install --upgrade pip
474
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece]
Kamal Raj's avatar
Kamal Raj committed
475
            - run: pip install tensorflow_probability
476
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
477
                  key: v0.4-tf-{{ checksum "setup.py" }}
478
479
                  paths:
                      - '~/.cache/pip'
480
481
482
483
484
485
486
            - run: python utils/tests_fetcher.py | tee test_preparation.txt
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
                    python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_pipelines_tf $(cat test_list.txt) -m is_pipeline_test | tee tests_output.txt
                  fi
487
488
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
489
            - store_artifacts:
490
491
                  path: ~/transformers/reports

492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
    run_tests_pipelines_tf_all:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
            RUN_PIPELINE_TESTS: yes
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: pip install --upgrade pip
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece]
Kamal Raj's avatar
Kamal Raj committed
510
            - run: pip install tensorflow_probability
511
512
513
514
515
            - save_cache:
                  key: v0.4-tf-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: |
516
                  python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_pipelines_tf tests -m is_pipeline_test | tee tests_output.txt
517
518
519
520
521
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
522
    run_tests_custom_tokenizers:
523
524
        working_directory: ~/transformers
        docker:
525
            - image: circleci/python:3.7
526
527
        environment:
            RUN_CUSTOM_TOKENIZERS: yes
528
            TRANSFORMERS_IS_CI: yes
529
530
        steps:
            - checkout
531
532
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
533
534
                      - v0.4-custom_tokenizers-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
535
            - run: pip install --upgrade pip
536
            - run: pip install .[ja,testing,sentencepiece,jieba]
537
            - run: python -m unidic download
538
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
539
                  key: v0.4-custom_tokenizers-{{ checksum "setup.py" }}
540
541
                  paths:
                      - '~/.cache/pip'
542
543
544
545
            - run: |
                  if [ -f test_list.txt ]; then
                    python -m pytest -s --make-reports=tests_custom_tokenizers ./tests/test_tokenization_bert_japanese.py | tee tests_output.txt
                  fi
546
547
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
548
            - store_artifacts:
549
550
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
551
    run_examples_torch:
552
553
        working_directory: ~/transformers
        docker:
554
            - image: circleci/python:3.6
555
556
        environment:
            OMP_NUM_THREADS: 1
557
            TRANSFORMERS_IS_CI: yes
558
559
560
561
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
562
563
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
564
565
                      - v0.4-torch_examples-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
566
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
567
            - run: pip install --upgrade pip
568
            - run: pip install .[sklearn,torch,sentencepiece,testing,torch-speech]
Sylvain Gugger's avatar
Sylvain Gugger committed
569
            - run: pip install -r examples/pytorch/_tests_requirements.txt
570
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
571
                  key: v0.4-torch_examples-{{ checksum "setup.py" }}
572
573
                  paths:
                      - '~/.cache/pip'
574
            - run: python utils/tests_fetcher.py --filters examples tests | tee test_preparation.txt
575
576
577
578
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
579
                    python -m pytest -n 8 --dist=loadfile -s --make-reports=examples_torch ./examples/pytorch/ | tee tests_output.txt
580
                  fi
581
            - store_artifacts:
582
583
584
                  path: ~/transformers/examples_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
    
    run_examples_torch_all:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.6
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-torch_examples-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
601
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
602
            - run: pip install --upgrade pip
603
            - run: pip install .[sklearn,torch,sentencepiece,testing,torch-speech]
604
605
606
607
608
609
610
611
612
613
614
            - run: pip install -r examples/pytorch/_tests_requirements.txt
            - save_cache:
                  key: v0.4-torch_examples-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: |
                  TRANSFORMERS_IS_CI=1 python -m pytest -n 8 --dist=loadfile -s --make-reports=examples_torch ./examples/pytorch/ | tee examples_output.txt
            - store_artifacts:
                  path: ~/transformers/examples_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
615

Sylvain Gugger's avatar
Sylvain Gugger committed
616
    run_tests_hub:
617
618
619
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
620
        environment:
Sylvain Gugger's avatar
Sylvain Gugger committed
621
            HUGGINGFACE_CO_STAGING: yes
622
623
            RUN_GIT_LFS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
624
625
626
627
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
628
629
630
631
            - restore_cache:
                  keys:
                      - v0.4-hub-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
632
633
634
635
636
            - run: sudo apt-get install git-lfs
            - run: |
                git config --global user.email "ci@dummy.com"
                git config --global user.name "ci"
            - run: pip install --upgrade pip
Sylvain Gugger's avatar
Sylvain Gugger committed
637
638
639
640
641
            - run: pip install .[torch,sentencepiece,testing]
            - save_cache:
                  key: v0.4-hub-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
642
643
644
645
646
            - run: python utils/tests_fetcher.py | tee test_preparation.txt
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
647
                    python -m pytest -sv --make-reports=tests_hub $(cat test_list.txt) -m is_staging_test | tee tests_output.txt
648
                  fi
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
    
    run_tests_hub_all:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            HUGGINGFACE_CO_STAGING: yes
            RUN_GIT_LFS_TESTS: yes
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-hub-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: sudo apt-get install git-lfs
            - 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:
                  key: v0.4-hub-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: |
                  python -m pytest -sv --make-reports=tests_hub tests -m is_staging_test | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
686

687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
    run_tests_onnxruntime:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: pip install --upgrade pip
            - run: pip install .[torch,testing,sentencepiece,onnxruntime]
            - save_cache:
                  key: v0.4-onnx-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
708
709
710
711
712
            - run: python utils/tests_fetcher.py | tee test_preparation.txt
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
713
                    python -m pytest -n 1 --dist=loadfile -s --make-reports=tests_onnx $(cat test_list.txt) -k onnx | tee tests_output.txt
714
                  fi
715
716
717
718
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
    
    run_tests_onnxruntime_all:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: pip install --upgrade pip
            - run: pip install .[torch,testing,sentencepiece,onnxruntime]
            - save_cache:
                  key: v0.4-onnx-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: |
                  python -m pytest -n 1 --dist=loadfile -s --make-reports=tests_onnx tests -k onnx | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

748
749
750
    build_doc:
        working_directory: ~/transformers
        docker:
751
            - image: circleci/python:3.6
Lysandre's avatar
Lysandre committed
752
        resource_class: large
753
754
        steps:
            - checkout
755
756
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
757
758
                      - v0.4-build_doc-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
759
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
760
            - run: pip install --upgrade pip
761
            - run: pip install ."[docs]"
Lysandre Debut's avatar
Lysandre Debut committed
762
            - run: pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-1.10.0+cpu.html
763
            - run: pip install pytorch-quantization --extra-index-url https://pypi.ngc.nvidia.com
764
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
765
                  key: v0.4-build_doc-{{ checksum "setup.py" }}
766
767
                  paths:
                      - '~/.cache/pip'
Stas Bekman's avatar
Stas Bekman committed
768
            - run: cd docs && make html SPHINXOPTS="-W -j 4"
769
770
            - store_artifacts:
                path: ./docs/_build
771

LysandreJik's avatar
LysandreJik committed
772
    deploy_doc:
773
        working_directory: ~/transformers
LysandreJik's avatar
LysandreJik committed
774
        docker:
775
            - image: circleci/python:3.6
Lysandre's avatar
Lysandre committed
776
        resource_class: large
LysandreJik's avatar
LysandreJik committed
777
778
        steps:
            - add_ssh_keys:
779
780
                fingerprints:
                    - "5b:7a:95:18:07:8c:aa:76:4c:60:35:88:ad:60:56:71"
LysandreJik's avatar
LysandreJik committed
781
            - checkout
782
783
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
784
785
                      - v0.4-deploy_doc-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
Sylvain Gugger's avatar
Sylvain Gugger committed
786
787
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
            - run: pip install --upgrade pip
788
            - run: pip install ."[docs]"
789
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
790
                  key: v0.4-deploy_doc-{{ checksum "setup.py" }}
791
792
                  paths:
                      - '~/.cache/pip'
Lysandre's avatar
Lysandre committed
793
            - run: ./.circleci/deploy.sh
794

Aymeric Augustin's avatar
Aymeric Augustin committed
795
796
797
798
    check_code_quality:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.6
Lysandre's avatar
Lysandre committed
799
        resource_class: large
800
801
        environment:
            TRANSFORMERS_IS_CI: yes
Aymeric Augustin's avatar
Aymeric Augustin committed
802
803
804
        parallelism: 1
        steps:
            - checkout
805
806
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
807
808
                      - v0.4-code_quality-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
809
            - run: pip install --upgrade pip
810
            - run: pip install .[all,quality]
811
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
812
                  key: v0.4-code_quality-{{ checksum "setup.py" }}
813
814
                  paths:
                      - '~/.cache/pip'
815
816
            - run: black --check examples tests src utils
            - run: isort --check-only examples tests src utils
Sylvain Gugger's avatar
Sylvain Gugger committed
817
            - run: python utils/custom_init_isort.py --check_only
818
            - run: flake8 examples tests src utils
Sylvain Gugger's avatar
Sylvain Gugger committed
819
            - run: python utils/style_doc.py src/transformers docs/source --max_len 119 --check_only
820

821
    check_repository_consistency:
R茅mi Louf's avatar
R茅mi Louf committed
822
823
        working_directory: ~/transformers
        docker:
824
            - image: circleci/python:3.6
Sylvain Gugger's avatar
Sylvain Gugger committed
825
826
827
        resource_class: large
        environment:
            TRANSFORMERS_IS_CI: yes
R茅mi Louf's avatar
R茅mi Louf committed
828
829
830
        parallelism: 1
        steps:
            - checkout
Sylvain Gugger's avatar
Sylvain Gugger committed
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
            - restore_cache:
                  keys:
                      - v0.4-repository_consistency-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
            - run: pip install --upgrade pip
            - run: pip install .[all,quality]
            - save_cache:
                  key: v0.4-repository_consistency-{{ checksum "setup.py" }}
                  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
            - run: make deps_table_check_updated
            - run: python utils/tests_fetcher.py --sanity_check
848

849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
    run_tests_layoutlmv2:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
            TRANSFORMERS_IS_CI: yes
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ 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
            - 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.4-torch-{{ checksum "setup.py" }}
                  paths:
                      - '~/.cache/pip'
            - run: python utils/tests_fetcher.py | tee test_preparation.txt
            - store_artifacts:
                  path: ~/transformers/test_preparation.txt
            - run: |
                  if [ -f test_list.txt ]; then
                    python -m pytest -n 1 tests/*layoutlmv2* --dist=loadfile -s --make-reports=tests_layoutlmv2 --durations=100
                  fi
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

887
888
889
890
891
892
# TPU JOBS
    run_examples_tpu:
        docker:
            - image: circleci/python:3.6
        environment:
            OMP_NUM_THREADS: 1
893
            TRANSFORMERS_IS_CI: yes
894
895
896
897
898
899
900
901
902
903
904
905
906
        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
907

908
909
910
911
912
913
914
915
916
    cleanup-gke-jobs:
        docker:
            - image: circleci/python:3.6
        steps:
            - gcp-gke/install
            - gcp-gke/update-kubeconfig-with-credentials:
                  cluster: $GKE_CLUSTER
                  perform-login: true
            - *delete_gke_jobs
917

LysandreJik's avatar
LysandreJik committed
918
919
920
921
workflow_filters: &workflow_filters
    filters:
        branches:
            only:
Lysandre's avatar
Lysandre committed
922
                - master
923
workflows:
LysandreJik's avatar
LysandreJik committed
924
925
926
    version: 2
    build_and_test:
        jobs:
Aymeric Augustin's avatar
Aymeric Augustin committed
927
            - check_code_quality
928
            - check_repository_consistency
Aymeric Augustin's avatar
Aymeric Augustin committed
929
930
931
            - run_examples_torch
            - run_tests_custom_tokenizers
            - run_tests_torch_and_tf
932
            - run_tests_torch_and_flax
Aymeric Augustin's avatar
Aymeric Augustin committed
933
934
            - run_tests_torch
            - run_tests_tf
935
            - run_tests_flax
936
937
            - run_tests_pipelines_torch
            - run_tests_pipelines_tf
938
            - run_tests_onnxruntime
Sylvain Gugger's avatar
Sylvain Gugger committed
939
            - run_tests_hub
940
            - build_doc
941
            - run_tests_layoutlmv2
Lysandre's avatar
Lysandre committed
942
            - deploy_doc: *workflow_filters
943
944
945
946
947
948
949
950
951
    nightly:
        triggers:
            - schedule:
                cron: "0 0 * * *"
                filters:
                    branches:
                        only:
                            - master
        jobs:
952
            - run_examples_torch_all
953
954
955
956
957
958
959
960
961
962
            - run_tests_torch_and_tf_all
            - run_tests_torch_and_flax_all
            - run_tests_torch_all
            - run_tests_tf_all
            - run_tests_flax_all
            - run_tests_pipelines_torch_all
            - run_tests_pipelines_tf_all
            - run_tests_onnxruntime_all
            - run_tests_hub_all

963
964
965
966
967
968
969
970
971
972
973
974
#    tpu_testing_jobs:
#        triggers:
#            - schedule:
#                # Set to run at the first minute of every hour.
#                cron: "0 8 * * *"
#                filters:
#                    branches:
#                        only:
#                            - master
#        jobs:
#            - cleanup-gke-jobs
#            - run_examples_tpu