config.yml 17.6 KB
Newer Older
1
2
3
4
5
version: 2.1
orbs:
    gcp-gke: circleci/gcp-gke@1.0.4
    go: circleci/go@1.3.0

6

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# 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
23
                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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
                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" && \
46
47
48
                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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
                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
65
jobs:
Aymeric Augustin's avatar
Aymeric Augustin committed
66
    run_tests_torch_and_tf:
67
        working_directory: ~/transformers
68
        docker:
69
            - image: circleci/python:3.6
70
71
        environment:
            OMP_NUM_THREADS: 1
72
73
74
75
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
76
77
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
78
79
                      - v0.4-torch_and_tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
80
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
81
            - run: pip install --upgrade pip
Suraj Patil's avatar
Suraj Patil committed
82
            - run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece,speech]
83
            - run: pip install tapas torch-scatter -f https://pytorch-geometric.com/whl/torch-1.8.0+cpu.html
84
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
85
                key: v0.4-{{ checksum "setup.py" }}
86
87
                paths:
                    - '~/.cache/pip'
88
            - run: RUN_PT_TF_CROSS_TESTS=1 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
89
            - store_artifacts:
90
91
92
93
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
94
    run_tests_torch:
95
        working_directory: ~/transformers
Julien Chaumond's avatar
Julien Chaumond committed
96
        docker:
97
            - image: circleci/python:3.7
98
99
        environment:
            OMP_NUM_THREADS: 1
100
        resource_class: xlarge
101
        parallelism: 1
Julien Chaumond's avatar
Julien Chaumond committed
102
103
        steps:
            - checkout
104
105
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
106
107
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
108
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
109
            - run: pip install --upgrade pip
Suraj Patil's avatar
Suraj Patil committed
110
            - run: pip install .[sklearn,torch,testing,sentencepiece,speech]
111
            - run: pip install tapas torch-scatter -f https://pytorch-geometric.com/whl/torch-1.8.0+cpu.html
112
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
113
                  key: v0.4-torch-{{ checksum "setup.py" }}
114
115
                  paths:
                      - '~/.cache/pip'
116
            - run: python -m pytest -n 8 --dist=loadfile -s --make-reports=tests_torch ./tests/ | tee tests_output.txt
117
            - store_artifacts:
118
119
120
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
Lysandre Debut's avatar
Lysandre Debut committed
121

Aymeric Augustin's avatar
Aymeric Augustin committed
122
    run_tests_tf:
123
        working_directory: ~/transformers
thomwolf's avatar
thomwolf committed
124
        docker:
125
            - image: circleci/python:3.7
126
127
        environment:
            OMP_NUM_THREADS: 1
thomwolf's avatar
thomwolf committed
128
129
130
131
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
132
133
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
134
135
                      - v0.4-tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
136
            - run: pip install --upgrade pip
137
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece]
138
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
139
                  key: v0.4-tf-{{ checksum "setup.py" }}
140
141
                  paths:
                      - '~/.cache/pip'
142
            - run: python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_tf ./tests/ | tee tests_output.txt
143
            - store_artifacts:
144
145
146
147
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

148
149
150
151
152
153
154
155
156
157
158
159
    run_tests_flax:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                keys:
Lysandre Debut's avatar
Lysandre Debut committed
160
161
                    - v0.4-flax-{{ checksum "setup.py" }}
                    - v0.4-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
162
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
163
            - run: pip install --upgrade pip
Suraj Patil's avatar
Suraj Patil committed
164
            - run: sudo pip install .[flax,sklearn,torch,testing,sentencepiece,speech]
165
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
166
                  key: v0.4-flax-{{ checksum "setup.py" }}
167
168
                  paths:
                      - '~/.cache/pip'
169
            - run: python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_flax ./tests/ | tee tests_output.txt
170
            - store_artifacts:
171
172
173
174
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

175
176
177
178
179
180
181
182
183
184
185
186
    run_tests_pipelines_torch:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
