|
| 1 | +Setting up debugging in Visual Studio Code (VSCode) |
| 2 | +=================================================== |
| 3 | + |
| 4 | +`VSCode <https://code.visualstudio.com/>`_ provides powerful tools for |
| 5 | +debugging support. For this project, we use a Python extension. For more |
| 6 | +details about debugging configurations for Python apps in VSCode, see this |
| 7 | +`link <https://code.visualstudio.com/docs/python/debugging>`_. |
| 8 | + |
| 9 | +If you are planning on contributing to the project, or track your debugging |
| 10 | +process, it is a better idea to have your own copy of DFFML on your Github |
| 11 | +account. For more details about setting up your git repository, |
| 12 | +read :doc:`git` page. |
| 13 | + |
| 14 | +After setting up the version controlling configurations, you need to install |
| 15 | +DFFML. See :doc:`dev_env` page for installing details in the development mode. |
| 16 | + |
| 17 | +Open the VSCode app, on the menu bar, click on ``File`` then choose |
| 18 | +``Open Folder``. Locate DFFML folder and open it. Inside the folder in VSCode, |
| 19 | +select ``setup.py`` file. This helps VSCode to retrieve your Python environment |
| 20 | +(either base or any virtual environment) that you setup. You can close the |
| 21 | +``setup.py`` file. |
| 22 | + |
| 23 | +Go to the menu bar and click on ``Run``, then select ``Add configuration``. |
| 24 | +Choose Python from the drop-down menu and then select ``module``. Inside the |
| 25 | +module text input field type ``dffml`` and press Enter. This will create a |
| 26 | +``launch.json`` file under the ``.vscode`` folder. |
| 27 | + |
| 28 | +It should be similar to the following: |
| 29 | + |
| 30 | +.. code-block:: console |
| 31 | +
|
| 32 | + { |
| 33 | + // Use IntelliSense to learn about possible attributes. |
| 34 | + // Hover to view descriptions of existing attributes. |
| 35 | + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 |
| 36 | + "version": "0.2.0", |
| 37 | + "configurations": [ |
| 38 | + { |
| 39 | + "name": "Python: Module", |
| 40 | + "type": "python", |
| 41 | + "request": "launch", |
| 42 | + "module": "dffml" |
| 43 | + } |
| 44 | + ] |
| 45 | + } |
| 46 | +
|
| 47 | +``dffml`` module needs arguments to run. Add arguments as a key-value pair into |
| 48 | +the embedded configurations container. Here is the example ``launch.json`` file |
| 49 | +for the :doc:`/quickstart/model` example. |
| 50 | + |
| 51 | +.. code-block:: console |
| 52 | +
|
| 53 | + { |
| 54 | + // Use IntelliSense to learn about possible attributes. |
| 55 | + // Hover to view descriptions of existing attributes. |
| 56 | + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 |
| 57 | + "version": "0.2.0", |
| 58 | + "configurations": [ |
| 59 | + { |
| 60 | + "name": "Python: Module", |
| 61 | + "type": "python", |
| 62 | + "request": "launch", |
| 63 | + "module": "dffml", |
| 64 | + "args": [ |
| 65 | + "train", |
| 66 | + "-model", "scikitlr", |
| 67 | + "-model-features", "Years:int:1", "Expertise:int:1", |
| 68 | + "Trust:float:1", |
| 69 | + "-model-predict", "Salary:float:1", |
| 70 | + "-sources", "f=csv", |
| 71 | + "-source-filename", "training.csv" |
| 72 | + ] |
| 73 | + } |
| 74 | + ] |
| 75 | + } |
| 76 | +
|
| 77 | +Save the file and click on the ``Run`` at the menu bar, and then click on |
| 78 | +``Start Debugging``. The code should run successfully to the end. You can add |
| 79 | +``"stopOnEntry": true,`` in the configurations container to break immediately |
| 80 | +when the program launches or you can use break point to stop at any arbitrary |
| 81 | +point in the code. Read more about debugging a Python code in |
| 82 | +VSCode `here <https://code.visualstudio.com/docs/python/debugging>`_. |
0 commit comments