Skip to content
This repository has been archived by the owner on Nov 16, 2023. It is now read-only.

Debugging NativeBridge, DotNetBridge and ML.Net

pieths edited this page Aug 26, 2019 · 2 revisions

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.

Debugging in to DotNetBridge from NimbusML

  1. Start Visual Studio and open the NimbusML solution.

  2. Open a command prompt and cd in to the root directory of the NimbusML repo.

  3. 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.

  4. 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
  5. 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 and DotNetBridge but before the lines which will be debugged.

    Usage documentation for the built-in Python debugger (Pdb) can be found here.

  6. Start the program with the c(ontinue) command. When the Python break point is encountered, Pdb will return control to the user.

    (Pdb) c
  7. In Visual Studio, click on Debug -> Attach to Process. In the Attach to Process dialog box, click the Select... button for the Attach to: field. Select Debug these code types and make sure only the following are checked:

    • Managed (CoreCLR)
    • Managed (Native compilation)
    • Native
  8. In the Filter processes text box, type python and select the python process which corresponds to the executable which was started in step (4). This will usually be python.exe. Then, click the Attach button.

  9. If PyBridge and DotNetBridge 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 the PyBridge and DotNetBridge code is debugged from within the attached Visual Studio debugger.

  10. When the code has been updated, repeat the process from step (3).

Debugging in to ML.Net from NimbusML

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.