187
188
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
189
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
190
            - run: pip install --upgrade pip
Suraj Patil's avatar
Suraj Patil committed
191
            - run: pip install .[sklearn,torch,testing,sentencepiece,speech]
192
            - run: pip install tapas torch-scatter -f https://pytorch-geometric.com/whl/torch-1.8.0+cpu.html
193
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
194
                  key: v0.4-torch-{{ checksum "setup.py" }}
195
196
                  paths:
                      - '~/.cache/pip'
197
            - run: RUN_PIPELINE_TESTS=1 python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_pipelines_torch -m is_pipeline_test ./tests/ | tee tests_output.txt
198
            - store_artifacts:
199
200
201
202
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

203
204
205
206
207
208
209
210
211
212
213
214
    run_tests_pipelines_tf:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
215
216
                      - v0.4-tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
217
            - run: pip install --upgrade pip
218
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece]
219
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
220
                  key: v0.4-tf-{{ checksum "setup.py" }}
221
222
                  paths:
                      - '~/.cache/pip'
223
224
225
            - run: RUN_PIPELINE_TESTS=1 python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_pipelines_tf ./tests/ -m is_pipeline_test | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
226
            - store_artifacts:
227
228
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
229
    run_tests_custom_tokenizers:
230
231
        working_directory: ~/transformers
        docker:
232
            - image: circleci/python:3.7
233
234
        environment:
            RUN_CUSTOM_TOKENIZERS: yes
235
236
        steps:
            - checkout
237
238
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
239
240
                      - v0.4-custom_tokenizers-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
241
            - run: pip install --upgrade pip
242
            - run: pip install .[ja,testing,sentencepiece]
243
            - run: python -m unidic download
244
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
245
                  key: v0.4-custom_tokenizers-{{ checksum "setup.py" }}
246
247
                  paths:
                      - '~/.cache/pip'
248
249
250
            - run: python -m pytest -s --make-reports=tests_custom_tokenizers ./tests/test_tokenization_bert_japanese.py | tee tests_output.txt
            - store_artifacts:
                  path: ~/transformers/tests_output.txt
251
            - store_artifacts:
252
253
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
254
    run_examples_torch:
255
256
        working_directory: ~/transformers
        docker:
257
            - image: circleci/python:3.6
258
259
260
261
262
263
        environment:
            OMP_NUM_THREADS: 1
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
264
265
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
266
267
                      - v0.4-torch_examples-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
268
            - run: pip install --upgrade pip
269
            - run: pip install .[sklearn,torch,sentencepiece,testing]
Sylvain Gugger's avatar
Sylvain Gugger committed
270
            - run: pip install -r examples/_tests_requirements.txt
271
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
272
                  key: v0.4-torch_examples-{{ checksum "setup.py" }}
273
274
                  paths:
                      - '~/.cache/pip'
275
            - run: python -m pytest -n 8 --dist=loadfile -s --make-reports=examples_torch ./examples/ | tee examples_output.txt
276
            - store_artifacts:
277
278
279
                  path: ~/transformers/examples_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
280

281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
    run_tests_git_lfs:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
            - 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 .[testing]
            - run: RUN_GIT_LFS_TESTS=1 python -m pytest -sv ./tests/test_hf_api.py -k "HfLargefilesTest"

297
298
299
300
301
302
    build_doc:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.6
        steps:
            - checkout
303
304
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
305
306
                      - v0.4-build_doc-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
Suraj Patil's avatar
Suraj Patil committed
307
            - run: sudo apt-get -y update && sudo apt-get install -y libsndfile1-dev
308
            - run: pip install --upgrade pip
309
            - run: pip install ."[all, docs]"
310
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
311
                  key: v0.4-build_doc-{{ checksum "setup.py" }}
312
313
                  paths:
                      - '~/.cache/pip'
Stas Bekman's avatar
Stas Bekman committed
314
            - run: cd docs && make html SPHINXOPTS="-W -j 4"
