@@ -65,14 +65,17 @@ if [[ "${JOB_BASE_NAME}" == *worker_* ]]; then
65
65
rm beginner_source/aws_distributed_training_tutorial.py || true
66
66
67
67
# Step 2: Keep certain tutorials based on file count, and remove runnable code in all other tutorials
68
+ # IMPORTANT NOTE: We assume that each tutorial has a UNIQUE filename.
68
69
export WORKER_ID=$( echo " ${JOB_BASE_NAME} " | tr -dc ' 0-9' )
69
70
count=0
71
+ FILES_TO_RUN=()
70
72
for filename in $( find beginner_source/ -name ' *.py' -not -path ' */data/*' ) ; do
71
73
if [ $(( $count % $NUM_WORKERS )) != $WORKER_ID ]; then
72
74
echo " Removing runnable code from " $filename
73
75
python $DIR /remove_runnable_code.py $filename $filename
74
76
else
75
77
echo " Keeping " $filename
78
+ FILES_TO_RUN+=($( basename $filename .py) )
76
79
fi
77
80
count=$(( count+ 1 ))
78
81
done
@@ -82,6 +85,7 @@ if [[ "${JOB_BASE_NAME}" == *worker_* ]]; then
82
85
python $DIR /remove_runnable_code.py $filename $filename
83
86
else
84
87
echo " Keeping " $filename
88
+ FILES_TO_RUN+=($( basename $filename .py) )
85
89
fi
86
90
count=$(( count+ 1 ))
87
91
done
@@ -91,28 +95,58 @@ if [[ "${JOB_BASE_NAME}" == *worker_* ]]; then
91
95
python $DIR /remove_runnable_code.py $filename $filename
92
96
else
93
97
echo " Keeping " $filename
98
+ FILES_TO_RUN+=($( basename $filename .py) )
94
99
fi
95
100
count=$(( count+ 1 ))
96
101
done
102
+ echo " FILES_TO_RUN: " ${FILES_TO_RUN[@]}
97
103
98
104
# Step 3: Run `make docs` to generate HTML files and static files for these tutorials
99
105
make docs
100
106
101
- # Step 4: Remove all HTML files generated from Python files that don't contain runnable code
102
- for filename in $( find docs/beginner -name ' *.html' ) ; do
103
- python $DIR /delete_html_file_with_runnable_code_removed.py $filename
107
+ # Step 4: If any of the generated files are not related the tutorial files we want to run,
108
+ # then we remove them
109
+ for filename in $( find docs/beginner docs/intermediate docs/advanced -name ' *.html' ) ; do
110
+ file_basename=$( basename $filename .html)
111
+ if [[ ! " ${FILES_TO_RUN[@]} " =~ " ${file_basename} " ]]; then
112
+ rm $filename
113
+ fi
104
114
done
105
- for filename in $( find docs/intermediate -name ' *.html' ) ; do
106
- python $DIR /delete_html_file_with_runnable_code_removed.py $filename
115
+ for filename in $( find docs/beginner docs/intermediate docs/advanced -name ' *.rst' ) ; do
116
+ file_basename=$( basename $filename .rst)
117
+ if [[ ! " ${FILES_TO_RUN[@]} " =~ " ${file_basename} " ]]; then
118
+ rm $filename
119
+ fi
107
120
done
108
- for filename in $( find docs/advanced -name ' *.html' ) ; do
109
- python $DIR /delete_html_file_with_runnable_code_removed.py $filename
121
+ for filename in $( find docs/_downloads -name ' *.py' ) ; do
122
+ file_basename=$( basename $filename .py)
123
+ if [[ ! " ${FILES_TO_RUN[@]} " =~ " ${file_basename} " ]]; then
124
+ rm $filename
125
+ fi
126
+ done
127
+ for filename in $( find docs/_downloads -name ' *.ipynb' ) ; do
128
+ file_basename=$( basename $filename .ipynb)
129
+ if [[ ! " ${FILES_TO_RUN[@]} " =~ " ${file_basename} " ]]; then
130
+ rm $filename
131
+ fi
132
+ done
133
+ for filename in $( find docs/_sources/beginner docs/_sources/intermediate docs/_sources/advanced -name ' *.rst.txt' ) ; do
134
+ file_basename=$( basename $filename .rst.txt)
135
+ if [[ ! " ${FILES_TO_RUN[@]} " =~ " ${file_basename} " ]]; then
136
+ rm $filename
137
+ fi
138
+ done
139
+ for filename in $( find docs/.doctrees/beginner docs/.doctrees/intermediate docs/.doctrees/advanced -name ' *.doctree' ) ; do
140
+ file_basename=$( basename $filename .doctree)
141
+ if [[ ! " ${FILES_TO_RUN[@]} " =~ " ${file_basename} " ]]; then
142
+ rm $filename
143
+ fi
110
144
done
111
145
112
- # Step 5: Remove INVISIBLE_CODE_BLOCK from all HTML files
146
+ # Step 5: Remove INVISIBLE_CODE_BLOCK from .html/.rst.txt/.ipynb/.py files
113
147
bash $DIR /remove_invisible_code_block_batch.sh docs
114
148
115
- # Step 6: Copy generated HTML files and static files to S3, tag with commit ID
149
+ # Step 6: Copy generated files to S3, tag with commit ID
116
150
7z a worker_${WORKER_ID} .7z docs
117
151
aws s3 cp worker_${WORKER_ID} .7z s3://${BUCKET_NAME} /${COMMIT_ID} /worker_${WORKER_ID} .7z --acl public-read
118
152
elif [[ " ${JOB_BASE_NAME} " == * manager ]]; then
@@ -151,14 +185,17 @@ elif [[ "${JOB_BASE_NAME}" == *manager ]]; then
151
185
done
152
186
153
187
# Step 5: Copy all static files into docs
154
- rsync -av docs_with_plot/docs/ docs --exclude beginner --exclude intermediate --exclude advanced
188
+ rsync -av docs_with_plot/docs/ docs
189
+
190
+ # Step 6: Remove INVISIBLE_CODE_BLOCK from .html/.rst.txt/.ipynb/.py files
191
+ bash $DIR /remove_invisible_code_block_batch.sh docs
155
192
156
- # Step 6 : Copy generated HTML files and static files to S3
193
+ # Step 7 : Copy generated HTML files and static files to S3
157
194
7z a manager.7z docs
158
195
aws s3 cp manager.7z s3://${BUCKET_NAME} /${COMMIT_ID} /manager.7z --acl public-read
159
196
160
197
# yf225 TODO: re-enable this after tutorial build is fixed
161
- # # Step 7 : push new HTML files and static files to gh-pages
198
+ # # Step 8 : push new HTML files and static files to gh-pages
162
199
# if [[ "$COMMIT_SOURCE" == master ]]; then
163
200
# git clone https://github.com/pytorch/tutorials.git -b gh-pages gh-pages
164
201
# cp -r docs/* gh-pages/
0 commit comments