-
Notifications
You must be signed in to change notification settings - Fork 3
/
run.sh
executable file
·81 lines (76 loc) · 2.66 KB
/
run.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
#!/bin/bash
abort()
{
echo "*** FAILED ***" >&2
exit 1
}
if [ "$#" -eq 0 ]; then
echo "No arguments provided. Usage:
1. '-local' to build local environment
2. '-docker' to build and run docker container
3. '-test' to run linter, formatter and tests
4. '-benchmark' to run benchmark tests
5. '-run-server' to run fastapi server
6. '-setup' to run package setup"
elif [ $1 = "-local" ]; then
trap 'abort' 0
set -e
echo "Running format, linter and tests"
rm -rf .venv
python3 -m venv .venv
source .venv/bin/activate
pip install --upgrade pip
pip install -r ./requirements.txt
black whisperflow tests
pylint --fail-under=9.9 whisperflow tests
pytest --ignore=tests/benchmark --cov-fail-under=95 --cov whisperflow -v tests
elif [ $1 = "-test" ]; then
trap 'abort' 0
set -e
echo "Running format, linter and tests"
source .venv/bin/activate
black whisperflow tests
pylint --fail-under=9.9 whisperflow tests
pytest --ignore=tests/benchmark --cov-fail-under=95 --cov --log-cli-level=INFO whisperflow -v tests
elif [ $1 = "-docker" ]; then
echo "Building and running docker image"
docker stop whisperflow-container
docker rm whisperflow-container
docker rmi whisperflow-image
# build docker and run
docker build --tag whisperflow-image --build-arg CACHEBUST=$(date +%s) .
docker run --name whisperflow-container -p 8888:8888 -d whisperflow-image
elif [ $1 = "-benchmark" ]; then
echo "Running WhisperFlow Server"
kill $(lsof -t -i:8181)
nohup uvicorn whisperflow.fast_server:app --host 0.0.0.0 --port 8181 &
sleep 2s
echo "Running WhisperFlow benchmark tests"
pytest -v -s tests/benchmark
kill $(lsof -t -i:8181)
elif [ $1 = "-run-server" ]; then
echo "Running WhisperFlow server"
kill $(lsof -t -i:8181)
uvicorn whisperflow.fast_server:app --host 0.0.0.0 --port 8181
elif [ $1 = "-test-package" ]; then
echo "Running WhisperFlow package setup"
# pip install twine
# pip install wheel
python setup.py sdist bdist_wheel
rm -rf .venv_test
python3 -m venv .venv_test
source .venv_test/bin/activate
pip install ./dist/whisperflow-0.1.0-py3-none-any.whl
pytest --ignore=tests/benchmark --cov-fail-under=95 --cov whisperflow -v tests
# twine upload ./dist/*
else
echo "Wrong argument is provided. Usage:
1. '-local' to build local environment
2. '-docker' to build and run docker container
3. '-test' to run linter, formatter and tests
4. '-benchmark' to run benchmark tests
5. '-run-server' to run fastapi server
6. '-setup' to run package setup"
fi
trap : 0
echo >&2 '*** DONE ***'