forked from aws/amazon-sagemaker-clarify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
devtool
executable file
·105 lines (86 loc) · 2.05 KB
/
devtool
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
#!/usr/bin/env bash
set -euo pipefail
install_deps_dev() {
python -m pip install --upgrade pip
pip install -e .[test]
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f docs/requirements.txt ]; then pip install -r docs/requirements.txt; fi
if [ -f examples/requirements.txt ]; then pip install -r examples/requirements.txt; fi
}
unit_tests() {
pytest --pspec tests/unit
}
integ_tests() {
pytest --pspec tests/integration
}
lint() {
echo ""
echo "Lint checks"
echo -e "===========\n"
echo "1. pre-commit hooks"
echo "==================="
pre-commit run -v -a
echo ""
echo "2. Flake8"
echo "========="
flake8 . --count --show-source --statistics
echo ""
echo "3. Mypy"
echo "======="
mypy --junit-xml reports/typecheck.xml --html-report reports --config-file setup.cfg src/
echo ""
echo "Lint: SUCCESS"
}
test_with_coverage() {
scripts/run_examples.py
coverage run -m pytest --pspec tests/unit
coverage report -m --fail-under=88
}
docs() {
cd docs
make html
}
create_commit_hash_file(){
if [[ -z "${CODEBUILD_RESOLVED_SOURCE_VERSION:-}" ]]; then
echo $(git rev-parse HEAD) > src/smclarify/COMMIT_HASH
else
echo "${CODEBUILD_RESOLVED_SOURCE_VERSION}" > src/smclarify/COMMIT_HASH
fi
}
build_package() {
create_commit_hash_file
python3 setup.py bdist_wheel
rm src/smclarify/COMMIT_HASH
}
install_package(){
wheel_name=$(ls -t dist | head -n 1)
pip install --upgrade dist/$wheel_name
}
all() {
lint
test_with_coverage
build_package
docs
}
##############################################################
# MAIN
#
# Run function passed as argument
set +x
if [ $# -gt 0 ]
then
SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
echo "CD -> $SCRIPTPATH"
cd $SCRIPTPATH
$@
else
cat<<EOF
**Developer tool**
==================
$0: Execute a function by passing it as an argument to the script:
Possible commands:
==================
EOF
declare -F | cut -d' ' -f3
echo
fi