Skip to content

Commit e53a93b

Browse files
Debug support (#140)
* perf: debug support * chore: update submodules * chore: update submodules
1 parent f8aafe6 commit e53a93b

File tree

5 files changed

+49
-5
lines changed

5 files changed

+49
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
.vscode/
1+
.vscode/*
2+
!.vscode/launch.json
23

34
# Byte-compiled / optimized / DLL files
45
__pycache__/

.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-embedder",
9+
"type": "debugpy",
10+
"request": "attach",
11+
"connect": {
12+
"host": "localhost",
13+
"port": 15675
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: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,20 @@
11
#!/bin/bash
2+
3+
DEBUG_MODE=false
4+
DEBUG_PORT=15675
5+
6+
while getopts d flag
7+
do
8+
case "${flag}" in
9+
d) DEBUG_MODE=true;;
10+
esac
11+
done
12+
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+
218
trap "echo -ne '\nstopping container...' && docker stop refinery-embedder > /dev/null 2>&1 && echo -ne '\t\t [done]\n'" EXIT
319

420
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)
@@ -42,6 +58,7 @@ fi
4258
echo -ne 'starting...'
4359
docker run -d --rm \
4460
--name refinery-embedder \
61+
-p $DEBUG_PORT:$DEBUG_PORT \
4562
-p 7058:80 \
4663
-e S3_ENDPOINT_LOCAL=object-storage:9000 \
4764
-e S3_ACCESS_KEY=kern \
@@ -55,8 +72,10 @@ docker run -d --rm \
5572
-v "$MODEL_DIR":/models \
5673
-v "$INFERENCE_DIR":/inference \
5774
--network dev-setup_default \
58-
refinery-embedder-dev > /dev/null 2>&1
75+
refinery-embedder-dev $CMD > /dev/null 2>&1
5976
echo -ne '\t\t\t [done]\n'
6077

61-
78+
if [ $DEBUG_MODE = true ]; then
79+
echo -e "\033[0;33muse VSCode Debugger (Python Debugger: refinery-embedder) to start the service\033[0m"
80+
fi
6281
docker logs -f refinery-embedder

0 commit comments

Comments
 (0)