-
-
Notifications
You must be signed in to change notification settings - Fork 113
/
Copy pathmake.bat
159 lines (127 loc) · 3.46 KB
/
make.bat
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
@ECHO OFF
REM Command file to centralize test tasks
SET ROOT_DIR="%~dp0"
CALL :joinpath %ROOT_DIR% pymc4
SET PACKAGE_DIR=%RESULT%
CALL :joinpath %ROOT_DIR% tests
SET TESTS_DIR=%RESULT%
SET PYTHON=python
SET PIP=pip
SET CONDA=conda
if "%1" == "" (
call :help
exit /B 0
)
call :%1
EXIT /B %ERRORLEVEL%
:help
echo.Usage:
echo. make help: display help
echo. make venv: create python virtual environment
echo. make conda: create conda environment
echo. make docker: create docker image from application
echo. make docstyle: check package documentation with pydocstyle
echo. make format: check package formating with black
echo. make style: check package style with pylint
echo. make types: check typehints with mypy
echo. make black: apply black formating to the entire package and tests
echo. make test: run tests with pytest
echo. make lint: run all docstyle, format, style and docscheck checks
echo. make check: run lint, test
echo. make notebooks: execute jupyter notebooks
EXIT /B 0
:joinpath
set Path1=%~1
set Path2=%~2
if {%Path1:~-1,1%}=={\} (set Result="%Path1%%Path2%") else (set Result="%Path1%\%Path2%")
EXIT /B %ERRORLEVEL%
:conda
echo.Creating conda environment...
%CONDA% create --yes --name pymc4-env python=3.6
%CONDA% activate pymc4-env
%PIP% install -U pip
%PIP% install -r requirements.txt
%PIP% install -r requirements-dev.txt
%CONDA% deactivate
if %ERRORLEVEL%==0 (
echo.Conda environment created! Run conda activate pymc4-env to activate it.
) else (
echo.Failed to create conda environment.
)
EXIT /B %ERRORLEVEL%
:venv
echo.Creating Python virtual environment...
rmdir /s /q pymc4-venv
%PYTHON% -m venv pymc4-venv
pymc4-venv\Scripts\activate
%PIP% install -U pip
%PIP% install -r requirements.txt
%PIP% install -r requirements-dev.txt
deactivate
if %ERRORLEVEL%==0 (
echo.Virtual environment created! Run pymc4-venv\Scripts\activate to activate it."
) else (
echo.Failed to create virtual environment.
)
EXIT /B %ERRORLEVEL%
:docker
echo.Creating Docker image...
scripts\container --build
if %ERRORLEVEL%==0 (
echo.Successfully built docker image.
) else (
echo.Failed to build docker image.
)
EXIT /B %ERRORLEVEL%
:docstyle
echo.Checking documentation with pydocstyle...
%PYTHON% -m pydocstyle %PACKAGE_DIR%
if %ERRORLEVEL%==0 (
echo.Pydocstyle passes!
) else (
echo.Pydocstyle failed!
)
EXIT /B %ERRORLEVEL%
:format
echo.Checking code format with black...
%PYTHON% -m black --check --diff %PACKAGE_DIR% %TESTS_DIR%
if %ERRORLEVEL%==0 (
echo.Black passes!
) else (
echo.Black failed!
)
EXIT /B %ERRORLEVEL%
:style
echo.Checking style with pylint...
%PYTHON% -m pylint %PACKAGE_DIR%
if %ERRORLEVEL%==0 (
echo.Pylint passes!
) else (
echo.Pylint failed!
)
EXIT /B %ERRORLEVEL%
:types
echo.Checking type hints with mypy...
%PYTHON% -m mypy --ignore-missing-imports %PACKAGE_DIR%
if %ERRORLEVEL%==0 (
echo.Mypy passes!
) else (
echo.Mypy failed!
)
EXIT /B %ERRORLEVEL%
:black
%PYTHON% -m black %PACKAGE_DIR% %TESTS_DIR%
EXIT /B %ERRORLEVEL%
:notebooks
jupyter nbconvert --config nbconfig.py --execute --ExecutePreprocessor.kernel_name="pymc4-dev" --ExecutePreprocessor.timeout=1200 --to html
del %ROOT_DIR%notebooks\*.html
EXIT /B %ERRORLEVEL%
:test
%PYTHON% -m pytest -v %PACKAGE_DIR% %TESTS_DIR% --doctest-modules --html=testing-report.html --self-contained-html
EXIT /B %ERRORLEVEL%
:lint
call :docstyle && call :format && call :style && call :types
EXIT /B %ERRORLEVEL%
:check
call :lint && call :test
EXIT /B %ERRORLEVEL%