Skip to content

Commit 50b06a1

Browse files
Debug support (#79)
* perf: debug support * chore: update submodules * fix: expose debug port * chore: update submodules
1 parent 764f6c5 commit 50b06a1

File tree

5 files changed

+51
-5
lines changed

5 files changed

+51
-5
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
.vscode/
1+
.vscode/*
2+
!.vscode/launch.json
3+
24
.DS_Store
35

46
# Byte-compiled / optimized / DLL files

.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-neural-search",
9+
"type": "debugpy",
10+
"request": "attach",
11+
"connect": {
12+
"host": "localhost",
13+
"port": 15676
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,2 +1,3 @@
11
-r requirements.txt
2-
pytest==8.1.1
2+
pytest==8.1.1
3+
debugpy==1.8.12

start

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,44 @@
11
#!/bin/bash
2+
3+
DEBUG_MODE=false
4+
DEBUG_PORT=15676
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-neural-search > /dev/null 2>&1 && echo -ne '\t\t [done]\n'" EXIT
319

420
echo -ne 'stopping old container...'
521
docker stop refinery-neural-search > /dev/null 2>&1
622
echo -ne '\t [done]\n'
723

824
echo -ne 'building container...'
9-
docker build -t refinery-neural-search-dev -f dev.Dockerfile . > /dev/null 2>&1
25+
docker build -t refinery-neural-search-dev -f dev.Dockerfile .
1026
echo -ne '\t\t [done]\n'
1127

1228
echo -ne 'starting...'
1329
docker run -d --rm \
1430
--name refinery-neural-search \
31+
-p $DEBUG_PORT:$DEBUG_PORT \
1532
-p 7063:80 \
1633
-e POSTGRES=postgresql://postgres:kern@graphql-postgres:5432 \
1734
-e QDRANT_PORT=6333 \
1835
--mount type=bind,source="$(pwd)"/,target=/app \
1936
-v /var/run/docker.sock:/var/run/docker.sock \
2037
--network dev-setup_default \
21-
refinery-neural-search-dev > /dev/null 2>&1
38+
refinery-neural-search-dev $CMD > /dev/null 2>&1
2239
echo -ne '\t\t\t [done]\n'
2340

41+
if [ $DEBUG_MODE = true ]; then
42+
echo -e "\033[0;33muse VSCode Debugger (Python Debugger: refinery-neural-search) to start the service\033[0m"
43+
fi
2444
docker logs -f refinery-neural-search

0 commit comments

Comments
 (0)