Skip to content

Commit a3c675c

Browse files
Debug support (#84)
* Azure VM Updates * perf: debugging support * chore: update submodules * perf: align start script to others * chore: update submodules
1 parent 9149a78 commit a3c675c

File tree

5 files changed

+48
-20
lines changed

5 files changed

+48
-20
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,5 @@ dmypy.json
131131
.idea/
132132

133133
# Visual Studio code
134-
.vscode
134+
.vscode/*
135+
!.vscode/launch.json

.vscode/launch.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Python Debugger: refinery-tokenizer",
9+
"type": "debugpy",
10+
"request": "attach",
11+
"connect": {
12+
"host": "localhost",
13+
"port": 15671
14+
},
15+
"pathMappings": [
16+
{
17+
"localRoot": "${workspaceFolder}",
18+
"remoteRoot": "."
19+
}
20+
]
21+
}
22+
]
23+
}

requirements-dev.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
-r requirements.txt
22
httpx==0.25.0
3-
pytest==8.1.1
3+
pytest==8.1.1
4+
debugpy==1.8.12

start

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
#!/bin/bash
2-
trap "echo -ne '\nstopping container...' && docker stop refinery-tokenizer > /dev/null 2>&1 && echo -ne '\t\t [done]\n'" EXIT
32

4-
HIDE_BUILD=0
5-
while getopts :s flag
3+
DEBUG_MODE=false
4+
DEBUG_PORT=15671
5+
6+
while getopts d flag
67
do
78
case "${flag}" in
8-
s) HIDE_BUILD=1;;
9+
d) DEBUG_MODE=true;;
910
esac
1011
done
1112

13+
CMD=""
14+
if [ $DEBUG_MODE = true ]; then
15+
CMD="debugpy --wait-for-client --listen 0.0.0.0:$DEBUG_PORT -m uvicorn app:app --host 0.0.0.0 --port 80 --reload"
16+
fi
17+
18+
trap "echo -ne '\nstopping container...' && docker stop refinery-tokenizer > /dev/null 2>&1 && echo -ne '\t\t [done]\n'" EXIT
19+
1220
HOST_IP=$(docker network inspect bridge --format='{{json .IPAM.Config}}' | grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' | tail -1)
1321

1422
echo -ne 'stopping old container...'
15-
if [ $HIDE_BUILD -eq 1 ]
16-
then
17-
docker stop refinery-tokenizer > /dev/null 2>&1
18-
else
19-
docker stop refinery-tokenizer
20-
fi
23+
docker stop refinery-tokenizer > /dev/null 2>&1
2124
echo -ne '\t\t [done]\n'
2225

2326
INFERENCE_DIR=${PWD%/*}/dev-setup/inference/
@@ -35,17 +38,13 @@ then
3538
fi
3639

3740
echo -ne 'building container...'
38-
if [ $HIDE_BUILD -eq 1 ]
39-
then
40-
docker build -t refinery-tokenizer-dev -f dev.Dockerfile . > /dev/null 2>&1
41-
else
42-
docker build -t refinery-tokenizer-dev -f dev.Dockerfile .
43-
fi
41+
docker build -t refinery-tokenizer-dev -f dev.Dockerfile .
4442
echo -ne '\t\t [done]\n'
4543

4644
echo -ne 'starting...'
4745
docker run -d --rm \
4846
--name refinery-tokenizer \
47+
-p $DEBUG_PORT:$DEBUG_PORT \
4948
-p 7061:80 \
5049
-e S3_ENDPOINT_LOCAL=object-storage:9000 \
5150
-e S3_ACCESS_KEY=kern \
@@ -56,6 +55,10 @@ docker run -d --rm \
5655
--mount type=bind,source="$(pwd)"/,target=/app \
5756
-v /var/run/docker.sock:/var/run/docker.sock \
5857
--network dev-setup_default \
59-
refinery-tokenizer-dev > /dev/null 2>&1
58+
refinery-tokenizer-dev $CMD > /dev/null 2>&1
6059
echo -ne '\t\t\t [done]\n'
60+
61+
if [ $DEBUG_MODE = true ]; then
62+
echo -e "\033[0;33muse VSCode Debugger (Python Debugger: refinery-tokenizer) to start the service\033[0m"
63+
fi
6164
docker logs -f refinery-tokenizer

0 commit comments

Comments
 (0)