-
Notifications
You must be signed in to change notification settings - Fork 63
Debugging NativeBridge, DotNetBridge and ML.Net
Currently, as of version 15.9.15 of Visual Studio 2017 (and 16.2.2 of Visual Studio 2019), the Python debugger does not support debugging from NimbusML python code in to DotNetBridge or ML.Net. Here is a work around that supports debugging the complete end to end code path (NimbusML
-> PyBridge
-> DotNetBridge
-> ML.Net
and back).
NOTE: The Python debugger in Visual Studio already supports debugging in to PyBridge
from NimbusML
. To enable this, open the NimbusML project file in Visual Studio, navigate to the Debug
page and check the Enable native code debugging
check box.
-
Start Visual Studio and open the
NimbusML
solution. -
Open a command prompt and
cd
in to the root directory of theNimbusML
repo. -
Build
NimbusML
and install the wheel file in to the dependencies directory.c:\Your\NimbusML\Repo> build --installPythonPackages
Installing the wheel file is important because this is where the Python interpreter will look for the NimbusML package.
-
Start the main python file to debug (ie. unit test, example, ...) with the built-in Python debugger.
c:\Your\NimbusML\Repo> dependencies\Python3.7\python.exe -m pdb src\python\nimbusml\examples\ColumnDropper.py
-
Set a break point in any of the NimbusML python files with the
b(reak)
command. Here, a breakpoint is set on line 19 in the main file (the one started in step 4).(Pdb) b 19
Ideally, the break point should be set after a Python command which loads
PyBridge
andDotNetBridge
but before the lines which will be debugged.Usage documentation for the built-in Python debugger (
Pdb
) can be found here. -
Start the program with the
c(ontinue)
command. When the Python break point is encountered,Pdb
will return control to the user.(Pdb) c
-
In Visual Studio, click on
Debug
->Attach to Process
. In theAttach to Process
dialog box, click theSelect...
button for theAttach to:
field. SelectDebug these code types
and make sure only the following are checked:- Managed (CoreCLR)
- Managed (Native compilation)
- Native
-
In the
Filter processes
text box, typepython
and select the python process which corresponds to the executable which was started in step (4). This will usually bepython.exe
. Then, click theAttach
button. -
If
PyBridge
andDotNetBridge
have already been loaded then break points can be set in there respective files and debugged.The Python code is debugged using
Pdb
on the command line and thePyBridge
andDotNetBridge
code is debugged from within the attached Visual Studio debugger. -
When the code has been updated, repeat the process from step (3).
To add support for debugging all the way in to ML.Net from NimbusML, in step (3), build NimbusML with local debug versions of the ML.Net libraries. The steps to do this can be found here.
Make sure to replace the build -release
with build -debug
when building ML.Net.