Skip to main content

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,

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

Portal Development menu VS Code entry

  1. Select the number of cores to be used for the session (2 or 4) and the desired run time and click on "Launch".

Portal VS Code allocation

  1. Once the session is ready, you can connect to it via "Connect to VS Code".

Portal VS Code launcher

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

Portal VS Code welcome page

  1. By default, the file explorer shows your home directory. You can access other folders/projects on the DSS by clicking on the menu icon Portal menu stack icon → File → Open Folder.

  2. You can install and activate any of the thousands extensions available by clicking on the extension icon Portal VS Code extensions icon and searching for a key word.

Portal VS Code extensions

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

Portal My Interactive Sessions menu

  1. In order to terminate the session before the run time ends, go to "My Interactive Sessions", select the respective session and click on "Delete".

Portal VS Code delete session

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

  1. Change into the working directory where your Python code is located by clicking on the menu icon Portal menu stack icon → File → Open Folder.

  2. In the explorer, select the file you like to modify.

  3. Do your modifications. They will be saved automatically.

  4. Activate your custom environment to run the code with:

    a. Press F1

    b. In the search-window, type "Python" and choose "Python: Select Interpreter"

    Portal VS Code select interpreter

    c. Click on "+ Enter interpreter path..."

    Portal VS Code 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.

    Portal VS Code select interpreter

  5. Click the "Run and Debug"-icon, and then "Run and Debug" in order to run the code and get debugging information

Portal VS Code rund and debug

Portal VS Code debugger

Example: Connect to DLR-GitLab

  1. Change to the explorer view:

Portal VS Code explorer view icon

  1. Change to the folder where to clone the GitLab repository to: menu icon

Portal VS Code menu icon → File → Open Folder

  1. If necessary, create a new folder and change into it as described in the step before.

Portal VS Code new folder

  1. Open a terminal: menu icon Portal VS Code menu icon → Terminal → New Terminal

  2. 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
  1. 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"
  1. 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).

Portal VS Code create new branch

  1. The current branch will be displayed in the lower left corner.

  2. Make changes, test the code, etc.

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

Portal VS Code commit

Merge Requests

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 Portal VS Code GitLab icon and merge requests can be made by clicking on "Create MR" at the bottom left of the browser window:

Portal VS Code merge request