From e215140a34dc40f9780f453faa7bee959e1c6b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Juan=20Pedre=C3=B1o=20Manresa?= <jpedrenomanresa@adva.com> Date: Mon, 1 Aug 2022 08:51:30 +0000 Subject: [PATCH] Added tutorial for debugging with VSCode Draft of tutorial to configure environment and VSCode to debug individual TFS components --- tutorial/3-0-development.md | 1 + tutorial/3.3-debug-comp.md | 55 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tutorial/3.3-debug-comp.md diff --git a/tutorial/3-0-development.md b/tutorial/3-0-development.md index 0e2d1a03f..c2b13315a 100644 --- a/tutorial/3-0-development.md +++ b/tutorial/3-0-development.md @@ -7,3 +7,4 @@ this guide assumes you are using the Oracle VirtualBox-based VM running MicroK8s ## Table of Content: - [3.1. Configure VSCode and Connect to the VM](./3-1-configure-vscode.md) - [3.2. Development Commands, Tricks, and Hints (WORK IN PROGRESS)](./3-2-develop-cth.md) +- [3.3. Debugging individual components in VSCode](./3.3-debug-comp.md) diff --git a/tutorial/3.3-debug-comp.md b/tutorial/3.3-debug-comp.md new file mode 100644 index 000000000..380c5add2 --- /dev/null +++ b/tutorial/3.3-debug-comp.md @@ -0,0 +1,55 @@ +# 3.3 Debugging individual components in VSCode + +## 3.3.1 Source TeraFlow environment variables into .bashrc + +With any text editor, open the file `~/.bashrc` and add the following line at the end: +```bash +source ~/tfs-ctrl/tfs_runtime_env_vars.sh +``` + +"tfs-ctrl" can be substituted by the appropriate path where the controller is deployed. + +## 3.3.2 Install VSCode Python extensions +The following extensions are required to execute and debug TeraFlow components in VSCode: + +- *Python*. New versions of the extension are known to have some unsolved bugs, it is recommended to downgrade to version **v2022.10.0**. Go to the extension window, select Python, click the arrow next to the "Uninstall" button and select "Install Another Version..." +- *Pylance* + +## 3.3.3 Configure VSCode workspace and launch settings +Run VSCode and open the folder with the source code of TeraFlow, this will be the main workspace. Create (if it does not exist) the subfolder `.vscode`. Inside, create and edit the following files: + +- `settings.json` + ```bash + { + "python.analysis.extraPaths": ["<HOME>/.pyenv/versions/3.9.7/envs/teraflow/lib/python3.9/site-packages"], + } + ``` + `<HOME>` should be replaced by the path of your home folder. If in the future another version of Python is used, or the virtual environment changes, this file should be updated to reflect the new path of the installed pip packages. + +- `launch.json` + ```bash + { + // 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": "TFS compute.service", + "module": "compute.service", + "python": "${command:python.interpreterPath}", + "type": "python", + "request": "launch", + "justMyCode": true, + "console": "internalConsole", + "env": { + "PYTHONPATH": "${config:python.analysis.extraPaths}:${workspaceRoot}/src", + "LOG_LEVEL": "DEBUG", + } + } + ] + } + ``` + This file contains the configuration necessary to execute the `"compute"` component from the TeraFlow controller, while providing debugging capabilities (e.g., breaking points, console log output etc.). After saving, the debugging can be started from the "Run and Debug" menu. + + Additional profiles can be added to the JSON file under the `"configurations"` arrray. Copy & paste the existing one and change the `"name"` and `"module"` fields. \ No newline at end of file -- GitLab