Skip to content

Commit

Permalink
fix issue with deprecated .py.ipynb file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrueckl committed Jun 18, 2020
1 parent b807dd7 commit a8713b9
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 16 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ This is a Visual Studio Code extension that allows you to work with Azure Databr
- Easy configuration via standard VS Code settings

# Relase Notes
**v0.5.2**:
- fix issues with deprecated file extension '.py.ipynb'. Also removed it from configuration settings (but it still works)
- reworked UseCodeCells to now use the code cell tags provided by Databricks instead of adding new ones
- refresh on Connections Tab now also re-activates the current connection to reload the configuration
**v0.5.1**:
- fix issues with unsupported file extensions (e.g. .scala.ipynb)
**v0.5.0**:
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "databricks-vscode",
"displayName": "Databricks VSCode",
"description": "Databricks Extension for VSCode",
"version": "0.5.1",
"version": "0.5.2",
"publisher": "paiqo",
"icon": "resources/databricks_extension.png",
"author": {
Expand Down Expand Up @@ -118,7 +118,6 @@
"type": "string",
"enum": [
".py",
".py.ipynb",
".ipynb"
],
"description": "The file extension used when downloading Python notebooks from Databricks."
Expand Down Expand Up @@ -215,7 +214,6 @@
"type": "string",
"enum": [
".py",
".py.ipynb",
".ipynb"
],
"description": "The file extension used when downloading Python notebooks from Databricks."
Expand Down Expand Up @@ -338,7 +336,6 @@
"type": "string",
"enum": [
".py",
".py.ipynb",
".ipynb"
],
"description": "The file extension used when downloading Python notebooks from Databricks."
Expand Down
1 change: 1 addition & 0 deletions src/DatabricksConnectionTreeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class DatabricksConnectionTreeProvider implements vscode.TreeDataProvider
vscode.window.showInformationMessage('Refreshing Connections ...');
}
ThisExtension.ConnectionManager.loadConnections();
ThisExtension.ConnectionManager.activateConnection(ThisExtension.ActiveConnectionName);
this._onDidChangeTreeData.fire();
}

Expand Down
24 changes: 13 additions & 11 deletions src/databricksApi/workspaces/DatabricksWorkspaceNotebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,28 @@ export class DatabricksWorkspaceNotebook extends DatabricksWorkspaceTreeItem {
}
if (!this.onlinePathExists && this.localPathExists) {
tooltip += "[Offline only]\n";
tooltip += "Local file extension: " + this.localFileExtension + "\n";
}
if (this.onlinePathExists && this.localPathExists) {
tooltip += "[Synced]\n";
tooltip += "Local file extension: " + this.localFileExtension + "\n";
}
return tooltip;
}

// description is show next to the label
get description(): string {
return "[" + this.language + "] - " + this.path;
let ret: string;

ret = "[" + this.language;

if (this._languageFileExtension.isNotebook) {
ret += ", Notebook";
}

ret += "] - " + this.path;

return ret;
}

// used in package.json to filter commands via viewItem == CANSTART
Expand Down Expand Up @@ -167,11 +179,6 @@ export class DatabricksWorkspaceNotebook extends DatabricksWorkspaceTreeItem {
vscode.commands.executeCommand("databricksWorkspace.refresh", false);
}

if (!this._languageFileExtension.isNotebook && ThisExtension.ActiveConnection.useCodeCells) {
ThisExtension.log("Adding Code Cells!");
Helper.addCodeCells(localPath);
}

return localPath;
}
catch (error) {
Expand All @@ -181,11 +188,6 @@ export class DatabricksWorkspaceNotebook extends DatabricksWorkspaceTreeItem {

async upload(): Promise<void> {
try {
if (!this._languageFileExtension.isNotebook && ThisExtension.ActiveConnection.useCodeCells) {
// 1. copy to temporary file
// 2. replace on temporary file using Helper.removeCodeCells(tempFilePath)
// 3. upload temp file
}
let response = DatabricksApiService.uploadWorkspaceItem(this.localFilePath, this.path, this.language, true, this.exportFormat);
vscode.window.showInformationMessage(`Upload of item ${this.path}) finished!`);

Expand Down
7 changes: 6 additions & 1 deletion src/databricksApi/workspaces/LanguageFileExtensionMapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export class LanguageFileExtensionMapper {
case ".py":
ret._language = "PYTHON";
break;
case ".py.ipynb":
case ".ipynb":
ret._language = "PYTHON";
ret._isNotebook = true;
Expand All @@ -107,7 +108,11 @@ export class LanguageFileExtensionMapper {
}

static extensionFromFileName(fileName: string): string {
let tokens = fileName.split('.'); // e.g. '.py.ipynb'
if (fileName.endsWith(".py.ipynb")) {
return ".py.ipynb";
}

let tokens = fileName.split('.'); // e.g. '.ipynb' or '.scala'

return "." + tokens.slice(-1)[0];
}
Expand Down

0 comments on commit a8713b9

Please sign in to comment.