Skip to content

Conversation

@bmingles
Copy link
Contributor

@bmingles bmingles commented Oct 2, 2025

DH-19715: Python remote file source plugin

  • Python plugin that can be installed in a DH Core / Core+ worker
  • Registers custom sys.meta_path finder and loader that will request source code from a remote client
  • The plugin source includes a NodeJS based test client + a test workspace, but ultimately this plugin will be sourced by the VS Code extension (feat: DH-19715: VS Code - Remote Python execution vscode-deephaven#253)

Testing

There is a test Python workspace in plugins/python-remote-file-source/test-node-client/workspace. There are 2 test files that get run by the vitest test harness:

  • test_relative_imports.py
  • test_absolute_imports.py

Running the Tests

In the plugins repo root:

  1. Install dependencies
# Install js dependencies
nvm install
npm install

# Setup python venv and install dependencies
python -m venv .venv
source .venv/bin/activate
pip install --upgrade -r requirements.txt
pip install click watchdog deephaven-server
  1. Build the python-remote-file-source plugin
python tools/plugin_builder.py python-remote-file-source
  1. Start DH server

Note that the -Dprocess.info.system-info.enabled=false is only needed for Mac M1/M2.

python tools/plugin_builder.py \
 python-remote-file-source \
 --server \
 --server-arg \
 --jvm-args="-Dauthentication.psk=plugins.repo.test -Dprocess.info.system-info.enabled=false"
  1. Before running tests for the first time, install dependencies for the test client:
cd plugins/python-remote-file-source/test-node-client
nvm install
npm install
cd -
  1. Run nodejs tests
npm run test:remote-file-source

VS Code Extension

There is a .vsix attached to the DH-19715 that can be installed in VS Code if you want to see how the plugin integrates with VS Code.

@bmingles bmingles force-pushed the DH-19715_local-execution branch from 9c5f861 to 7e0af1d Compare October 2, 2025 19:44
@bmingles bmingles changed the title DH-19715: Python remote file source plugin feat: DH-19715: Python remote file source plugin Oct 2, 2025
@bmingles bmingles force-pushed the DH-19715_local-execution branch from 9e8f603 to bcfa90c Compare October 7, 2025 17:53
@bmingles bmingles requested a review from mofojed October 7, 2025 21:17
@bmingles bmingles marked this pull request as ready for review October 7, 2025 21:17
Copy link

@cpwright cpwright left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've looked at the Python and mostly skipped over the JS/TS. I've left micro-comments, but this is more of a macro design comment that you guys can think about. I might be misreading how this works as well.

One thing that I think we should consider is that the pipe to your Deephaven server instance is often narrow/has high latency. It may make sense to push more data to the worker rather than pulling it and being smarter on the VS Code side. In particular, from your demo I like how you have the ability to add several paths to the worker's import space.

I think that each of those top-level names would form a RemoteMetaPathFinder. if that is true, then we do have to request information from the client on each find_spec. Even when we are negative, the counterpoint ist hat negative requests in Python might be seemingly rare.

Instead of just sending the worker the top-level list of names, you could also send them the list of files that exist within each name; or maybe even contents. That would eliminate the need for "in-line" requests, because the worker could look things up in a cache.

It would however, also require significantly more front-end work; because we would need to watch the file system and send the server updated information whenever the watched file system paths change.

As I write this down, I think I am more convinced this is probably premature optimization for Python; and we can leave this as is.

@bmingles bmingles force-pushed the DH-19715_local-execution branch from 894c0e0 to 2f16dd4 Compare October 8, 2025 17:08
@bmingles bmingles force-pushed the DH-19715_local-execution branch from 13eeb70 to 4990ca8 Compare October 8, 2025 21:06
@bmingles bmingles requested review from cpwright and mofojed October 9, 2025 18:11
cpwright
cpwright previously approved these changes Oct 10, 2025
@bmingles bmingles force-pushed the DH-19715_local-execution branch from 4bbf4a4 to 9014638 Compare October 30, 2025 21:19
Copy link
Member

@mofojed mofojed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few cases on the server where we should just report the error and kill the connection.
A couple of questions why we're not using existing JSON RPC libraries instead of rolling our own functions/types.
Looks good overall though

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that there's anything wrong with this, but in deephaven.ui we used the json-rpc library for handling requests: https://pypi.org/project/json-rpc/
Handles passing methods off to a dispatcher and adding the appropriate ID to responses, etc. Just thinking there might be some edge cases that aren't handled correctly, such as notifications, but shouldn't matter for this case I don't think...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize we were already using a json-rpc library. I just opted not to bring in a dependency since the number of message types involved is very small and it's a pretty simple schema.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the json-rpc-2.0 library like we use in deephaven.ui?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had just avoided the extra dependency since number of message types is small. Also didn't realize we were using a library already to set some precedence.

@bmingles bmingles requested a review from mofojed November 5, 2025 17:30
@bmingles bmingles merged commit 8039d15 into deephaven:main Nov 7, 2025
10 checks passed
@bmingles bmingles deleted the DH-19715_local-execution branch November 7, 2025 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants