-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Draft for gather extensibility point #13672
Conversation
Codecov Report
@@ Coverage Diff @@
## main #13672 +/- ##
==========================================
- Coverage 59.86% 59.84% -0.03%
==========================================
Files 693 693
Lines 38351 38355 +4
Branches 5516 5516
==========================================
- Hits 22960 22952 -8
- Misses 14211 14220 +9
- Partials 1180 1183 +3
Continue to review full report at Codecov.
|
src/client/datascience/types.ts
Outdated
|
||
export const IJupyterExecutionLoggerRegistration = Symbol('IJupyterExecutionLoggerRegistration'); | ||
|
||
export interface IJupyterExecutionLoggerRegistration { |
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.
Based on our last discussion, exposing an event from the extension would be better.
This way you won't need to inject logger classes, manage it and the like.
Just fire events & the API is much simpler and smaller (both ends need to expose other types).
Aldo, we discussed that it would be better to not expose ICell
outside the extension, expose only what you need index of cell, source of cell and anything else required
this._executed.fire(this); | ||
this.executedCode.fire(code); | ||
this.executedCode.fire(cell.document.getText()); | ||
const cellMessage: IPublicCellInfo = { |
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.
IPublicCellInfo sounds strange to me. ICellInfo seems appropriate?
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.
Or maybe ICellExecutionInfo?
@@ -230,6 +245,7 @@ export class NotebookEditor implements INotebookEditor { | |||
this.document.metadata.cellRunnable = false; | |||
this.document.metadata.runnable = false; | |||
await kernel.restart(); | |||
this.kernelChange.fire('kernelRestarted'); |
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.
Two events seems better than the ambiguous 'string' result.
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.
onExecute<IExecutionInfo>
onKernelEvent<string>
?
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.
Or maybe
onKernelExecute<IExecutionInfo>
onKernelEvent<string>
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.
Do you mean 3 events?
- cell executed
- notebook opened
- kernel restarted
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.
Or maybe it can return CellInfo or an enum
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.
Sorry didn't notice the other use of the string param.
3 events sounds better. Overloading the event to be something like 'stuffChanged' doesn't seem very cohesive to me.
source: cell.document.getText(), | ||
executionCount: cell.metadata.executionOrder!, | ||
executionEventId: uuid(), | ||
hasError: cell.metadata.statusMessage! === 'error' |
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.
This is not working right, both executionOrder and statusMessage are always undefined and there is no persistent cell ID
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.
Just wondering, are you specifically trying to keep this trimmed to just what you need? Just wasn't sure why not just pass the statusMessage then check in gather to see if it's 'error' or not.
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.
yeah, I followed Don's comment of sending the whole cell
src/client/datascience/types.ts
Outdated
id: string; | ||
source: string; | ||
executionCount: number; | ||
executionEventId: string; |
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.
Why do we need this? Seems pointless if it is just generated and not stored anywhere
Why not expose the cell as is? After all this is a VSCode object.
return new EventEmitter<ICellExecutionInfo>().event; | ||
} | ||
public get onKernelRestart(): Event<void> { | ||
return new EventEmitter<void>().event; |
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.
Better to create a separate class, as a singleton and excise those events there. We want to try to get rid of the old notebook editor interface
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.
E.g. Notebook extensibility.
Add the events here and the methods in here, this way we have a specific class for such extensibility.
src/client/api.ts
Outdated
@@ -127,7 +137,12 @@ export function buildApi( | |||
const pythonPath = configurationService.getSettings(resource).pythonPath; | |||
// If pythonPath equals an empty string, no interpreter is set. | |||
return { execCommand: pythonPath === '' ? undefined : [pythonPath] }; | |||
} | |||
}, | |||
onNotebookOpened: notebookEditor ? notebookEditor.onNotebookOpened : new EventEmitter<void>().event, |
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.
You can get this from VSCode API, we don't need to expose this event from here, that's one less thing to expose from our end
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.
I can't find it.
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.
Thats how we have it working in the python extension. onDidOpenNotebookDocument
executionEventId: uuid(), | ||
hasError: cell.metadata.statusMessage! === 'error' | ||
}; | ||
this.kernelExecute.fire(cellInfo); |
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.
Why not fire(cell)
As VSCode cell is a VSCode object have you don't need to expose other interfaces from the python extension
and made it a singleton
src/client/api.ts
Outdated
@@ -51,6 +52,9 @@ export interface IExtensionApi { | |||
* An event that is emitted when execution details (for a resource) change. For instance, when interpreter configuration changes. | |||
*/ | |||
readonly onDidChangeExecutionDetails: Event<Uri | undefined>; | |||
readonly onNotebookOpened: Event<void>; |
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.
You can get this from the VS Code API.
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.
where?
Edit: nevermind, I saw your other comment
@@ -99,6 +102,7 @@ export function buildApi( | |||
): IExtensionApi { |
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.
This interface has not been updated.
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.
Do you mean updated to PostExecute?
src/client/api.ts
Outdated
} | ||
}, | ||
onKernelExecute: notebookExtensibility.onKernelPostExecute, | ||
onKernelRestart: notebookExtensibility.onKernelRestart |
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.
Shouldn't these go under dataScience
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.
We need to update the API interface & move the events under the DataScience
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
For #13306
Not final, but would like your review.
package-lock.json
has been regenerated by runningnpm install
(if dependencies have changed).