forked from d2l-ai/d2l-en
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
89 lines (80 loc) · 2.93 KB
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
stage("Build and Publish") {
// such as d2l-en and d2l-zh
def REPO_NAME = env.JOB_NAME.split('/')[0]
// such as en and zh
def LANG = REPO_NAME.split('-')[1]
// The current branch or the branch this PR will merge into
def TARGET_BRANCH = env.CHANGE_TARGET ? env.CHANGE_TARGET : env.BRANCH_NAME
// such as d2l-en-master
def TASK = REPO_NAME + '-' + TARGET_BRANCH
node {
ws("workspace/${TASK}") {
checkout scm
// conda environment
def ENV_NAME = "${TASK}-${EXECUTOR_NUMBER}";
// assign two GPUs to each build
def EID = EXECUTOR_NUMBER.toInteger()
def CUDA_VISIBLE_DEVICES=(EID*2).toString() + ',' + (EID*2+1).toString();
sh label: "Build Environment", script: """set -ex
conda env update -n ${ENV_NAME} -f static/build.yml
pip list
nvidia-smi
"""
sh label: "Sanity Check", script: """set -ex
conda activate ${ENV_NAME}
d2lbook build outputcheck tabcheck
"""
sh label: "Execute Notebooks", script: """set -ex
conda activate ${ENV_NAME}
export CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}
./static/cache.sh restore _build/eval/data
d2lbook build eval
./static/cache.sh store _build/eval/data
"""
sh label: "Execute Notebooks [PyTorch]", script: """set -ex
conda activate ${ENV_NAME}
export CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}
./static/cache.sh restore _build/eval_pytorch/data
d2lbook build eval --tab pytorch
./static/cache.sh store _build/eval_pytorch/data
"""
sh label: "Execute Notebooks [TensorFlow]", script: """set -ex
conda activate ${ENV_NAME}
export CUDA_VISIBLE_DEVICES=${CUDA_VISIBLE_DEVICES}
./static/cache.sh restore _build/eval_tensorflow/data
export TF_CPP_MIN_LOG_LEVEL=3
d2lbook build eval --tab tensorflow
./static/cache.sh store _build/eval_tensorflow/data
"""
sh label:"Build HTML", script:"""set -ex
conda activate ${ENV_NAME}
./static/build_html.sh
"""
sh label:"Build PDF", script:"""set -ex
conda activate ${ENV_NAME}
d2lbook build pdf
"""
if (env.BRANCH_NAME == 'release') {
sh label:"Release", script:"""set -ex
conda activate ${ENV_NAME}
d2lbook build pkg
d2lbook deploy html pdf pkg colab sagemaker --s3 s3://en.d2l.ai/
"""
sh label:"Release d2l", script:"""set -ex
conda activate ${ENV_NAME}
pip install setuptools wheel twine
python setup.py bdist_wheel
# twine upload dist/*
"""
} else {
sh label:"Publish", script:"""set -ex
conda activate ${ENV_NAME}
d2lbook deploy html pdf --s3 s3://preview.d2l.ai/${JOB_NAME}/
"""
if (env.BRANCH_NAME.startsWith("PR-")) {
pullRequest.comment("Job ${JOB_NAME}/${BUILD_NUMBER} is complete. \nCheck the results at http://preview.d2l.ai/${JOB_NAME}/")
}
}
}
}
}