2020-08-07 23:17:07 +08:00
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
2020-08-11 14:48:49 +08:00
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
2020-08-07 23:17:07 +08:00
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" && \
# Allow time for logs to flush.
sleep 60 && \
echo "JOB_NAME: $job_name" && \
gcloud logging read "resource.type=k8s_container resource.labels.project_id=$GOOGLE_PROJECT_ID resource.labels.location=$GOOGLE_COMPUTE_ZONE resource.labels.cluster_name=$GKE_CLUSTER resource.labels.namespace_name=default resource.labels.pod_name:$job_name" --limit 10000000 --order asc --format 'value(textPayload)' --project=$GOOGLE_PROJECT_ID && \
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}')
2018-12-21 05:33:39 +08:00
jobs :
2019-12-23 01:21:35 +08:00
run_tests_torch_and_tf :
2019-09-26 16:15:53 +08:00
working_directory : ~/transformers
2019-09-24 19:25:50 +08:00
docker :
2020-03-17 22:17:11 +08:00
- image : circleci/python:3.6
2019-12-21 03:56:59 +08:00
environment :
OMP_NUM_THREADS : 1
2019-09-24 19:25:50 +08:00
resource_class : xlarge
parallelism : 1
steps :
- checkout
2020-08-07 14:48:59 +08:00
- restore_cache :
keys :
- v0.3-torch_and_tf-{{ checksum "setup.py" }}
- v0.3-{{ checksum "setup.py" }}
- run : pip install --upgrade pip
- run : pip install .[sklearn,tf-cpu,torch,testing]
- run : pip install codecov pytest-cov
- save_cache :
key : v0.3-{{ checksum "setup.py" }}
paths :
- '~/.cache/pip'
2020-06-27 01:59:31 +08:00
- run : python -m pytest -n 8 --dist=loadfile -s ./tests/ --cov | tee output.txt
2019-09-24 19:25:50 +08:00
- run : codecov
2020-06-27 01:59:31 +08:00
- store_artifacts :
path : ~/transformers/output.txt
destination : test_output.txt
2019-12-23 01:21:35 +08:00
run_tests_torch :
2019-09-26 16:15:53 +08:00
working_directory : ~/transformers
2018-12-21 05:33:39 +08:00
docker :
2019-12-23 04:35:09 +08:00
- image : circleci/python:3.7
2019-12-21 03:56:59 +08:00
environment :
OMP_NUM_THREADS : 1
2019-09-03 00:35:14 +08:00
resource_class : xlarge
2019-08-31 08:33:16 +08:00
parallelism : 1
2018-12-21 05:33:39 +08:00
steps :
- checkout
2020-08-07 14:48:59 +08:00
- restore_cache :
keys :
- v0.3-torch-{{ checksum "setup.py" }}
- v0.3-{{ checksum "setup.py" }}
- run : pip install --upgrade pip
- run : pip install .[sklearn,torch,testing]
- save_cache :
key : v0.3-torch-{{ checksum "setup.py" }}
paths :
- '~/.cache/pip'
2020-06-27 01:59:31 +08:00
- run : python -m pytest -n 8 --dist=loadfile -s ./tests/ | tee output.txt
- store_artifacts :
path : ~/transformers/output.txt
destination : test_output.txt
2019-12-23 01:21:35 +08:00
run_tests_tf :
2019-09-26 16:15:53 +08:00
working_directory : ~/transformers
2019-09-05 16:23:04 +08:00
docker :
2019-12-23 04:35:09 +08:00
- image : circleci/python:3.7
2019-12-21 03:56:59 +08:00
environment :
OMP_NUM_THREADS : 1
2019-09-05 16:23:04 +08:00
resource_class : xlarge
parallelism : 1
steps :
- checkout
2020-08-07 14:48:59 +08:00
- restore_cache :
keys :
- v0.3-tf-{{ checksum "setup.py" }}
- v0.3-{{ checksum "setup.py" }}
- run : pip install --upgrade pip
- run : pip install .[sklearn,tf-cpu,testing]
- save_cache :
key : v0.3-tf-{{ checksum "setup.py" }}
paths :
- '~/.cache/pip'
2020-06-27 01:59:31 +08:00
- run : python -m pytest -n 8 --dist=loadfile -s ./tests/ | tee output.txt
- store_artifacts :
path : ~/transformers/output.txt
destination : test_output.txt
2019-12-23 01:21:35 +08:00
run_tests_custom_tokenizers :
2019-12-11 05:43:49 +08:00
working_directory : ~/transformers
docker :
2020-03-17 22:17:11 +08:00
- image : circleci/python:3.6
2019-12-24 16:09:13 +08:00
environment :
RUN_CUSTOM_TOKENIZERS : yes
2019-12-11 05:43:49 +08:00
steps :
- checkout
2020-08-07 14:48:59 +08:00
- restore_cache :
keys :
- v0.3-custom_tokenizers-{{ checksum "setup.py" }}
- v0.3-{{ checksum "setup.py" }}
- run : pip install --upgrade pip
- run : pip install .[ja,testing]
- save_cache :
key : v0.3-custom_tokenizers-{{ checksum "setup.py" }}
paths :
- '~/.cache/pip'
2020-07-01 04:12:14 +08:00
- run : python -m pytest -s ./tests/test_tokenization_bert_japanese.py | tee output.txt
- store_artifacts :
path : ~/transformers/output.txt
destination : test_output.txt
2019-12-23 01:21:35 +08:00
run_examples_torch :
2019-12-21 03:56:59 +08:00
working_directory : ~/transformers
docker :
2020-03-17 22:17:11 +08:00
- image : circleci/python:3.6
2019-12-21 03:56:59 +08:00
environment :
OMP_NUM_THREADS : 1
resource_class : xlarge
parallelism : 1
steps :
- checkout
2020-08-07 14:48:59 +08:00
- restore_cache :
keys :
- v0.3-torch_examples-{{ checksum "setup.py" }}
- v0.3-{{ checksum "setup.py" }}
- run : pip install --upgrade pip
- run : pip install .[sklearn,torch,testing]
- run : pip install -r examples/requirements.txt
- save_cache :
key : v0.3-torch_examples-{{ checksum "setup.py" }}
paths :
- '~/.cache/pip'
2020-07-27 02:09:14 +08:00
- run : python -m pytest -n 8 --dist=loadfile -rA -s ./examples/ | tee output.txt
2020-06-27 01:59:31 +08:00
- store_artifacts :
path : ~/transformers/output.txt
destination : test_output.txt
2020-04-17 23:23:18 +08:00
build_doc :
working_directory : ~/transformers
docker :
- image : circleci/python:3.6
steps :
- checkout
2020-08-07 14:48:59 +08:00
- restore_cache :
keys :
- v0.3-build_doc-{{ checksum "setup.py" }}
- v0.3-{{ checksum "setup.py" }}
- run : pip install --upgrade pip
- run : pip install .[tf,torch,docs]
- save_cache :
key : v0.3-build_doc-{{ checksum "setup.py" }}
paths :
- '~/.cache/pip'
2020-06-23 03:49:50 +08:00
- run : cd docs && make html SPHINXOPTS="-W"
2020-04-17 23:23:18 +08:00
- store_artifacts :
path : ./docs/_build
2019-08-30 00:14:29 +08:00
deploy_doc :
2019-09-26 16:15:53 +08:00
working_directory : ~/transformers
2019-08-30 00:14:29 +08:00
docker :
2020-03-17 22:17:11 +08:00
- image : circleci/python:3.6
2019-08-30 00:14:29 +08:00
steps :
- add_ssh_keys :
2019-12-24 16:09:13 +08:00
fingerprints :
- "5b:7a:95:18:07:8c:aa:76:4c:60:35:88:ad:60:56:71"
2019-08-30 00:14:29 +08:00
- checkout
2020-08-07 14:48:59 +08:00
- restore_cache :
keys :
- v0.3-deploy_doc-{{ checksum "setup.py" }}
- v0.3-{{ checksum "setup.py" }}
- run : pip install .[tf,torch,docs]
- save_cache :
key : v0.3-deploy_doc-{{ checksum "setup.py" }}
paths :
- '~/.cache/pip'
2019-10-23 05:53:52 +08:00
- run : ./.circleci/deploy.sh
2019-12-21 22:49:11 +08:00
check_code_quality :
working_directory : ~/transformers
docker :
- image : circleci/python:3.6
2019-12-21 22:58:40 +08:00
resource_class : medium
2019-12-21 22:49:11 +08:00
parallelism : 1
steps :
- checkout
2020-08-07 14:48:59 +08:00
- restore_cache :
keys :
- v0.3-code_quality-{{ checksum "setup.py" }}
- v0.3-{{ checksum "setup.py" }}
- run : pip install --upgrade pip
2020-03-25 00:10:43 +08:00
# we need a version of isort with https://github.com/timothycrosley/isort/pull/1000
2020-08-07 14:48:59 +08:00
- run : pip install git+git://github.com/timothycrosley/isort.git@e63ae06ec7d70b06df9e528357650281a3d3ec22#egg=isort
- run : pip install .[tf,torch,quality]
- save_cache :
key : v0.3-code_quality-{{ checksum "setup.py" }}
paths :
- '~/.cache/pip'
2019-12-28 05:47:59 +08:00
- run : black --check --line-length 119 --target-version py35 examples templates tests src utils
2019-12-22 20:54:22 +08:00
- run : isort --check-only --recursive examples templates tests src utils
- run : flake8 examples templates tests src utils
2019-12-21 03:56:59 +08:00
check_repository_consistency :
2019-12-06 04:24:57 +08:00
working_directory : ~/transformers
docker :
2020-03-17 22:17:11 +08:00
- image : circleci/python:3.6
2019-12-06 04:24:57 +08:00
resource_class : small
parallelism : 1
steps :
- checkout
2020-08-07 14:48:59 +08:00
- run : pip install requests
2019-12-06 04:24:57 +08:00
- run : python ./utils/link_tester.py
2020-08-07 23:17:07 +08:00
# 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
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
2019-08-30 00:14:29 +08:00
workflow_filters : &workflow_filters
filters :
branches :
only :
2019-10-23 06:01:10 +08:00
- master
2019-02-06 07:25:12 +08:00
workflows :
2019-08-30 00:14:29 +08:00
version : 2
build_and_test :
jobs :
2019-12-21 22:49:11 +08:00
- check_code_quality
2019-12-21 03:56:59 +08:00
- check_repository_consistency
2019-12-23 01:21:35 +08:00
- run_examples_torch
- run_tests_custom_tokenizers
- run_tests_torch_and_tf
- run_tests_torch
- run_tests_tf
2020-04-17 23:23:18 +08:00
- build_doc
2019-10-23 05:51:30 +08:00
- deploy_doc : *workflow_filters
2020-08-10 14:11:40 +08:00
# 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