-
Notifications
You must be signed in to change notification settings - Fork 141
feat(frontend): use notebook name as default pipeline name and handle TaskMissingError #524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
70e866f
20bdb69
5bffb89
89e56fd
4e0d523
bf5e734
d95a5f8
49f230a
8cbdb0f
7569c83
feb29d5
4e4d466
7dd496e
d0ce37a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,8 @@ import * as React from 'react'; | |
| import { NotebookPanel } from '@jupyterlab/notebook'; | ||
| import { Kernel } from '@jupyterlab/services'; | ||
| import NotebookUtils from './NotebookUtils'; | ||
| // @ts-expect-error This module is not typed | ||
| import SanitizedHTML from 'react-sanitized-html'; | ||
| import { isError, IError, IOutput } from '@jupyterlab/nbformat'; | ||
| import { Notification } from '@jupyterlab/apputils'; | ||
|
|
||
|
|
@@ -30,11 +32,11 @@ export const globalUnhandledRejection = async (event: any) => { | |
| // isolate the segments | ||
| const stackLines = errorStack.split('\n'); | ||
| // create alert string | ||
| const alert_string = 'Unhandled Error' | ||
| const alert_string = 'Unhandled Error'; | ||
| // call the toast pop up | ||
| if (errorStack.includes('lab/extensions/')){ | ||
| if (errorStack.includes('lab/extensions/')) { | ||
| // if the error is caused by a jupyterlab extension, try to isolate the extension name | ||
| const extensionName = getExtensionName(stackLines) | ||
| const extensionName = getExtensionName(stackLines); | ||
| Notification.error(`An unhandled error has been thrown.`, { | ||
| actions: [ | ||
| { label: 'Details', callback: () => NotebookUtils.showMessage(alert_string, | ||
|
|
@@ -46,20 +48,28 @@ export const globalUnhandledRejection = async (event: any) => { | |
| autoClose: 3000 | ||
| }); | ||
| } else { | ||
| const extensionName = getExtensionName(stackLines); | ||
| Notification.error(`An unhandled error has been thrown.`, { | ||
| actions: [ | ||
| { label: 'Details', callback: () => NotebookUtils.showMessage(alert_string, | ||
| ["Please see console for more details."]) } | ||
| { | ||
| label: 'Details', | ||
| callback: () => | ||
| NotebookUtils.showMessage(alert_string, [ | ||
| 'An unhandled error was thrown from:', | ||
| extensionName, | ||
| 'Please see console for more details.' | ||
| ]) | ||
| } | ||
| ], | ||
| autoClose: 3000 | ||
| }); | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| function getExtensionName(stackLines: Array<string>){ | ||
| const urlSplit = stackLines.slice(1,2).toString(); | ||
| const extensionSplit = urlSplit.split('@').slice(1,2).toString(); | ||
| function getExtensionName(stackLines: Array<string>) { | ||
| const urlSplit = stackLines.slice(1, 2).toString(); | ||
| const extensionSplit = urlSplit.split('@').slice(1, 2).toString(); | ||
| const extensionParts = extensionSplit.split('/'); | ||
| extensionParts.pop(); | ||
| const extensionName = extensionParts.join('/'); | ||
|
|
@@ -82,7 +92,7 @@ export enum RPC_CALL_STATUS { | |
| NotFound = 3, | ||
| InternalError = 4, | ||
| ServiceUnavailable = 5, | ||
| UnhandledError = 6, | ||
| UnhandledError = 6 | ||
| } | ||
|
|
||
| const getRpcCodeName = (code: number) => { | ||
|
|
@@ -104,6 +114,8 @@ const getRpcCodeName = (code: number) => { | |
| } | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| export const rokErrorTooltip = (rokError: IRPCError) => { | ||
| return ( | ||
| <React.Fragment> | ||
|
|
@@ -132,12 +144,12 @@ export const executeRpc = async ( | |
| env: Kernel.IKernelConnection | NotebookPanel, | ||
| func: string, | ||
| kwargs: any = {}, | ||
| ctx: { nb_path: string | null } = { nb_path: null }, | ||
| ctx: { nb_path: string | null } = { nb_path: null } | ||
| ) => { | ||
| const cmd: string = | ||
| 'from kale.rpc.run import run as __kale_rpc_run\n' + | ||
| `__kale_rpc_result = __kale_rpc_run("${func}", '${serialize( | ||
| kwargs, | ||
| kwargs | ||
| )}', '${serialize(ctx)}')`; | ||
| console.log('Executing command: ' + cmd); | ||
| const expressions = { result: '__kale_rpc_result' }; | ||
|
|
@@ -148,7 +160,7 @@ export const executeRpc = async ( | |
| ? await NotebookUtils.sendKernelRequestFromNotebook( | ||
| env, | ||
| cmd, | ||
| expressions, | ||
| expressions | ||
| ) | ||
| : await NotebookUtils.sendKernelRequest(env, cmd, expressions); | ||
| } catch (e) { | ||
|
|
@@ -158,7 +170,7 @@ export const executeRpc = async ( | |
| const error = { | ||
| rpc: `${func}`, | ||
| status: `${(e as IError).ename}: ${(e as IError).evalue}`, | ||
| output: (e as IError).traceback, | ||
| output: (e as IError).traceback | ||
| }; | ||
| throw new KernelError(error); | ||
| } | ||
|
|
@@ -174,7 +186,7 @@ export const executeRpc = async ( | |
| const error = { | ||
| rpc: `${func}`, | ||
| status: output.result.status, | ||
| output: output, | ||
| output: output | ||
| }; | ||
| throw new KernelError(error); | ||
| } | ||
|
|
@@ -193,7 +205,7 @@ export const executeRpc = async ( | |
| rpc: `${func}`, | ||
| err_message: 'Failed to parse response as JSON', | ||
| error: error, | ||
| jsonData: json_data, | ||
| jsonData: json_data | ||
| }; | ||
| throw new JSONParseError(jsonError); | ||
| } | ||
|
|
@@ -205,12 +217,11 @@ export const executeRpc = async ( | |
| err_message: parsedResult.err_message, | ||
| err_details: parsedResult.err_details, | ||
| err_cls: parsedResult.err_cls, | ||
| trans_id: parsedResult.trans_id, | ||
| trans_id: parsedResult.trans_id | ||
| }; | ||
| throw new RPCError(error); | ||
| } | ||
| return parsedResult.result; | ||
|
|
||
| }; | ||
|
|
||
| export const showError = async ( | ||
|
|
@@ -221,11 +232,11 @@ export const showError = async ( | |
| refresh: boolean = true, | ||
| method: string | null = null, | ||
| code: number | null = null, | ||
| trans_id: number | null = null, | ||
| trans_id: number | null = null | ||
| ): Promise<void> => { | ||
| const msg: string[] = [ | ||
| `Browser: ${navigator ? navigator.userAgent : 'other'}`, | ||
| `Type: ${type}`, | ||
| `Type: ${type}` | ||
| ]; | ||
| if (method) { | ||
| msg.push(`Method: ${method}()`); | ||
|
|
@@ -247,8 +258,9 @@ export const showError = async ( | |
|
|
||
| export const showRpcError = async ( | ||
| error: IRPCError, | ||
| refresh: boolean = false, | ||
| refresh: boolean = false | ||
| ): Promise<void> => { | ||
|
|
||
| await showError( | ||
| 'An RPC Error has occurred', | ||
| 'RPC', | ||
|
|
@@ -257,7 +269,7 @@ export const showRpcError = async ( | |
| refresh, | ||
| error.rpc, | ||
| error.code, | ||
| error.trans_id, | ||
| error.trans_id | ||
| ); | ||
| }; | ||
|
|
||
|
|
@@ -267,7 +279,7 @@ export const _legacy_executeRpc = async ( | |
| kernel: Kernel.IKernelConnection, | ||
| func: string, | ||
| args: any = {}, | ||
| nb_path: string | null = null, | ||
| nb_path: string | null = null | ||
| ) => { | ||
| if (!nb_path && notebook) { | ||
| nb_path = notebook.context.path; | ||
|
|
@@ -300,15 +312,15 @@ export const _legacy_executeRpcAndShowRPCError = async ( | |
| kernel: Kernel.IKernelConnection, | ||
| func: string, | ||
| args: any = {}, | ||
| nb_path: string | null = null, | ||
| nb_path: string | null = null | ||
| ) => { | ||
| try { | ||
| const result = await _legacy_executeRpc( | ||
| notebook, | ||
| kernel, | ||
| func, | ||
| args, | ||
| nb_path, | ||
| nb_path | ||
| ); | ||
| return result; | ||
| } catch (error) { | ||
|
|
@@ -321,7 +333,10 @@ export const _legacy_executeRpcAndShowRPCError = async ( | |
| }; | ||
|
|
||
| export abstract class BaseError extends Error { | ||
| constructor(message: string, public error: any) { | ||
| constructor( | ||
| message: string, | ||
| public error: any | ||
| ) { | ||
| super(message); | ||
| this.name = this.constructor.name; | ||
| this.stack = new Error(message).stack; | ||
|
|
@@ -345,7 +360,7 @@ export class KernelError extends BaseError { | |
| this.error.status, | ||
| JSON.stringify(this.error.output, null, 3), | ||
| refresh, | ||
| this.error.rpc, | ||
| this.error.rpc | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -363,7 +378,7 @@ export class JSONParseError extends BaseError { | |
| this.error.error.message, | ||
| this.error.json_data, | ||
| refresh, | ||
| this.error.rpc, | ||
| this.error.rpc | ||
| ); | ||
| } | ||
| } | ||
|
|
@@ -378,3 +393,4 @@ export class RPCError extends BaseError { | |
| await showRpcError(this.error, refresh); | ||
| } | ||
| } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this functionality can be simplified. There is some logic already for handling the |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes here on (new) lines
24-62and124-254and268-377appear to be unrelated to the main changes of the PR. I believe the preferred method of AI-assisted coding is to accept only the bare minimum necessary changes related directly to solving the issue. The LLMs often produce extra "fixes", which can cause the overall number of changes to rapidly increase. @ederign do you feel we should keep changes like these, that are valid but not directly related to the issue?