-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
/
code_checks.sh
executable file
·225 lines (203 loc) · 9.37 KB
/
code_checks.sh
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
#!/bin/bash
#
# Run checks related to code quality.
#
# This script is intended for both the CI and to check locally that code standards are
# respected. We run doctests here (currently some files only), and we
# validate formatting error in docstrings.
#
# Usage:
# $ ./ci/code_checks.sh # run all checks
# $ ./ci/code_checks.sh code # checks on imported code
# $ ./ci/code_checks.sh doctests # run doctests
# $ ./ci/code_checks.sh docstrings # validate docstring errors
# $ ./ci/code_checks.sh single-docs # check single-page docs build warning-free
# $ ./ci/code_checks.sh notebooks # check execution of documentation notebooks
set -uo pipefail
if [[ -v 1 ]]; then
CHECK=$1
else
# script will fail if it uses an unset variable (i.e. $1 is not provided)
CHECK=""
fi
[[ -z "$CHECK" || "$CHECK" == "code" || "$CHECK" == "doctests" || "$CHECK" == "docstrings" || "$CHECK" == "single-docs" || "$CHECK" == "notebooks" ]] || \
{ echo "Unknown command $1. Usage: $0 [code|doctests|docstrings|single-docs|notebooks]"; exit 9999; }
BASE_DIR="$(dirname $0)/.."
RET=0
### CODE ###
if [[ -z "$CHECK" || "$CHECK" == "code" ]]; then
MSG='Check import. No warnings, and blocklist some optional dependencies' ; echo $MSG
python -W error -c "
import sys
import pandas
blocklist = {'bs4', 'gcsfs', 'html5lib', 'http', 'ipython', 'jinja2', 'hypothesis',
'lxml', 'matplotlib', 'openpyxl', 'py', 'pytest', 's3fs', 'scipy',
'tables', 'urllib.request', 'xlrd', 'xlsxwriter'}
# GH#28227 for some of these check for top-level modules, while others are
# more specific (e.g. urllib.request)
import_mods = set(m.split('.')[0] for m in sys.modules) | set(sys.modules)
mods = blocklist & import_mods
if mods:
sys.stderr.write('err: pandas should not import: {}\n'.format(', '.join(mods)))
sys.exit(len(mods))
"
RET=$(($RET + $?)) ; echo $MSG "DONE"
fi
### DOCTESTS ###
if [[ -z "$CHECK" || "$CHECK" == "doctests" ]]; then
MSG='Python and Cython Doctests' ; echo $MSG
python -c 'import pandas as pd; pd.test(run_doctests=True)'
RET=$(($RET + $?)) ; echo $MSG "DONE"
fi
### DOCSTRINGS ###
if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then
MSG='Validate docstrings (EX01, EX03, EX04, GL01, GL02, GL03, GL04, GL05, GL06, GL07, GL09, GL10, PR03, PR04, PR05, PR06, PR08, PR09, PR10, RT01, RT02, RT04, RT05, SA02, SA03, SA04, SS01, SS02, SS03, SS04, SS05, SS06)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=EX01,EX03,EX04,GL01,GL02,GL03,GL04,GL05,GL06,GL07,GL09,GL10,PR03,PR04,PR05,PR06,PR08,PR09,PR10,RT01,RT02,RT04,RT05,SA02,SA03,SA04,SS01,SS02,SS03,SS04,SS05,SS06
RET=$(($RET + $?)) ; echo $MSG "DONE"
MSG='Partially validate docstrings (PR02)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=PR02 --ignore_functions \
pandas.Series.dt.to_period\
pandas.Series.dt.tz_localize\
pandas.Series.dt.tz_convert\
pandas.Series.dt.strftime\
pandas.Series.dt.round\
pandas.Series.dt.floor\
pandas.Series.dt.ceil\
pandas.Series.dt.month_name\
pandas.Series.dt.day_name\
pandas.Series.str.wrap\
pandas.Series.cat.rename_categories\
pandas.Series.cat.reorder_categories\
pandas.Series.cat.add_categories\
pandas.Series.cat.remove_categories\
pandas.Series.cat.set_categories\
pandas.Series.plot\
pandas.DataFrame.plot\
pandas.tseries.offsets.DateOffset\
pandas.tseries.offsets.BusinessDay\
pandas.tseries.offsets.BDay\
pandas.tseries.offsets.BusinessHour\
pandas.tseries.offsets.CustomBusinessDay\
pandas.tseries.offsets.CDay\
pandas.tseries.offsets.CustomBusinessHour\
pandas.tseries.offsets.MonthEnd\
pandas.tseries.offsets.MonthBegin\
pandas.tseries.offsets.BusinessMonthEnd\
pandas.tseries.offsets.BMonthEnd\
pandas.tseries.offsets.BusinessMonthBegin\
pandas.tseries.offsets.BMonthBegin\
pandas.tseries.offsets.CustomBusinessMonthEnd\
pandas.tseries.offsets.CBMonthEnd\
pandas.tseries.offsets.CustomBusinessMonthBegin\
pandas.tseries.offsets.CBMonthBegin\
pandas.tseries.offsets.SemiMonthEnd\
pandas.tseries.offsets.SemiMonthBegin\
pandas.tseries.offsets.Week\
pandas.tseries.offsets.WeekOfMonth\
pandas.tseries.offsets.LastWeekOfMonth\
pandas.tseries.offsets.BQuarterEnd\
pandas.tseries.offsets.BQuarterBegin\
pandas.tseries.offsets.QuarterEnd\
pandas.tseries.offsets.QuarterBegin\
pandas.tseries.offsets.BYearEnd\
pandas.tseries.offsets.BYearBegin\
pandas.tseries.offsets.YearEnd\
pandas.tseries.offsets.YearBegin\
pandas.tseries.offsets.FY5253\
pandas.tseries.offsets.FY5253Quarter\
pandas.tseries.offsets.Easter\
pandas.tseries.offsets.Day\
pandas.tseries.offsets.Hour\
pandas.tseries.offsets.Minute\
pandas.tseries.offsets.Second\
pandas.tseries.offsets.Milli\
pandas.tseries.offsets.Micro\
pandas.tseries.offsets.Nano\
pandas.Timestamp.max\
pandas.Timestamp.min\
pandas.Timestamp.resolution\
pandas.Timedelta.max\
pandas.Timedelta.min\
pandas.Timedelta.resolution\
pandas.Interval\
pandas.Grouper\
pandas.core.groupby.DataFrameGroupBy.nth\
pandas.core.groupby.SeriesGroupBy.nth\
pandas.core.groupby.DataFrameGroupBy.plot\
pandas.core.groupby.SeriesGroupBy.plot # There should be no backslash in the final line, please keep this comment in the last ignored function
RET=$(($RET + $?)) ; echo $MSG "DONE"
MSG='Partially validate docstrings (SA05)' ; echo $MSG
$BASE_DIR/scripts/validate_docstrings.py --format=actions --errors=SA05 --ignore_functions \
pandas.DataFrame.agg\
pandas.DataFrame.aggregate\
pandas.DataFrame.boxplot\
pandas.PeriodIndex.asfreq\
pandas.arrays.ArrowStringArray\
pandas.arrays.StringArray\
pandas.core.groupby.DataFrameGroupBy.first\
pandas.core.groupby.DataFrameGroupBy.last\
pandas.core.groupby.SeriesGroupBy.first\
pandas.core.groupby.SeriesGroupBy.last\
pandas.core.resample.Resampler.first\
pandas.core.resample.Resampler.last\
pandas.core.window.ewm.ExponentialMovingWindow.corr\
pandas.core.window.ewm.ExponentialMovingWindow.cov\
pandas.core.window.ewm.ExponentialMovingWindow.mean\
pandas.core.window.ewm.ExponentialMovingWindow.std\
pandas.core.window.ewm.ExponentialMovingWindow.sum\
pandas.core.window.ewm.ExponentialMovingWindow.var\
pandas.core.window.expanding.Expanding.aggregate\
pandas.core.window.expanding.Expanding.apply\
pandas.core.window.expanding.Expanding.corr\
pandas.core.window.expanding.Expanding.count\
pandas.core.window.expanding.Expanding.cov\
pandas.core.window.expanding.Expanding.kurt\
pandas.core.window.expanding.Expanding.max\
pandas.core.window.expanding.Expanding.mean\
pandas.core.window.expanding.Expanding.median\
pandas.core.window.expanding.Expanding.min\
pandas.core.window.expanding.Expanding.quantile\
pandas.core.window.expanding.Expanding.rank\
pandas.core.window.expanding.Expanding.sem\
pandas.core.window.expanding.Expanding.skew\
pandas.core.window.expanding.Expanding.std\
pandas.core.window.expanding.Expanding.sum\
pandas.core.window.expanding.Expanding.var\
pandas.core.window.rolling.Rolling.aggregate\
pandas.core.window.rolling.Rolling.apply\
pandas.core.window.rolling.Rolling.corr\
pandas.core.window.rolling.Rolling.count\
pandas.core.window.rolling.Rolling.cov\
pandas.core.window.rolling.Rolling.kurt\
pandas.core.window.rolling.Rolling.max\
pandas.core.window.rolling.Rolling.mean\
pandas.core.window.rolling.Rolling.median\
pandas.core.window.rolling.Rolling.min\
pandas.core.window.rolling.Rolling.quantile\
pandas.core.window.rolling.Rolling.rank\
pandas.core.window.rolling.Rolling.sem\
pandas.core.window.rolling.Rolling.skew\
pandas.core.window.rolling.Rolling.std\
pandas.core.window.rolling.Rolling.sum\
pandas.core.window.rolling.Rolling.var\
pandas.core.window.rolling.Window.mean\
pandas.core.window.rolling.Window.std\
pandas.core.window.rolling.Window.sum\
pandas.core.window.rolling.Window.var\
pandas.plotting.bootstrap_plot\
pandas.plotting.boxplot\
pandas.plotting.radviz # There should be no backslash in the final line, please keep this comment in the last ignored function
RET=$(($RET + $?)) ; echo $MSG "DONE"
fi
### DOCUMENTATION NOTEBOOKS ###
if [[ -z "$CHECK" || "$CHECK" == "notebooks" ]]; then
MSG='Notebooks' ; echo $MSG
jupyter nbconvert --execute $(find doc/source -name '*.ipynb') --to notebook
RET=$(($RET + $?)) ; echo $MSG "DONE"
fi
### SINGLE-PAGE DOCS ###
if [[ -z "$CHECK" || "$CHECK" == "single-docs" ]]; then
python doc/make.py --warnings-are-errors --no-browser --single pandas.Series.value_counts
python doc/make.py --warnings-are-errors --no-browser --single pandas.Series.str.split
fi
exit $RET