Skip to content

SMT setup VSCodeConfig

Roman Cattaneo edited this page Aug 14, 2024 · 1 revision

VSCode Configuration

VSCode has many configuration options and an active plugin ecosystem. Editor configuration (as well as the editor itself) is a user choice and we respect this. This guide thus a a collection of useful snippets, extensions, and debug launch configurations, which we think are worth sharing with the team.

Extensions

A plethora of extensions are available for VSCode. Most of them target streamlining workflows, which can be a huge time-saver. We found the following to be useful (in no particular order)

  • Python (language support including pylance & debugger) / Black Formatter
  • Modern Fortran (without the fortls engine or else the extension dies trying to figure out GEOS)
  • H5Web for netcdf inline viewing
  • DaCe SDFG Editor (in case you work with DaCe graphs)
  • your standard set of git extensions
  • Live Share (remote pair-programming)
  • Draw.io Integration (draw & share graphs directly from within VSCode - we've seen scaling errors when mixed with graphs created from the website)

Format on save

While pre-commit is the source of truth, having format on save support in the editor can be a huge time-saver. To enable format on save

  1. Install the "Black Formatter" extension (see above)
  2. Configure "Black Formatter" as the default formatter for python files and enable format on save. In .vscode/settings.json add
{
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true
    },
}

Debugging

In VSCode, debugging tasks can be configured with so called “launch configurations”, that live in launch.json files. Sharing these here will help the team debug faster.

Translate tests

⚠️ Blindly copy/pasting the snippet below will not work because of hard-coded paths in the config. We should clean this up and/or explain them in the snippet.

{
    "name": "Translate - pyMoist",
    "type": "debugpy",
    "request": "launch",
    "module": "pytest",
    "args": [
        "-s",
        "-v",
        "-x",
        "--data_path=/home/mad/work/fp/geos/src/Components/@GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSmoist_GridComp/pyMoist/test_data/geos_11.5.2/moist",
        "--grid=default",
        "--backend=numpy",
        "--which_modules=evap_subl_pdf",
        "/home/mad/work/fp/geos/src/Components/@GEOSgcm_GridComp/GEOSagcm_GridComp/GEOSphysics_GridComp/GEOSmoist_GridComp/pyMoist/tests"
    ],
    "env": {
        "PACE_TEST_N_THRESHOLD_SAMPLES": "0",
        "PACE_FLOAT_PRECISION": "32"
    }
}