diff --git a/.gitignore b/.gitignore index b8c6c94f..e29f098f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,8 @@ __pycache__/ *.py[cod] *$py.class -.vscode/ +.vscode/* +!.vscode/launch.json # C extensions *.so diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..a28bb0af --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,23 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python Debugger: refinery-gateway", + "type": "debugpy", + "request": "attach", + "connect": { + "host": "localhost", + "port": 15670 + }, + "pathMappings": [ + { + "localRoot": "${workspaceFolder}", + "remoteRoot": "." + } + ] + } + ] +} \ No newline at end of file diff --git a/requirements-dev.txt b/requirements-dev.txt index 5bedfc1e..31b10836 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,3 +1,4 @@ -r requirements.txt httpx>=0.25.0 -pytest==8.1.1 \ No newline at end of file +pytest==8.1.1 +debugpy==1.8.12 \ No newline at end of file diff --git a/start b/start index 204f2a84..6846cec1 100755 --- a/start +++ b/start @@ -1,4 +1,20 @@ #!/bin/bash + +DEBUG_MODE=false +DEBUG_PORT=15670 + +while getopts d flag +do + case "${flag}" in + d) DEBUG_MODE=true;; + esac +done + +CMD="" +if [ $DEBUG_MODE = true ]; then + CMD="debugpy --wait-for-client --listen 0.0.0.0:$DEBUG_PORT -m uvicorn app:app --host 0.0.0.0 --port 80 --reload" +fi + trap "echo -ne '\nstopping container...' && docker stop refinery-gateway > /dev/null 2>&1 && echo -ne '\t\t [done]\n'" EXIT unameOut="$(uname -s)" @@ -60,7 +76,7 @@ then fi echo -ne 'building container...' -docker build -t graphql-dev -f dev.Dockerfile . > /dev/null 2>&1 +docker build -t graphql-dev -f dev.Dockerfile . echo -ne '\t\t [done]\n' echo -ne 'migrating db...\n' @@ -76,6 +92,7 @@ echo -ne 'migration done\n' echo -ne 'starting...' docker run -d --rm \ --name refinery-gateway \ +-p $DEBUG_PORT:$DEBUG_PORT \ -p 7051:80 \ -e AC_EXEC_ENV_IMAGE=registry.dev.kern.ai/code-kern-ai/refinery-ac-exec-env:dev$IS_ARM64 \ -e LF_EXEC_ENV_IMAGE=registry.dev.kern.ai/code-kern-ai/refinery-lf-exec-env:dev$IS_ARM64 \ @@ -106,7 +123,10 @@ docker run -d --rm \ --mount type=bind,source="$(pwd)"/,target=/app \ -v /var/run/docker.sock:/var/run/docker.sock \ --network dev-setup_default \ -graphql-dev > /dev/null 2>&1 +graphql-dev $CMD > /dev/null 2>&1 echo -ne '\t\t\t [done]\n' +if [ $DEBUG_MODE = true ]; then + echo -e "\033[0;33muse VSCode Debugger (Python Debugger: refinery-gateway) to start the service\033[0m" +fi docker logs -f refinery-gateway \ diff --git a/submodules/model b/submodules/model index cd31a340..c8179885 160000 --- a/submodules/model +++ b/submodules/model @@ -1 +1 @@ -Subproject commit cd31a340d9a7f1e28c2367a63d36eb71732dec9c +Subproject commit c81798852f9f2a2769b094dc971e89e1c4a58a42