holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.77k stars 519 forks source link

VSCode not automatically detected when using Remote Containers #3876

Open ddrinka opened 2 years ago

ddrinka commented 2 years ago

ALL software version info

Library Version
VS Code 1.71.2
python 3.9.13 64-bit
panel ~0.13.1~ 0.14.0a25
jupyterlab 3.4.6
bokeh 2.4.3
jupyter-bokeh 3.0.5
pandas 1.4.4
ipywidgets 8.0.2

.devcontainer configuration

devcontainer.json Dockerfile

Description of expected behavior and the observed behavior

Panel should provide interactivity to charts in Visual Studio Code. In Remote Containers mode, Panel does not provide interactivity.

Complete, minimal, self-contained example code that reproduces the issue

I'm using the Panel Getting Started notebook.


VSCODE_PID is not defined in Remote Containers

import panel as pn
pn.extension()
pn.config.comms # default
...
pn.interact(find_outliers)

Chart is not interactive.


import panel as pn
pn.extension(comms='vscode')
pn.config.comms  # vscode
...
pn.interact(find_outliers)

Chart is interactive.

philippjfr commented 2 years ago

Which version of ipywidgets are you running? The ipywidgets 8.0 release has been somewhat disruptive and I wouldn't be surprised if that's what's causing this.

ddrinka commented 2 years ago

Ok, using the daily build the exception went away, so now this issue is just around auto-detection of VSCode when using Remote Containers.

MarcSkovMadsen commented 2 years ago

Panel uses environment variables to detect vs code. Could you print(os.environ) and share the results? (Please remove anything private first).

philippjfr commented 2 years ago

If the VSCode server is running remotely those environment variables probably won't be set.

jbednar commented 2 years ago

In which case is there something else we should be checking to detect it? That may be a question for the VSCode team.

ddrinka commented 2 years ago

os.environ:

environ = {'HOSTNAME': '68948ad90c70',
        'PIPX_HOME': '/usr/local/py-utils',
        'PYTHON_PIP_VERSION': '22.0.4',
        'HOME': '/home/vscode',
        'PIPX_BIN_DIR': '/usr/local/py-utils/bin',
        'NVM_SYMLINK_CURRENT': 'true',
        'GPG_KEY': '<REDACTED>',
        'PYTHON_PATH': '/usr/local/python/current',
        'NVM_DIR': '/usr/local/share/nvm',
        'PYTHON_GET_PIP_URL': 'https://github.com/pypa/get-pip/raw/5eaac1050023df1f5c98b173b248c260023f2278/public/get-pip.py',
        'PATH': '/usr/local/bin:/vscode/vscode-server/bin/linux-x64/74b1f979648cc44d385a2286793c226e611f59e7/bin/remote-cli:/usr/local/share/nvm/current/bin:/usr/local/python/current/bin:/usr/local/bin:/usr/local/share/nvm/current/bin:/usr/local/python/current/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/py-utils/bin:/home/vscode/.local/bin:/usr/local/py-utils/bin',
        'VSCODE_AGENT_FOLDER': '/home/vscode/.vscode-server',
        'LANG': 'C.UTF-8',
        'SHELL': '/bin/bash',
        'PYTHON_VERSION': '3.9.13',
        'PYTHON_SETUPTOOLS_VERSION': '58.1.0',
        'PWD': '/vscode/vscode-server/bin/linux-x64/74b1f979648cc44d385a2286793c226e611f59e7',
        'PYTHON_GET_PIP_SHA256': '5aefe6ade911d997af080b315ebcb7f882212d070465df544e1175ac2be519b4',
        'VSCODE_HANDLES_SIGPIPE': 'true',
        'VSCODE_AMD_ENTRYPOINT': 'vs/workbench/api/node/extensionHostProcess',
        'VSCODE_HANDLES_UNCAUGHT_ERRORS': 'true',
        'VSCODE_NLS_CONFIG': '{"locale":"en","availableLanguages":{}}',
        'NVM_RC_VERSION': '',
        'REMOTE_CONTAINERS_IPC': '/tmp/vscode-remote-containers-ipc-0e8fe9f88438da0f52e1679977b4850e36e31441.sock',
        'LS_COLORS': '',
        'REMOTE_CONTAINERS_SOCKETS': '["/tmp/vscode-ssh-auth-0e8fe9f88438da0f52e1679977b4850e36e31441.sock"]',
        'USER': 'vscode',
        'SHLVL': '1',
        'NVM_CD_FLAGS': '',
        'PROMPT_DIRTRIM': '4',
        '_': '/bin/cat',
        'SSH_AUTH_SOCK': '/tmp/vscode-ssh-auth-0e8fe9f88438da0f52e1679977b4850e36e31441.sock',
        'REMOTE_CONTAINERS': 'true',
        'BROWSER': '/vscode/vscode-server/bin/linux-x64/74b1f979648cc44d385a2286793c226e611f59e7/bin/helpers/browser.sh',
        'VSCODE_CWD': '/vscode/vscode-server/bin/linux-x64/74b1f979648cc44d385a2286793c226e611f59e7',
        'ELECTRON_RUN_AS_NODE': '1',
        'VSCODE_IPC_HOOK_CLI': '/tmp/vscode-ipc-7af855a2-86e4-4811-a6ce-6b18d55039f3.sock',
        'PYSPARK_SUBMIT_ARGS': '--properties-file local_debug_spark_properties.conf pyspark-shell',
        'BOKEH_ALLOW_WS_ORIGIN': '*',
        'PYTHONUNBUFFERED': '1',
        'PYTHONIOENCODING': 'utf-8',
        'TERM': 'xterm-color',
        'CLICOLOR': '1',
        'PAGER': 'cat',
        'GIT_PAGER': 'cat',
        'MPLBACKEND': 'module://matplotlib_inline.backend_inline',
        'PYDEVD_IPYTHON_COMPATIBLE_DEBUGGING': '1'}
philippjfr commented 2 years ago

Actually I'm a little confused by how VSCode works in this instance. Surely if the VSCode notebook is running remotely then the python process is also running there and the auto-detection needs to check for environment variables that are defined there. @ddrinka Does that list of env vars come from your local or remote machine?

ddrinka commented 2 years ago

Those environment variables are from the Python kernel's perspective, on the remote machine. "Remote Machine" is just a docker container running locally.