"ppocr/metrics/DetMetric.py" did not exist on "10f7e5192d0d5e58793d1618e52f7de1214131e0"
config.yml 17.8 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
commands:
  skip-job-on-doc-only-changes:
    description: "Do not continue this job and exit with success for PRs with only doc changes"
    steps:

      - run:
          name: docs-only changes skip check
          command: |
14
            # pipeline.git.base_revision is not always defined, so only proceed if all external vars are defined
15
            if test -n "<< pipeline.git.base_revision >>" && test -n "<< pipeline.git.revision >>" && test -n "$(git diff --name-only << pipeline.git.base_revision >>...<< pipeline.git.revision >>)"
16
            then
17
                git diff --name-only << pipeline.git.base_revision >>...<< pipeline.git.revision >> 
18
19
20
21
22
                if git diff --name-only << pipeline.git.base_revision >>...<< pipeline.git.revision >> | egrep -qv '\.(md|rst)$'
                then
                    echo "Non-docs were modified in this PR, proceeding normally"
                else
                    echo "Only docs were modified in this PR, quitting this job"
23
24
                    # disable skipping for now, as circleCI's base_revision is inconsistent leading to invalid ranges
                    # circleci step halt
25
                fi
26
            else
27
                echo "Can't perform skipping check w/o base_revision defined, continuing the job"
28
29
            fi

30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 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
46
                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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
                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" && \
69
70
71
                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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
                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
88
jobs:
Aymeric Augustin's avatar
Aymeric Augustin committed
89
    run_tests_torch_and_tf:
90
        working_directory: ~/transformers
91
        docker:
92
            - image: circleci/python:3.6
93
94
        environment:
            OMP_NUM_THREADS: 1
95
96
97
98
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
99
            - skip-job-on-doc-only-changes
100
101
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
102
103
                      - v0.4-torch_and_tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
104
            - run: pip install --upgrade pip
105
            - run: pip install .[sklearn,tf-cpu,torch,testing,sentencepiece]
106
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
107
                key: v0.4-{{ checksum "setup.py" }}
108
109
                paths:
                    - '~/.cache/pip'
110
            - 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
111
            - store_artifacts:
112
113
114
115
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
116
    run_tests_torch:
117
        working_directory: ~/transformers
Julien Chaumond's avatar
Julien Chaumond committed
118
        docker:
119
            - image: circleci/python:3.7
120
121
        environment:
            OMP_NUM_THREADS: 1
122
        resource_class: xlarge
123
        parallelism: 1
Julien Chaumond's avatar
Julien Chaumond committed
124
125
        steps:
            - checkout
126
            - skip-job-on-doc-only-changes
127
128
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
129
130
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
131
            - run: pip install --upgrade pip
132
            - run: pip install .[sklearn,torch,testing,sentencepiece]
133
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
134
                  key: v0.4-torch-{{ checksum "setup.py" }}
135
136
                  paths:
                      - '~/.cache/pip'
137
            - run: python -m pytest -n 8 --dist=loadfile -s --make-reports=tests_torch ./tests/ | tee tests_output.txt
138
            - store_artifacts:
139
140
141
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
Lysandre Debut's avatar
Lysandre Debut committed
142

Aymeric Augustin's avatar
Aymeric Augustin committed
143
    run_tests_tf:
144
        working_directory: ~/transformers
thomwolf's avatar
thomwolf committed
145
        docker:
146
            - image: circleci/python:3.7
147
148
        environment:
            OMP_NUM_THREADS: 1
thomwolf's avatar
thomwolf committed
149
150
151
152
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
153
            - skip-job-on-doc-only-changes
154
155
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
156
157
                      - v0.4-tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
158
            - run: pip install --upgrade pip
159
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece]
160
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
161
                  key: v0.4-tf-{{ checksum "setup.py" }}
162
163
                  paths:
                      - '~/.cache/pip'
164
            - run: python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_tf ./tests/ | tee tests_output.txt
165
            - store_artifacts:
166
167
168
169
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

170
171
172
173
174
175
176
177
178
179
    run_tests_flax:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.7
        environment:
            OMP_NUM_THREADS: 1
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
180
            - skip-job-on-doc-only-changes
181
182
            - restore_cache:
                keys:
Lysandre Debut's avatar
Lysandre Debut committed
183
184
                    - v0.4-flax-{{ checksum "setup.py" }}
                    - v0.4-{{ checksum "setup.py" }}
185
            - run: pip install --upgrade pip
186
            - run: sudo pip install .[flax,sklearn,torch,testing,sentencepiece]
187
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
188
                  key: v0.4-flax-{{ checksum "setup.py" }}
189
190
                  paths:
                      - '~/.cache/pip'
191
            - run: python -m pytest -n 8 --dist=loadfile -rA -s --make-reports=tests_flax ./tests/ | tee tests_output.txt
192
            - store_artifacts:
