-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from dod-advana/feature/UOT-145475-finetune-w…
…ith-new-data Feature/uot 145475 finetune with new data
- Loading branch information
Showing
14 changed files
with
361 additions
and
144 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ matplotlib | |
seaborn | ||
autopep8 | ||
black | ||
debugpy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ services: | |
- capabilities: [gpu] | ||
ports: | ||
- "5000:5000" | ||
- "5678:5678" | ||
env_file: | ||
- .env | ||
volumes: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import os | ||
from gamechangerml.api.fastapi.settings import logger | ||
|
||
env_flag = "ENABLE_DEBUGGER" | ||
|
||
|
||
def check_debug_flagged(): | ||
flag_str = os.getenv(env_flag, "false") | ||
return flag_str == 'true' | ||
|
||
|
||
def debug_if_flagged(): | ||
|
||
if check_debug_flagged(): | ||
try: | ||
import debugpy | ||
debugger_port = 5678 | ||
debugpy.listen(('0.0.0.0', debugger_port)) | ||
logger.info(f"\n Debugger listening on {debugger_port} 🥾🦟 \n") | ||
|
||
# debugpy.wait_for_client() | ||
# debugpy.breakpoint() | ||
except Exception as e: | ||
import time | ||
logger.warning("ERROR STARTING DEBUGGER CONNECTION") | ||
time.sleep(3) | ||
logger.warning(e) | ||
time.sleep(3) | ||
logger.info( | ||
f"Debugging can be turned off by removing env variable {env_flag}") | ||
else: | ||
logger.info("ENABLE_DEBUGGER not set, debugger not started") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Debug setup for Visual Studio Code | ||
|
||
If you already have a launch.json, merge the below config, otherwise: | ||
|
||
go to `Run and Debug` tab on sidebar | ||
|
||
click link text `create a launch.json file` | ||
|
||
select: `Python` | ||
|
||
select: `Remote Attach` | ||
|
||
Enter the host name... : `localhost` | ||
|
||
Enter the port number... : `5678` | ||
|
||
your launch.json should look like below | ||
``` | ||
{ | ||
// 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: Remote Attach", | ||
"type": "python", | ||
"request": "attach", | ||
"connect": { | ||
"host": "localhost", | ||
"port": 5678 | ||
}, | ||
"pathMappings": [ | ||
{ | ||
"localRoot": "${workspaceFolder}", | ||
"remoteRoot": "." | ||
} | ||
], | ||
"justMyCode": true | ||
} | ||
] | ||
} | ||
``` | ||
|
||
## How it's working | ||
|
||
When you use | ||
|
||
`docker-compose up` - `gamechanger-ml/gamechangerml/api/docker-compose.yml` | ||
|
||
This exposes port `5678` for `gamechanger-ml-gpu` | ||
|
||
<br> | ||
|
||
In the entrypoint `gamechanger-ml/gamechangerml/api/fastapi/mlapp.py` | ||
|
||
`debug_if_flagged()` is called immediately, which is from `gamechanger-ml/gamechangerml/debug/debug_connector.py` | ||
|
||
This starts up `debugpy` to listen on `5678` if the ENV variable `ENABLE_DEBUGGER` in `setup_env.sh` is set to `true` | ||
|
||
The vscode debugger will attach to it using `launch.json` config | ||
|
||
Now you're ready to crush bugs 🥾🦟 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.