Skip to content

Commit

Permalink
VS Code Tasks and Python Debugging Fixes (QuantConnect#5601)
Browse files Browse the repository at this point in the history
* ~Fix Python debugging and update docs

* Cleanup tasks
  • Loading branch information
C-SELLERS authored May 27, 2021
1 parent 22a5378 commit 6c42f58
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
36 changes: 15 additions & 21 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,18 @@
/*
VS Code Launch configurations for the LEAN engine

Launch w/ Mono (Local):
Builds the project with MSBuild and then launches the program using mono locally;
supports debugging. In order to use this you need msbuild and mono on your system path.
As well as the Mono Debug extension from the marketplace.

Debug in Container:
Launches our run_docker script to start the container and attaches to the debugger.
Requires that you have built the project at least once as it will transfer the compiled
csharp files.
Requires Mono Debug extension from the marketplace.
Launch:
Builds the project with dotnet 5 and then launches the program using coreclr; supports debugging.
In order to use this you need dotnet 5 on your system path, As well as the C# extension from the
marketplace.

Attach to Python (Container):
Will attempt to attach to LEAN in the container using PTVSD. Requires that the container is
actively running and config is set: "debugging": true, "debugging-method": "PTVSD",
Requires Python extension from the marketplace.

Attach to Python (Local):
Attach to Python:
Will attempt to attach to LEAN running locally using PTVSD. Requires that the process is
actively running and config is set: "debugging": true, "debugging-method": "PTVSD",
Requires Python extension from the marketplace.

Requires Python extension from the marketplace. Currently only works with algorithms in
Algorithm.Python directory. This is because we map that directory to our build directory
that contains the py file at runtime. If using another location change "localRoot" value
to the directory in use.
*/

"version": "0.2.0",
Expand All @@ -33,7 +24,10 @@
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Launcher/bin/Debug/QuantConnect.Lean.Launcher.dll",
"args": [],
"args": [
"--config",
"${workspaceFolder}/Launcher/config.json"
],
"cwd": "${workspaceFolder}/Launcher/bin/Debug/",
"stopAtEntry": false,
"console": "integratedTerminal",
Expand All @@ -45,8 +39,8 @@
"request": "attach",
"port": 5678,
"pathMappings":[{
"localRoot": "${workspaceFolder}",
"remoteRoot": "${workspaceFolder}"
"localRoot": "${workspaceFolder}/Algorithm.Python",
"remoteRoot": "${workspaceFolder}/Launcher/bin/Debug/"
}]
}
]
Expand Down
5 changes: 4 additions & 1 deletion .vscode/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ To use Lean CLI follow the instructions for installation and tutorial for usage

1. Install [.Net 5](https://dotnet.microsoft.com/download) for the project

2. (Optional) Get Get [Python 3.6.8](https://www.python.org/downloads/release/python-368/) for running Python algorithms
2. (Optional) Get [Python 3.6.8](https://www.python.org/downloads/release/python-368/) for running Python algorithms
- Follow Python instructions [here](https://github.com/QuantConnect/Lean/tree/master/Algorithm.Python#installing-python-36) for your platform

3. Get [Visual Studio Code](https://code.visualstudio.com/download)
Expand Down Expand Up @@ -125,3 +125,6 @@ Here we will cover some common issues with setting this up. This section will ex

- Autocomplete and reference finding with omnisharp can sometimes bug, if this occurs use the command palette to restart omnisharp. (Ctrl+Shift+P "OmniSharp: Restart OmniSharp")
- Any error messages about building in VSCode that point to comments in JSON. Either select **ignore** or follow steps described [here](https://stackoverflow.com/questions/47834825/in-vs-code-disable-error-comments-are-not-permitted-in-json) to remove the errors entirely.
- Python Algorithms will only attach and debug correctly when the algorithm lives in ./Algorithm.Python, this is due to an issue where Lean runs the py files from the build dir at
runtime; so we have mapped the ./Algorithm.Python directory to the build dir for the debugger. The mapped directory can be changed in .vscode/launch.json under "Attach To Python"
option "LocalRoot". If you adjust this to your Py algorithm directory you will be able to launch and debug in the same way.
10 changes: 6 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
"command": "dotnet",
"args": [
"build",
"--configuration", "Debug",
"/p:DebugType=portable"
"/p:Configuration=Debug",
"/p:DebugType=portable",
"/p:WarningLevel=1"
],
"group": "build",
"presentation": {
Expand All @@ -26,9 +27,10 @@
"command": "dotnet",
"args": [
"build",
"--configuration", "Debug",
"--no-incremental",
"/p:DebugType=portable"
"/p:Configuration=Debug",
"/p:DebugType=portable",
"/p:WarningLevel=1"
],
"group": "build",
"presentation": {
Expand Down

0 comments on commit 6c42f58

Please sign in to comment.