Code Server for VS Code
Visual Studio Code (VS Code) is a lightweight and highly customizable source code editor developed by Microsoft. It is designed to provide developers with a powerful and efficient environment for coding, debugging, and building applications. VS Code supports a wide range of programming languages and offers features like syntax highlighting, intelligent code completion, debugging capabilities, and Git integration. It also provides a vast library of extensions that enhance its functionality, allowing developers to personalize their coding experience based on their preferences and requirements.
For a detailed documentation of VS Code, please see https://code.visualstudio.com/docs.
Start a new VS Code session
In order to start a new VS Code session on the terrabyte Portal,
- Click on the Code Server for VS Code icon on the dashboard or select "Code Server for VS Code" in the drop down list under "Development" in the upper menu bar.
- Select the number of cores to be used for the session (2 or 4) and the desired run time and click on "Launch".
- Once the session is ready, you can connect to it via "Connect to VS Code".
- A new browser window with VS Code will open. Be patient: It may take some seconds until the application is completely loaded. Your browser window may stay blank white during loading.
-
By default, the file explorer shows your home directory. You can access other folders/projects on the DSS by clicking on the menu icon → File → Open Folder.
-
You can install and activate any of the thousands extensions available by clicking on the extension icon and searching for a key word.
- You can close and resume the browser window anytime during your specified run time. If clicking on "My Interactive Sessions" in the upper menu bar, you can resume your session as explained in step 3.
- In order to terminate the session before the run time ends, go to "My Interactive Sessions", select the respective session and click on "Delete".
Example: Develop, run and debug Python code in a custom conda environment
If not yet done: Install the Python extension (see step 6 of example above).
-
Change into the working directory where your Python code is located by clicking on the menu icon → File → Open Folder.
-
In the explorer, select the file you like to modify.
-
Do your modifications. They will be saved automatically.
-
Activate your custom environment to run the code with:
a. Press F1
b. In the search-window, type "Python" and choose "Python: Select Interpreter"
c. Click on "+ Enter interpreter path..."
d. Enter the path to the Python-binary of your environment. You may click on "Find..." in order to browse for the file.
-
Click the "Run and Debug"-icon, and then "Run and Debug" in order to run the code and get debugging information
Example: Connect to DLR-GitLab
- Change to the explorer view:
- Change to the folder where to clone the GitLab repository to: menu icon
→ File → Open Folder
- If necessary, create a new folder and change into it as described in the step before.
-
Open a terminal: menu icon → Terminal → New Terminal
-
In the terminal, your working directoy is automatically set to the folder in your explorer. Now clone the repository by typing into the terminal Attention: You will be asked for your DLR-GitLab credentials in a popup-window.
git clone https://gitlab.dlr.de/your/repo
- If not yet done, specify your Git user name and email:
git config user.name "Surname, Name"
git config user.email "Name.Surname@dlr.de"
- Select the branch you would like to work with or create a new branch by clicking on the current branch in the lower left corner (in our case the master branch).
-
The current branch will be displayed in the lower left corner.
-
Make changes, test the code, etc.
-
To commit the changes, change to the source control section where all changes are listed. Enter a commit-message and click on "Commit". You may also stage the changes beforehand or directly stage them when prompted. Attention: You will be asked for your DLR-GitLab credentials in a popup-window.
Merge requests can be made directly out of VS code, but this requires to install the extension "GitLab Workflow". The installation and setup process is very straightforward and explained in the official GitLab documentation: https://docs.gitlab.com/ee/user/project/repository/vscode.html
Once the GitLab workflow extension has been setup, it can be opened via the GitLab-icon and merge requests can be made by clicking on "Create MR" at the bottom left of the browser window: