File tree Expand file tree Collapse file tree 9 files changed +41
-16
lines changed
packages/databricks-vscode Expand file tree Collapse file tree 9 files changed +41
-16
lines changed Original file line number Diff line number Diff line change 346346 },
347347 {
348348 "command" : " databricks.run.runEditorContentsAsWorkflow" ,
349- "when" : " resourceLangId == python || resourceExtname == .ipynb" ,
349+ "when" : " resourceLangId == python || resourceLangId == scala || resourceLangId == r || resourceLangId == sql || resourceExtname == .ipynb" ,
350350 "group" : " navigation@1"
351351 }
352352 ],
464464 {
465465 "type" : " databricks-workflow" ,
466466 "languages" : [
467- " python"
467+ " python" ,
468+ " sql" ,
469+ " r" ,
470+ " scala"
468471 ],
469472 "label" : " Databricks Workflow" ,
470473 "configurationAttributes" : {
666669 ],
667670 "report-dir" : " coverage"
668671 }
669- }
672+ }
Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ export class ConnectionCommands implements Disposable {
231231 alwaysShow : true ,
232232 detail : workspaceConfigs . enableFilesInWorkspace
233233 ? ""
234- : `Open Databricks in the browser and create a new repo under /Repo/${ me } ` ,
234+ : `Open Databricks in the browser and create a new Repo under /Repo/${ me } ` ,
235235 } ,
236236 {
237237 label : "" ,
Original file line number Diff line number Diff line change @@ -376,7 +376,7 @@ export class ConnectionManager {
376376 this . databricksWorkspace === undefined
377377 ) {
378378 throw new Error (
379- "Can't attach a Repo when profile is not connected"
379+ "Can't attach a Sync Destination when profile is not connected"
380380 ) ;
381381 }
382382 if ( ! ( await SyncDestination . validateRemote ( this , workspacePath ) ) ) {
Original file line number Diff line number Diff line change @@ -157,7 +157,7 @@ export class SyncDestination {
157157 localToRemoteNotebook ( localPath : Uri ) : string {
158158 assert . equal ( localPath . scheme , "file" ) ;
159159 return this . localToRemote ( localPath ) . replace (
160- / ^ \/ W o r k s p a c e ( \/ .* ) \. ( p y | i p y n b ) / g,
160+ / ^ \/ W o r k s p a c e ( \/ .* ) \. ( p y | i p y n b | s c a l a | r | s q l ) / g,
161161 "$1"
162162 ) ;
163163 }
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import {Subject} from "./Subject";
2525import { WorkflowRunner } from "./WorkflowRunner" ;
2626import { promptForClusterStart } from "./prompts" ;
2727import { CodeSynchronizer } from "../sync/CodeSynchronizer" ;
28+ import { isNotebook } from "../utils" ;
2829
2930/**
3031 * This interface describes the mock-debug specific launch attributes
@@ -154,6 +155,13 @@ export class DatabricksWorkflowDebugSession extends LoggingDebugSession {
154155 parameters : Record < string , string > ,
155156 args : Array < string >
156157 ) : Promise < void > {
158+ if (
159+ ! ( await isNotebook ( Uri . file ( program ) ) ) &&
160+ ! program . endsWith ( ".py" )
161+ ) {
162+ return this . onError ( "Only Python files can be run as a workflow" ) ;
163+ }
164+
157165 if ( this . connection . state === "CONNECTING" ) {
158166 await this . connection . waitForConnect ( ) ;
159167 }
Original file line number Diff line number Diff line change @@ -34,12 +34,12 @@ export class RunCommands {
3434 if ( this . connection . syncDestination === undefined ) {
3535 await promptForAttachingSyncDest ( async ( ) => {
3636 window . showErrorMessage (
37- "Execution cancelled because no Databricks Repo is attached "
37+ "Execution cancelled because no Sync Destination is configured "
3838 ) ;
3939 } ) ;
4040 if ( this . connection . syncDestination === undefined ) {
4141 window . showErrorMessage (
42- "Execution cancelled because no Databricks Repo is attached "
42+ "Execution cancelled because no Sync Destination is configured "
4343 ) ;
4444 return ;
4545 }
@@ -73,12 +73,12 @@ export class RunCommands {
7373 if ( this . connection . syncDestination === undefined ) {
7474 await promptForAttachingSyncDest ( async ( ) => {
7575 window . showErrorMessage (
76- "Execution cancelled because no Databricks Repo is attached "
76+ "Execution cancelled because no Sync Destination is configured "
7777 ) ;
7878 } ) ;
7979 if ( this . connection . syncDestination === undefined ) {
8080 window . showErrorMessage (
81- "Execution cancelled because no Databricks Repo is attached "
81+ "Execution cancelled because no Sync Destination is configured "
8282 ) ;
8383 return ;
8484 }
Original file line number Diff line number Diff line change @@ -30,12 +30,12 @@ export async function promptForAttachingSyncDest(
3030 onAccept : ( ) => Promise < void > = async ( ) => { }
3131) {
3232 const response = await window . showErrorMessage (
33- "Please configure a Databricks Repo for syncing " ,
34- "Attach Repo " ,
33+ "Please configure a Sync Destination " ,
34+ "Configure Sync Destination " ,
3535 "Cancel"
3636 ) ;
3737 switch ( response ) {
38- case "Attach Repo " :
38+ case "Configure Sync Destination " :
3939 await commands . executeCommand (
4040 "databricks.connection.attachSyncDestination"
4141 ) ;
Original file line number Diff line number Diff line change @@ -83,7 +83,7 @@ export class CodeSynchronizer implements Disposable {
8383
8484 // This function waits for sync to reach WATCHING_FOR_CHANGES which is a
8585 // necessary condition to execute local code on databricks. This state denotes
86- // all local changes have been synced to remote workspace repo
86+ // all local changes have been synced to remote workspace
8787 async waitForSyncComplete ( ) : Promise < void > {
8888 if ( this . _state !== "WATCHING_FOR_CHANGES" ) {
8989 return await new Promise ( ( resolve ) => {
Original file line number Diff line number Diff line change @@ -2,12 +2,26 @@ import {TextDecoder} from "util";
22import { Uri , workspace } from "vscode" ;
33
44export async function isNotebook ( uri : Uri ) : Promise < boolean > {
5- if ( uri . path . match ( / \. i p y n b $ / ) ) {
5+ const ext = uri . path . split ( "." ) . pop ( ) ?. toLowerCase ( ) ;
6+ if ( ! ext ) {
7+ return false ;
8+ }
9+
10+ if ( ext === "ipynb" ) {
611 return true ;
712 }
13+
14+ const comment = {
15+ py : "#" ,
16+ scala : "//" ,
17+ sql : "--" ,
18+ r : "#" ,
19+ } [ ext ] ;
20+
821 const bytes = await workspace . fs . readFile ( uri ) ;
922 const lines = new TextDecoder ( ) . decode ( bytes ) . split ( / \r ? \n / ) ;
1023 return (
11- lines . length > 0 && lines [ 0 ] . startsWith ( "# Databricks notebook source" )
24+ lines . length > 0 &&
25+ lines [ 0 ] . startsWith ( `${ comment } Databricks notebook source` )
1226 ) ;
1327}
You can’t perform that action at this time.
0 commit comments