Skip to content

Commit

Permalink
Merge pull request #9 from allen-li1231/dev-kernels
Browse files Browse the repository at this point in the history
Feature: Interpreter Status and Restart Button on Cell Status Bar
  • Loading branch information
allen-li1231 authored Mar 27, 2024
2 parents bbe3f11 + 35dcd18 commit 9033f73
Show file tree
Hide file tree
Showing 9 changed files with 365 additions and 92 deletions.
48 changes: 34 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "zeppelin-vscode",
"displayName": "Zeppelin Notebook",
"description": "Apache Zeppelin Notebook Extension for VS Code",
"version": "0.2.4",
"version": "0.2.5",
"publisher": "AllenLi1231",
"author": {
"name": "Allen Li"
Expand Down Expand Up @@ -39,30 +39,36 @@
"activationEvents": [
"onLanguage:alluxio",
"onLanguage:beam",
"onLanguage:bigquery",
"onLanguage:cypher",
"onLanguage:sql-bigquery",
"onLanguage:cassandra",
"onLanguage:elasticsearch",
"onLanguage:flink",
"onLanguage:es",
"onLanguage:flink-sql",
"onLanguage:geode",
"onLanguage:groovy",
"onLanguage:gsp",
"onLanguage:hazelcastjet",
"onLanguage:hbase",
"onLanguage:hive",
"onLanguage:hive-sql",
"onLanguage:hql",
"onLanguage:ignite",
"onLanguage:influxdb",
"onLanguage:java",
"onLanguage:javascript",
"onLanguage:kotlin",
"onLanguage:kylin",
"onLanguage:ksql",
"onLanguage:hahout",
"onLanguage:markdown",
"onLanguage:neo4j",
"onLanguage:pig",
"onLanguage:plaintext",
"onLanguage:python",
"onLanguage:r",
"onLanguage:sap",
"onLanguage:scala",
"onLanguage:scalding",
"onLanguage:scio",
"onLanguage:shell",
"onLanguage:shellscript",
"onLanguage:sql",
"onLanguage:spark",
"onLanguage:sparql",
Expand Down Expand Up @@ -106,13 +112,13 @@
"zeppelin.autosave.throttleTime": {
"order": 2,
"type": "number",
"default": 1,
"default": 3,
"description": "Set paragraph update delay time (in seconds). Avoid too fast changes of cells causing response pressure on Zeppelin server."
},
"zeppelin.autosave.poolingInterval": {
"order": 3,
"type": "number",
"default": 1,
"default": 3,
"description": "Set minimum save interval (in seconds) to Zeppelin server."
},
"zeppelin.execution.concurrency": {
Expand All @@ -135,8 +141,14 @@
"default": 1,
"description": "Set minimum interval (in seconds) to track execution."
},
"zeppelin.proxy.host": {
"zeppelin.interpreter.trackInterval": {
"order": 6,
"type": "number",
"default": 5,
"description": "Set minimum interval (in seconds) to track interpreter status."
},
"zeppelin.proxy.host": {
"order": 7,
"type": [
"string"
],
Expand All @@ -145,31 +157,31 @@
"description": "Set proxy host for connection with Zeppelin server."
},
"zeppelin.proxy.port": {
"order": 7,
"order": 8,
"type": [
"integer"
],
"default": null,
"description": "Set proxy port for connection with Zeppelin server."
},
"zeppelin.proxy.credential.username": {
"order": 8,
"order": 9,
"type": [
"string"
],
"default": null,
"description": "Specifies proxy authentication for connection with Zeppelin server."
},
"zeppelin.proxy.credential.password": {
"order": 9,
"order": 10,
"type": [
"string"
],
"default": null,
"description": "Specifies proxy authentication for connection with Zeppelin server."
},
"zeppelin.proxy.credential.protocol": {
"order": 10,
"order": 11,
"type": [
"string"
],
Expand All @@ -191,6 +203,10 @@
{
"command": "zeppelin-vscode.setZeppelinCredential",
"title": "Zeppelin: Set Zeppelin Credential (username and password)"
},
{
"command": "zeppelin-vscode.restartInterpreter",
"title": "Zeppelin: restart a interpreter"
}
],
"menus": {
Expand All @@ -204,6 +220,10 @@
},
{
"command": "zeppelin-vscode.setZeppelinCredential"
},
{
"command": "zeppelin-vscode.restartInterpreter",
"when": "resourceExtname == .zpln || resourceExtname == .ipynb"
}
]
}
Expand Down
64 changes: 41 additions & 23 deletions src/common/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ class BasicService {
`You do not have permission to access '${url}'`
);
}
else if (error.response?.status !== 403) {
else if ((error.response?.status === 404)
&& error.request.path.startsWith('/api/interpreter/setting')) {
logDebug(`interpreter '${error.request.path.slice(25)}' ignored`);
}
else if (error.response?.status !== 403
&& error.response.data.exception !== 'UnavailableSecurityManagerException') {
// simplify credential error
window.showErrorMessage(`${error.message}:
${!!error.response.data.message
Expand Down Expand Up @@ -139,7 +144,7 @@ class BasicService {
}


export class NotebookService extends BasicService{
export class NotebookService extends BasicService {

constructor(
baseUrl: string,
Expand All @@ -164,7 +169,7 @@ export class NotebookService extends BasicService{

deleteNote(noteId: string) {
return this.session.delete(
`/api/notebook/${noteId}`
`/api/notebook/${encodeURIComponent(noteId)}`
);
}

Expand All @@ -177,51 +182,51 @@ export class NotebookService extends BasicService{

cloneNote(noteId: string, newNoteName: string) {
return this.session.post(
`/api/notebook/${noteId}`,
`/api/notebook/${encodeURIComponent(noteId)}`,
{ name: newNoteName }
);
}

exportNote(noteId: string, newNoteName: string) {
return this.session.post(
`/api/notebook/${noteId}`,
`/api/notebook/${encodeURIComponent(noteId)}`,
{ name: newNoteName }
);
}

getAllStatus(noteId: string) {
return this.session.get(
`/api/notebook/job/${noteId}`
`/api/notebook/job/${encodeURIComponent(noteId)}`
);
}

getInfo(noteId: string) {
return this.session.get(
'/api/notebook/' + noteId
`/api/notebook/${encodeURIComponent(noteId)}`
);
}

runAll(noteId: string) {
return this.session.post(
`/api/notebook/job/${noteId}`
`/api/notebook/job/${encodeURIComponent(noteId)}`
);
}

stopAll(noteId: string) {
return this.session.delete(
`/api/notebook/job/${noteId}`
`/api/notebook/job/${encodeURIComponent(noteId)}`
);
}

clearAllResult(noteId: string) {
return this.session.put(
`/api/notebook/${noteId}/clear`
`/api/notebook/${encodeURIComponent(noteId)}/clear`
);
}

addCron(noteId: string, cron: string, releaseResource: boolean = false) {
return this.session.post(
`/api/notebook/cron/${noteId}`,
`/api/notebook/cron/${encodeURIComponent(noteId)}`,
{ cron: cron, releaseResource: releaseResource}
);
}
Expand All @@ -239,7 +244,7 @@ export class NotebookService extends BasicService{

getPermission(noteId: string) {
return this.session.get(
`/api/notebook/${noteId}/permissions`
`/api/notebook/${encodeURIComponent(noteId)}/permissions`
);
}

Expand All @@ -251,7 +256,7 @@ export class NotebookService extends BasicService{
writers: string[]
) {
return this.session.post(
`/api/notebook/cron/${noteId}`,
`/api/notebook/cron/${encodeURIComponent(noteId)}`,
{
readers: readers,
owners: owners,
Expand All @@ -276,20 +281,20 @@ export class NotebookService extends BasicService{
data.config = config;
}
return this.session.post(
`/api/notebook/${noteId}/paragraph`,
`/api/notebook/${encodeURIComponent(noteId)}/paragraph`,
data
);
}

getParagraphInfo(noteId: string, paragraphId: string) {
return this.session.get(
`/api/notebook/${noteId}/paragraph/${paragraphId}`
`/api/notebook/${encodeURIComponent(noteId)}/paragraph/${encodeURIComponent(paragraphId)}`
);
}

getParagraphStatus(noteId: string, paragraphId: string) {
return this.session.get(
`/api/notebook/job/${noteId}/${paragraphId}`
`/api/notebook/job/${encodeURIComponent(noteId)}/${encodeURIComponent(paragraphId)}`
);
}

Expand All @@ -308,38 +313,38 @@ export class NotebookService extends BasicService{
}

return this.session.put(
`/api/notebook/${noteId}/paragraph/${paragraphId}`,
`/api/notebook/${encodeURIComponent(noteId)}/paragraph/${encodeURIComponent(paragraphId)}`,
data
);
}

updateParagraphConfig(noteId: string, paragraphId: string, config: ParagraphConfig) {
return this.session.put(
`/api/notebook/${noteId}/paragraph/${paragraphId}/config`,
`/api/notebook/${encodeURIComponent(noteId)}/paragraph/${encodeURIComponent(paragraphId)}/config`,
config
);
}

moveParagraphToIndex(noteId: string, paragraphId: string, index: number) {
return this.session.post(
`/api/notebook/${noteId}/paragraph/${paragraphId}/move/` + index.toString()
`/api/notebook/${encodeURIComponent(noteId)}/paragraph/${encodeURIComponent(paragraphId)}/move/` + index.toString()
);
}

deleteParagraph(noteId: string, paragraphId: string) {
return this.session.delete(
`/api/notebook/${noteId}/paragraph/${paragraphId}`
`/api/notebook/${encodeURIComponent(noteId)}/paragraph/${encodeURIComponent(paragraphId)}`
);
}

async runParagraph(noteId: string, paragraphId: string, sync: boolean = true, option?: any) {
// let t = await this.listNotes();
let url;
if (sync) {
url = `/api/notebook/run/${noteId}/${paragraphId}`;
url = `/api/notebook/run/${encodeURIComponent(noteId)}/${encodeURIComponent(paragraphId)}`;
}
else {
url = `/api/notebook/job/${noteId}/${paragraphId}`;
url = `/api/notebook/job/${encodeURIComponent(noteId)}/${encodeURIComponent(paragraphId)}`;
}

let res;
Expand All @@ -362,11 +367,24 @@ export class NotebookService extends BasicService{

stopParagraph(noteId: string, paragraphId: string) {
return this.session.delete(
`/api/notebook/job/${noteId}/${paragraphId}`
`/api/notebook/job/${encodeURIComponent(noteId)}/${encodeURIComponent(paragraphId)}`
);
}

getInterpreterSetting(interpreterId: string) {
return this.session.get(
`/api/interpreter/setting/${encodeURIComponent(interpreterId)}`
);
}

restartInterpreter(interpreterId: string) {
return this.session.put(
`/api/interpreter/setting/restart/${encodeURIComponent(interpreterId)}`
);
}
}


interface CreateParagraphData {
text: string,
title?: string,
Expand Down
12 changes: 6 additions & 6 deletions src/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ export const EXTENSION_NAME = 'zeppelin-notebook';
export const NOTEBOOK_SUFFIX = '.zpln';

export const SUPPORTEDLANGUAGE = [
'alluxio', 'beam', 'bigquery', 'cassandra', 'elasticsearch', 'flink',
'geode', 'groovy', 'hazelcastjet', 'hbase', 'hive', 'ignite', 'ignite',
'influxdb', 'java', 'kotlin', 'ksql', 'kylin', 'mahout', 'markdown',
'mongodb', 'neo4j', 'pig', 'python', 'r', 'sap', 'scala', 'scalding',
'scio', 'shell', 'spark', 'sparql', 'sql'];
'alluxio', 'beam', 'cypher', 'sql-bigquery', 'cassandra', 'es', 'flink-sql',
'geode', 'groovy', 'gsp', 'hazelcastjet', 'hbase', 'hive-sql', 'hql', 'ignite',
'influxdb', 'java', 'javascript', 'kotlin', 'ksql', 'kylin', 'mahout', 'markdown',
'pig', 'plaintext', 'python', 'r', 'sap', 'scala', 'scalding',
'scio', 'shellscript', 'spark', 'sql'];

export const mapLanguageKind = new Map<string, number>();
for (let lang of SUPPORTEDLANGUAGE) {
mapLanguageKind.set(lang, 2);
}
mapLanguageKind.set('markdown', 1);

export const reInterpreter = RegExp(/([\s\n]*%[\w\d\._]+)\s*\n+/);
export const reInterpreter = RegExp(/[\s\n]*%([\w\d\._]+)\s*\n+/);
export const reURL = RegExp(/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.?[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)?/gi);
export const reCookies = RegExp(/^(JSESSIONID=((?!deleteMe).)*?);/s);
export const reBase64= /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
Expand Down
Loading

0 comments on commit 9033f73

Please sign in to comment.