Shared Dev Based IDE Setup

You may find it easier to work with the SDK in a modern IDE with code completion, highlighting, and other useful features. Our preferred editor at Q2 is VSCode. It does everything you would expect from a powerful IDE alongside sophisticated remote debugging support. For a best-in-class editor that allows a quick start with minimal custom setup, VSCode is the right choice.

Prefer Eclipse, Vim, etc.? No problem, but we won’t be able to provide as much assistance. We’ve provided guides for VSCode and PyCharm setup below.

Important

As a Caliper SDK member, we recommend adding your public SSH key to GitLab and running clone_from_gitlab on the shared dev machine if you have not already.

Visual Studio Code

This section is for SDK clients using a Q2-provided stack.

  1. First, ensure you have already connected to the shared dev box with ssh using your method of choice (ssh on *nix. For Windows, refer to Windows SSH Installation)

    • Into a terminal of your choice, enter ssh sdk-shared-dev.q2devstack.com -l <username>. Your username is your email address, and the password is the same as what you use to log in to q2developer.com.

    • You should see any additional setup items listed for you when you log into shared dev, along with other helpful information.

  2. Download VSCode - https://code.visualstudio.com/download

  3. Once VSCode is downloaded and opened, we need to connect it the remote server. For this we need the Remote Development Extension Pack

    • Open the VSCode Extension marketplace (Preferences -> extensions or CTRL+SHIFT+X)

    • Search for the Remote - SSH Extension and Install it

    ../../_images/vscode-remotesshextension.png
  4. (optional) Add SSH key authentication to the shared dev server - See https://code.visualstudio.com/docs/remote/troubleshooting#_configuring-key-based-authentication

  5. Select the SSH tab on the left and configure a new target by hitting the ‘+’ icon. Enter the ssh command from the first step and select your desired config file. You should see your newly configured host on the SSH tab

    Note

    This step may ask what kind of server you are connecting to. The Shared Development Server is a Linux box.

    ../../_images/vscode-configuredsshhost.png
  6. Connect to the ssh host. Open the command palette (F1/CMD+SHIFT+P), enter Remote-SSH: Connect to Host..., and select the new host. Once connected you should see the following in the bottom left of your window

  7. Open up the extension marketplace again. Search for “Q2 SDK Extension Pack” and click on “Install on SSH”. Then reload the window.

    ../../_images/vscode-extensionpack.png
  8. Go back to the first tab(Explorer tab) and click the Open Folder button. Open /home/<username>/sdk

    ../../_images/vscode-openfolder.png
  9. Run Preferences: Open Remote Settings (JSON) (SSH: sdk-shared-dev.q2devstack.com) from the Command Palette (F1). Your remote machine settings.json should look like the json blob below. If not, copy this into your settings.json file:

    {
        "python.defaultInterpreterPath": ".env/bin/python",
        "ruff.args": ["--extend-select=B006"],
        "terminal.integrated.defaultProfile.linux": "bash"
    }
    
  10. Enter generate_vscode_files into a terminal in your ssh session. This should create a .vscode directory in your /home/<username>/sdk directory. Please verify that the contents of the 3 files in the .vscode directory match the following:

    settings.json:

    {
      "files.exclude": {
        "**/__pycache__": true,
        "**/.antilles": true,
        "**/.env": true
      },
      "mssql.connections": [
        {
          "server": <db_host>,
          "port": <db_port>,
          "database": "Q2DB_sdk_<stack_name>",
          "authenticationType": "SqlLogin",
          "user": <db_user>,
          "password": <db_password>,
          "emptyPasswordInput": false,
          "savePassword": true,
          "profileName": "<stack_name>"
        }
      ],
      "python.defaultInterpreterPath": ".env/bin/python",
      "ruff.lint.args": ["--extend-select=B006"]
    }
    

    launch.json:

    {
      "version": "0.2.0",
      "configurations": [
        {
          "name": "q2 run",
          "type": "python",
          "request": "launch",
          "program": "/usr/local/bin/q2",
          "args": [
            "run"
          ],
          "console": "integratedTerminal"
        }
      ]
    }
    

    extensions.json:

    {
      "recommendations": [
        "q2.vscode-sdk-pack"
      ]
    }
    
  11. Your Visual Studio code is now setup to do development and debugging!

