-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #539 from shengyfu/master
Enable pyspark development in vscode
- Loading branch information
Showing
4 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"use strict"; | ||
import { Commands } from '../common/constants'; | ||
import * as vscode from "vscode"; | ||
import * as path from 'path'; | ||
import { IS_WINDOWS } from '../common/utils'; | ||
|
||
export function activateUpdateSparkLibraryProvider(): vscode.Disposable { | ||
console.log('Register command python.updateSparkLibrary'); | ||
return vscode.commands.registerCommand(Commands.Update_SparkLibrary, updateSparkLibrary); | ||
} | ||
|
||
function updateSparkLibrary() { | ||
const pythonConfig = vscode.workspace.getConfiguration('python'); | ||
const extraLibPath = 'autoComplete.extraPaths'; | ||
let sparkHomePath = '${env.SPARK_HOME}'; | ||
pythonConfig.update(extraLibPath, [path.join(sparkHomePath, 'python'), | ||
path.join(sparkHomePath, 'python/pyspark')]).then(() => { | ||
//Done | ||
}, reason => { | ||
vscode.window.showErrorMessage(`Failed to update ${extraLibPath}. Error: ${reason.message}`); | ||
console.error(reason); | ||
}); | ||
if (IS_WINDOWS) { | ||
const pysparkPath = 'pysparkPath'; | ||
console.log('Overriding ' + pysparkPath); | ||
pythonConfig.update(pysparkPath, path.join(sparkHomePath, 'bin', 'spark-submit.cmd')).then(() => { | ||
//Done | ||
}, reason => { | ||
vscode.window.showErrorMessage(`Failed to update ${pysparkPath}. Error: ${reason.message}`); | ||
console.error(reason); | ||
}); | ||
} | ||
vscode.window.showInformationMessage(`Make sure you have SPARK_HOME environment variable set to the root path of the local spark installation!`); | ||
} |