315
316
            - store_artifacts:
                path: ./docs/_build
317

LysandreJik's avatar
LysandreJik committed
318
    deploy_doc:
319
        working_directory: ~/transformers
LysandreJik's avatar
LysandreJik committed
320
        docker:
321
            - image: circleci/python:3.6
LysandreJik's avatar
LysandreJik committed
322
323
        steps:
            - add_ssh_keys:
324
325
                fingerprints:
                    - "5b:7a:95:18:07:8c:aa:76:4c:60:35:88:ad:60:56:71"
LysandreJik's avatar
LysandreJik committed
326
            - checkout
327
328
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
329
330
                      - v0.4-deploy_doc-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
331
            - run: pip install ."[all,docs]"
332
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
333
                  key: v0.4-deploy_doc-{{ checksum "setup.py" }}
334
335
                  paths:
                      - '~/.cache/pip'
Lysandre's avatar
Lysandre committed
336
            - run: ./.circleci/deploy.sh
337

Aymeric Augustin's avatar
Aymeric Augustin committed
338
339
340
341
    check_code_quality:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.6
Aymeric Augustin's avatar
Aymeric Augustin committed
342
        resource_class: medium
Aymeric Augustin's avatar
Aymeric Augustin committed
343
344
345
        parallelism: 1
        steps:
            - checkout
346
347
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
348
349
                      - v0.4-code_quality-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
350
            - run: pip install --upgrade pip
351
            - run: pip install isort
352
            - run: pip install .[all,quality]
353
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
354
                  key: v0.4-code_quality-{{ checksum "setup.py" }}
355
356
                  paths:
                      - '~/.cache/pip'
357
358
359
            - run: black --check examples tests src utils
            - run: isort --check-only examples tests src utils
            - run: flake8 examples tests src utils
Sylvain Gugger's avatar
Sylvain Gugger committed
360
            - run: python utils/style_doc.py src/transformers docs/source --max_len 119 --check_only
361
            - run: python utils/check_copies.py
362
            - run: python utils/check_table.py
363
            - run: python utils/check_dummies.py
364
            - run: python utils/check_repo.py
365

366
    check_repository_consistency:
R茅mi Louf's avatar
R茅mi Louf committed
367
368
        working_directory: ~/transformers
        docker:
369
            - image: circleci/python:3.6
R茅mi Louf's avatar
R茅mi Louf committed
370
371
372
373
        resource_class: small
        parallelism: 1
        steps:
            - checkout
374
            - run: pip install requests
R茅mi Louf's avatar
R茅mi Louf committed
375
            - run: python ./utils/link_tester.py
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395

# TPU JOBS
    run_examples_tpu:
        docker:
            - image: circleci/python:3.6
        environment:
            OMP_NUM_THREADS: 1
        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
396

397
398
399
400
401
402
403
404
405
    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
406

LysandreJik's avatar
LysandreJik committed
407
408
409
410
workflow_filters: &workflow_filters
    filters:
        branches:
            only:
Lysandre's avatar
Lysandre committed
411
                - master
412
workflows:
LysandreJik's avatar
LysandreJik committed
413
414
415
    version: 2
    build_and_test:
        jobs:
Aymeric Augustin's avatar
Aymeric Augustin committed
416
            - check_code_quality
417
            - check_repository_consistency
Aymeric Augustin's avatar
Aymeric Augustin committed
418
419
420
421
422
            - run_examples_torch
            - run_tests_custom_tokenizers
            - run_tests_torch_and_tf
            - run_tests_torch
            - run_tests_tf
423
            - run_tests_flax
424
425
            - run_tests_pipelines_torch
            - run_tests_pipelines_tf
426
            - run_tests_git_lfs
427
            - build_doc
Lysandre's avatar
Lysandre committed
428
            - deploy_doc: *workflow_filters
429
430
431
432
433
434
435
436
437
438
439
440
#    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