193
194
195
196
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

197
198
199
200
201
202
203
204
205
206
    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
207
            - skip-job-on-doc-only-changes
208
209
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
210
211
                      - v0.4-torch-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
212
            - run: pip install --upgrade pip
213
            - run: pip install .[sklearn,torch,testing,sentencepiece]
214
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
215
                  key: v0.4-torch-{{ checksum "setup.py" }}
216
217
                  paths:
                      - '~/.cache/pip'
218
            - 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
219
            - store_artifacts:
220
221
222
223
                  path: ~/transformers/tests_output.txt
            - store_artifacts:
                  path: ~/transformers/reports

224
225
226
227
228
229
230
231
232
233
    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
234
            - skip-job-on-doc-only-changes
235
236
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
237
238
                      - v0.4-tf-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
239
            - run: pip install --upgrade pip
240
            - run: pip install .[sklearn,tf-cpu,testing,sentencepiece]
241
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
242
                  key: v0.4-tf-{{ checksum "setup.py" }}
243
244
                  paths:
                      - '~/.cache/pip'
245
246
247
            - 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
248
            - store_artifacts:
249
250
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
251
    run_tests_custom_tokenizers:
252
253
        working_directory: ~/transformers
        docker:
254
            - image: circleci/python:3.7
255
256
        environment:
            RUN_CUSTOM_TOKENIZERS: yes
257
258
        steps:
            - checkout
259
            - skip-job-on-doc-only-changes
260
261
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
262
263
                      - v0.4-custom_tokenizers-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
264
            - run: pip install --upgrade pip
265
            - run: pip install .[ja,testing,sentencepiece]
266
            - run: python -m unidic download
267
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
268
                  key: v0.4-custom_tokenizers-{{ checksum "setup.py" }}
269
270
                  paths:
                      - '~/.cache/pip'
271
272
273
            - 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
274
            - store_artifacts:
275
276
                  path: ~/transformers/reports

Aymeric Augustin's avatar
Aymeric Augustin committed
277
    run_examples_torch:
278
279
        working_directory: ~/transformers
        docker:
280
            - image: circleci/python:3.6
281
282
283
284
285
286
        environment:
            OMP_NUM_THREADS: 1
        resource_class: xlarge
        parallelism: 1
        steps:
            - checkout
287
            - skip-job-on-doc-only-changes
288
289
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
290
291
                      - v0.4-torch_examples-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
292
            - run: pip install --upgrade pip
293
            - run: pip install .[sklearn,torch,sentencepiece,testing]
294
295
            - run: pip install -r examples/requirements.txt
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
296
                  key: v0.4-torch_examples-{{ checksum "setup.py" }}
297
298
                  paths:
                      - '~/.cache/pip'
299
            - run: python -m pytest -n 8 --dist=loadfile -s --make-reports=examples_torch ./examples/ | tee examples_output.txt
300
            - store_artifacts:
301
302
303
                  path: ~/transformers/examples_output.txt
            - store_artifacts:
                  path: ~/transformers/reports
304

305
306
307
308
309
310
    build_doc:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.6
        steps:
            - checkout
311
312
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
313
314
                      - v0.4-build_doc-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
315
            - run: pip install --upgrade pip
316
            - run: pip install ."[all, docs]"
317
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
318
                  key: v0.4-build_doc-{{ checksum "setup.py" }}
319
320
                  paths:
                      - '~/.cache/pip'
321
            - run: cd docs && make html SPHINXOPTS="-W"
322
323
            - store_artifacts:
                path: ./docs/_build
324

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

Aymeric Augustin's avatar
Aymeric Augustin committed
345
346
347
348
    check_code_quality:
        working_directory: ~/transformers
        docker:
            - image: circleci/python:3.6
Aymeric Augustin's avatar
Aymeric Augustin committed
349
        resource_class: medium
Aymeric Augustin's avatar
Aymeric Augustin committed
350
351
352
        parallelism: 1
        steps:
            - checkout
353
354
            - restore_cache:
                  keys:
Lysandre Debut's avatar
Lysandre Debut committed
355
356
                      - v0.4-code_quality-{{ checksum "setup.py" }}
                      - v0.4-{{ checksum "setup.py" }}
357
            - run: pip install --upgrade pip
358
            - run: pip install isort
359
            - run: pip install .[all,quality]
360
            - save_cache:
Lysandre Debut's avatar
Lysandre Debut committed
361
                  key: v0.4-code_quality-{{ checksum "setup.py" }}
362
363
                  paths:
                      - '~/.cache/pip'
364
365
366
            - 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
367
            - run: python utils/style_doc.py src/transformers docs/source --max_len 119 --check_only
368
            - run: python utils/check_copies.py
369
            - run: python utils/check_dummies.py
370
            - run: python utils/check_repo.py
371

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

# 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
402

403
404
405
406
407
408
409
410
411
    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
412

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