Using interactive sessions with Microsoft Visual Studio Code - Amazon Glue
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Using interactive sessions with Microsoft Visual Studio Code

Prerequisites

  • Install Amazon Glue interactive sessions and verify it works with Jupyter Notebook.

  • Download and install Visual Studio Code with Jupyter. For details, see Jupyter Notebook in VS Code.

To get started with interactive sessions with VSCode
  1. Disable Jupyter AutoStart in VS Code.

    In Visual Studio Code, Jupyter kernels will auto-start which will prevent your magics from taking effect as the session will already be started. To disable Auto Start on Windows, go to File > Preferences > Extensions > Jupyter > right-click on Jupyter then choose Extension Settings.

    On MacOS, go to Code > Settings > Extensions > Jupyter > right-click on Jupyter then choose Extension Settings.

    Scroll down until you see Jupyter: Disable Jupyter Auto Start. Check the box "When true, disables Jupyter from being automatically started for you. You must instead run a cell to start Jupyter."

    The screenshot shows the checkbox enabled in for the Jupyter Extension in VS Code.
  2. Go to File > New File > Save to save this file with name of your choice as an .ipynb extension or select jupyter under select a language and save the file.

    The screenshot shows the file being saved with a new name.
  3. Double-click on the file. The Jupyter shell will display and a notebook will be opened.

    The screenshot shows the open notebook.
  4. On Windows, when you first create a file, by default no kernel is selected. Click on Select Kernel and a list of available kernels is displayed. Choose Glue PySpark.

    On MacOS, If you do not see the Glue PySpark kernel, try the following steps:

    1. Run a local Jupyter session to obtain the URL.

      For example, run the following command to launch Jupyter Notebook.

      jupyter notebook

      When the notebook first runs, you will see a URL that looks like http://localhost:8888/?token=3398XXXXXXXXXXXXXXXX.

      Copy the URL.

    2. In VS Code, click the current kernel, then Select Another Kernel..., then select Existing Jupyter Server.... Paste the URL you copied from the step above.

      If you receive an error message, see the VS Code Jupyter wiki .

    3. If successful, this will set the kernel to Glue PySpark.

    The screenshot shows the Select Kernel button highlighted.

    Choose the Glue PySpark or Glue Spark kernel (for Python and Scala respectively).

    The screenshot shows the selection for Amazon Glue PySpark.

    If you don't see Amazon Glue PySpark and Amazon Glue Spark kernels in the drop-down list, please ensure you have installed the Amazon Glue kernel in the step above, or that your python.defaultInterpreterPath setting in Visual Studio Code is correct. For more information, see python.defaultInterpreterPath setting description .

  5. Create an Amazon Glue Interactive Session. Proceed to create a session in the same manner as you did in Jupyter Notebook. Specify any magics at the top of your first cell and run a statement of code.