Skip to content

Commit 0cd9bd4

Browse files
authored
SSH: enable databricks extension on the remote side (#4764)
## Changes The extension changes are in a separate PR - databricks/databricks-vscode#1861 Here we set our extension id to the IDE settings And also set special env var that will tell the extension to initialize in a special "remote" mode, wher it only sets the active venv and does nothing else (for now) ## Why venv activation is one of the main friction points ## Tests <!-- How have you tested the changes? --> <!-- If your PR needs to be included in the release notes for next release, add a separate entry in NEXT_CHANGELOG.md as part of your PR. -->
1 parent 9767900 commit 0cd9bd4

File tree

3 files changed

+17
-12
lines changed

3 files changed

+17
-12
lines changed

experimental/ssh/internal/client/ssh-server-bootstrap.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ def run_ssh_server():
9292
os.environ["DATABRICKS_TOKEN"] = ctx.apiToken
9393
os.environ["DATABRICKS_CLUSTER_ID"] = ctx.clusterId
9494
os.environ["DATABRICKS_VIRTUAL_ENV"] = sys.executable
95+
os.environ["DATABRICKS_REMOTE_ENV"] = "1"
9596
python_path = os.path.dirname(sys.executable)
9697
os.environ["PATH"] = f"{python_path}:{os.environ['PATH']}"
9798
if os.environ.get("VIRTUAL_ENV") is None:

experimental/ssh/internal/vscode/settings.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const (
2222
remotePlatform = "linux"
2323
pythonExtension = "ms-python.python"
2424
jupyterExtension = "ms-toolsai.jupyter"
25+
databricksExtension = "databricks.databricks"
2526
serverPickPortsKey = "remote.SSH.serverPickPortsFromRange"
2627
remotePlatformKey = "remote.SSH.remotePlatform"
2728
defaultExtensionsKey = "remote.SSH.defaultExtensions"
@@ -178,7 +179,7 @@ func hasCorrectListenOnSocket(v hujson.Value) bool {
178179
}
179180

180181
func getMissingExtensions(v hujson.Value) []string {
181-
required := []string{pythonExtension, jupyterExtension}
182+
required := []string{pythonExtension, jupyterExtension, databricksExtension}
182183
found := v.Find(jsonPtr(defaultExtensionsKey))
183184
if found == nil {
184185
return required
@@ -244,7 +245,7 @@ func handleMissingFile(ctx context.Context, ide, connectionName, settingsPath st
244245
portRange: true,
245246
platform: true,
246247
listenOnSocket: true,
247-
extensions: []string{pythonExtension, jupyterExtension},
248+
extensions: []string{pythonExtension, jupyterExtension, databricksExtension},
248249
}
249250
shouldCreate, err := promptUserForUpdate(ctx, ide, connectionName, missing)
250251
if err != nil {
@@ -348,7 +349,7 @@ func GetManualInstructions(ide, connectionName string) string {
348349
portRange: true,
349350
platform: true,
350351
listenOnSocket: true,
351-
extensions: []string{pythonExtension, jupyterExtension},
352+
extensions: []string{pythonExtension, jupyterExtension, databricksExtension},
352353
}
353354
return fmt.Sprintf(
354355
"To ensure the remote connection works as expected, manually add these settings to your %s settings.json:\n%s",

experimental/ssh/internal/vscode/settings_test.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ func TestValidateSettings_Complete(t *testing.T) {
199199
"remote.SSH.serverPickPortsFromRange": {"test-conn": "29500-29505"},
200200
"remote.SSH.remotePlatform": {"test-conn": "linux"},
201201
"remote.SSH.remoteServerListenOnSocket": true,
202-
"remote.SSH.defaultExtensions": ["ms-python.python", "ms-toolsai.jupyter"]
202+
"remote.SSH.defaultExtensions": ["ms-python.python", "ms-toolsai.jupyter", "databricks.databricks"]
203203
}`)
204204

205205
missing := validateSettings(v, "test-conn")
@@ -213,7 +213,7 @@ func TestValidateSettings_Missing(t *testing.T) {
213213
assert.False(t, missing.isEmpty())
214214
assert.True(t, missing.portRange)
215215
assert.True(t, missing.platform)
216-
assert.Equal(t, []string{"ms-python.python", "ms-toolsai.jupyter"}, missing.extensions)
216+
assert.Equal(t, []string{"ms-python.python", "ms-toolsai.jupyter", "databricks.databricks"}, missing.extensions)
217217
}
218218

219219
func TestValidateSettings_IncorrectValues(t *testing.T) {
@@ -227,15 +227,15 @@ func TestValidateSettings_IncorrectValues(t *testing.T) {
227227
assert.False(t, missing.isEmpty())
228228
assert.True(t, missing.portRange)
229229
assert.True(t, missing.platform)
230-
assert.Equal(t, []string{"ms-toolsai.jupyter"}, missing.extensions)
230+
assert.Equal(t, []string{"ms-toolsai.jupyter", "databricks.databricks"}, missing.extensions)
231231
}
232232

233233
func TestValidateSettings_DuplicateExtensionsNotReported(t *testing.T) {
234234
v := parseTestValue(t, `{
235235
"remote.SSH.serverPickPortsFromRange": {"test-conn": "29500-29505"},
236236
"remote.SSH.remotePlatform": {"test-conn": "linux"},
237237
"remote.SSH.remoteServerListenOnSocket": true,
238-
"remote.SSH.defaultExtensions": ["ms-python.python", "ms-python.python", "ms-toolsai.jupyter"]
238+
"remote.SSH.defaultExtensions": ["ms-python.python", "ms-python.python", "ms-toolsai.jupyter", "databricks.databricks"]
239239
}`)
240240

241241
missing := validateSettings(v, "test-conn")
@@ -246,7 +246,7 @@ func TestValidateSettings_MissingConnection(t *testing.T) {
246246
v := parseTestValue(t, `{
247247
"remote.SSH.serverPickPortsFromRange": {"other-conn": "29500-29505"},
248248
"remote.SSH.remotePlatform": {"other-conn": "linux"},
249-
"remote.SSH.defaultExtensions": ["ms-python.python", "ms-toolsai.jupyter"]
249+
"remote.SSH.defaultExtensions": ["ms-python.python", "ms-toolsai.jupyter", "databricks.databricks"]
250250
}`)
251251

252252
// Validating for a different connection should show port and platform as missing
@@ -273,7 +273,7 @@ func TestUpdateSettings_PreserveExistingConnections(t *testing.T) {
273273
missing := &missingSettings{
274274
portRange: true,
275275
platform: true,
276-
extensions: []string{"ms-python.python", "ms-toolsai.jupyter"},
276+
extensions: []string{"ms-python.python", "ms-toolsai.jupyter", "databricks.databricks"},
277277
}
278278

279279
err := updateSettings(&v, "conn-c", missing)
@@ -307,10 +307,11 @@ func TestUpdateSettings_PreserveExistingConnections(t *testing.T) {
307307

308308
// Check that extensions were merged
309309
exts := findStringSlice(t, v, jsonPtr(defaultExtensionsKey))
310-
assert.Len(t, exts, 3)
310+
assert.Len(t, exts, 4)
311311
assert.Contains(t, exts, "other.extension")
312312
assert.Contains(t, exts, "ms-python.python")
313313
assert.Contains(t, exts, "ms-toolsai.jupyter")
314+
assert.Contains(t, exts, "databricks.databricks")
314315
}
315316

316317
func TestUpdateSettings_NewConnection(t *testing.T) {
@@ -319,7 +320,7 @@ func TestUpdateSettings_NewConnection(t *testing.T) {
319320
missing := &missingSettings{
320321
portRange: true,
321322
platform: true,
322-
extensions: []string{"ms-python.python", "ms-toolsai.jupyter"},
323+
extensions: []string{"ms-python.python", "ms-toolsai.jupyter", "databricks.databricks"},
323324
}
324325

325326
err := updateSettings(&v, "new-conn", missing)
@@ -334,9 +335,10 @@ func TestUpdateSettings_NewConnection(t *testing.T) {
334335
assert.Equal(t, "linux", val)
335336

336337
exts := findStringSlice(t, v, jsonPtr(defaultExtensionsKey))
337-
assert.Len(t, exts, 2)
338+
assert.Len(t, exts, 3)
338339
assert.Contains(t, exts, "ms-python.python")
339340
assert.Contains(t, exts, "ms-toolsai.jupyter")
341+
assert.Contains(t, exts, "databricks.databricks")
340342
}
341343

342344
func TestUpdateSettings_GlobalExtensions(t *testing.T) {
@@ -544,6 +546,7 @@ func TestGetManualInstructions_VSCode(t *testing.T) {
544546
assert.Contains(t, instructions, "linux")
545547
assert.Contains(t, instructions, "ms-python.python")
546548
assert.Contains(t, instructions, "ms-toolsai.jupyter")
549+
assert.Contains(t, instructions, "databricks.databricks")
547550
assert.Contains(t, instructions, "remote.SSH.serverPickPortsFromRange")
548551
assert.Contains(t, instructions, "remote.SSH.remotePlatform")
549552
assert.Contains(t, instructions, "remote.SSH.defaultExtensions")

0 commit comments

Comments
 (0)