Study: DeveloperTools(DevTool)/DevTool: IDE

[IDE] VSCode Python ๋””๋ฒ„๊น… ํ™˜๊ฒฝ ์„ธํŒ…(launch.json): feat. ๋ชจ๋“  ์ค‘๋‹จ์ ์—์„œ ๋ฉˆ์ถ”๋„๋ก

DrawingProcess 2024. 2. 16. 10:45
๋ฐ˜์‘ํ˜•
๐Ÿ’ก ๋ณธ ๋ฌธ์„œ๋Š” Visual Studio Code๋ฅผ ํ™œ์šฉํ•œ Python ๋””๋ฒ„๊น… ํ™˜๊ฒฝ ์„ธํŒ… ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค.
์šด์˜์ฒด์ œ ๋ณ„๋กœ ์ง€์›๋˜๋Š” ์ปดํŒŒ์ผ๋Ÿฌ์— ์ฐจ์ด๊ฐ€ ์žˆ์–ด ์šด์˜์ฒด์ œ๋ณ„๋กœ ์ผ๋ถ€ ์ƒ์ดํ•  ์ˆ˜ ์žˆ์œผ๋‹ˆ ๋ณธ์ธ์˜ ์šด์˜์ฒด์ œ๋ฅผ ํ™•์ธํ•˜๊ณ  ๊ทธ์— ๋งž์ถฐ์„œ ์ง„ํ–‰ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

๋ฏธ๋ฆฌ ์•Œ์•„์•ผ ํ•  ์  (์ฃผ์˜์‚ฌํ•ญ)

VSCode์—์„œ ๋””๋ฒ„๊น…์‹œ ํ”„๋กœ์ ํŠธ์˜ ์ƒ์œ„์— ์žˆ๋Š” .vscode/ํด๋” ๋‚ด์— task.json๊ณผ launch.json์„ ์•„๋ž˜์™€ ์œ ์‚ฌํ•˜๊ฒŒ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. VScode์˜ ๋””๋ฒ„๊น…์„ ์‹คํ–‰ํ•˜๋ฉด launch.json์ด ์‹คํ–‰๋˜๋Š”๋ฐ, ์ด๋•Œ preLaunchTask ๋ผ๋ฒจ์ด ์žˆ๋‹ค๋ฉด task.json์—์„œ label์ด ๋™์ผํ•œ ๊ฒƒ์„ ์ฐพ๊ณ  task.json ์ž‘์—…์„ ์‹คํ–‰ํ•œ ํ›„ launch.json์ด ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค. 

๊ทธ๋ž˜์„œ C++์˜ ๋””๋ฒ„๊น… ํ™˜๊ฒฝ์„ ์„ธํŒ…ํ•  ๊ฒฝ์šฐ, task.json์— ๋นŒ๋“œํ•  ์ž‘์—…์„ ๋ช…์‹œํ•˜๊ณ  launch.json์—์„œ ์‹คํ–‰ํŒŒ์ผ์„ ์‹คํ–‰ํ•˜๋„๋ก ๊ตฌ์„ฑํ•˜๋Š”๋ฐ, python์˜ ๊ฒฝ์šฐ ๋ฐ”๋กœ ์‹คํ–‰ํ•˜๋ฉด ๋˜๊ธฐ์— launch.json๋งŒ ์ž‘์„ฑํ•ด๋„ ๋ฉ๋‹ˆ๋‹ค.

ํ•˜๋‹จ์—์„œ json ํŒŒ์ผ์— ๋Œ€ํ•œ ์„ค๋ช…์„ ํ•ด์ค„ ์˜ˆ์ •์ด๋‹ˆ ์ฐธ๊ณ ํ•˜์‹œ๊ธฐ ๋ฐ”๋ž๋‹ˆ๋‹ค.

VSCode python ๋””๋ฒ„๊น… ํ™˜๊ฒฝ ์„ธํŒ…

launch.json

{
    // 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: Current File",
            "type": "debugpy",
            "request": "launch",
            "program": "${workspaceRoot}/yolact/eval.py",
            "args": [
                "--config", "custom_config_ty_yolactplus",
                "--score_threshold", "0.2",
                "--trained_model", "/home/avs/yolact/yolact/weights/resnet101_construct_0131_con2/customty_yolactplus_139_7000.pth",
                // "--trained_model", "/home/avs/yolact/yolact/weights/resnet101_construct_0131_merged_plus_fhd/customty_yolactplus_111_110000.pth",
                "--images", "/home/avs/dataset/train_exd/con2:/home/avs/dataset/result_vis/result_vis_yolactplus/con2_merged"
            ],
            "console": "integratedTerminal"
        }
    ]
}
  • "type": debugpy๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
  • "program": ๋””๋ฒ„๊น…ํ•  ์‹คํ–‰ํŒŒ์ผ์˜ ์ ˆ๋Œ€๊ฒฝ๋กœ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
  • "args": ๋””๋ฒ„๊น…ํ•  ์‹œ ์‹คํ–‰ํŒŒ์ผ์˜ ์˜ต์…˜์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. 

+ VScode: ๋ชจ๋“  ์ค‘๋‹จ์ ์—์„œ ๋ฉˆ์ถ”๋„๋ก ์„ค์ •

  1. ์„ค์ •: ์ƒ๋‹จ๋ฐ” -> ๊ธฐ๋ณธ์„ค์ • -> ์„ค์ •(command + ,)
  2. ๋ชจ๋“  ์ค‘๋‹จ์ ์—์„œ ๋ฉˆ์ถ”๊ธฐ: breakpoint ๊ฒ€์ƒ‰ ํ›„ 'Debug: Allow Breakpoints Everywhere' ์ฒดํฌ

 

๋ฐ˜์‘ํ˜•