PyCharm

Warning

The remote configuration is only an option in the professional version of PyCharm, and is currently unavailable in community edition. The trial version is what you want if you do not already have a license. Please consider using VSCode with its remote development capabilities, described above.

  1. On your local workstation, create a new directory you want use as your Q2SDK PyCharm project.

  2. Open your PyCharm project

    ../../_images/pycharm-open-project.png
  3. Add your SSH Configuration

    • Pycharm Preferences/Settings -> Tools -> SSH Configurations

      ../../_images/pycharm-add-ssh.png
    • Host: sdk-shared-dev.q2devstack.com

    • Username: provided in Welcome email

    • Password: same as developer portal

      ../../_images/pycharm-ssh-config.png
  4. Configure your Project Interpreter for the Remote Python environment.

    A Remote Python Interpreter will allow PyCharm to read and execute code on the shared dev box from your workstation.

    • Pycharm Preferences/Settings -> Project -> Project Interpreter

    • Add Interpreter by clicking on the settings cog:

      ../../_images/pycharm-interpreter-cog.png
    • Add SSH Interpreter from your existing SSH Configuration

      ../../_images/pycharm-ssh-interpreter.png
    • Edit the Interpreter path and Sync folders as follows:

      Interpreter: /home/<username>/sdk/.env/bin/python

      ../../_images/pycharm-remote-interpreter-settings.png

      Sync folders: Set Remote path to /

      ../../_images/pycharm-edit-sync-folders.png

      click Finish

      ../../_images/pycharm-sshinterpreter-finish.png

      Your Project Interpreter should appear similar to this:

      ../../_images/pycharm-interpreter-success.png
  5. Configure your Remote Host

    • By adding your remote interpreter, you should now see your remote host option

      ../../_images/pycharm-select-new-remote.png
    • Click on the Remote Host tab (Tools -> Deployment -> Browse Remote Host)

      ../../_images/pycharm-remotehostpointer.png
    • Edit Remote Host Settings

      ../../_images/pycharm-edit-remote-host.png
    • Set the root sdk directory for the remote host, and use your existing SSH Configuration

      ../../_images/pycharm-sftp-root-dir.png
    • Exclude .env and .antilles directories from Deployment Path

      ../../_images/pycharm-excluded-dirs.png
  6. Configure your Database Connection

    • Click on the Database tab and add your Microsoft SQL Server Data Source

      ../../_images/pycharm-add-data-source.png
    • Configure Database Port and User

      ../../_images/pycharm-configure-data-source.png
    • Use SSH tunnel by selecting your existing SSH Configuration

      ../../_images/pycharm-use-ssh-tunnel.png
    • Select your database and all schemas

      ../../_images/pycharm-db-select.png
      ../../_images/pycharm-select-schemas.png
  7. Set up Remote Debugging

    • Add your remote debugger, SDK Debug

      ../../_images/pycharm-add-debug.png
      ../../_images/pycharm-debug-config.png
  8. Working with PyCharm

    • New remote files will need to be downloaded:

      ../../_images/pycharm-download-remote.png
    • Local file changes should be automatically uploaded to the remote host:

      ../../_images/pycharm-auto-upload.png
  9. You should now be ready. Here’s two pieces to get you started:

    • Tools -> Deployment -> Browse Remote Host will show you files on the server. You can download and edit them locally by right clicking on them

    • Tools -> Start SSH Session -> <Your Deployment Name> will let you access the remote server from the command line. Handy for running commands in the Tutorial!