Skip to content
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

Merged
merged 21 commits into from Sep 11, 2020
Merged

Conversation

DavidKutu
Copy link

@DavidKutu DavidKutu commented Aug 29, 2020

For #13306

Not final, but would like your review.

  • Pull request represents a single change (i.e. not fixing disparate/unrelated things in a single PR).
  • Title summarizes what is changing.
  • Has a news entry file (remember to thank yourself!).
  • Appropriate comments and documentation strings in the code.
  • Has sufficient logging.
  • Has telemetry for enhancements.
  • Unit tests & system/integration tests are added/updated.
  • Test plan is updated as appropriate.
  • package-lock.json has been regenerated by running npm install (if dependencies have changed).
  • The wiki is updated with any design decisions/details.

@codecov-commenter
Copy link

codecov-commenter commented Aug 29, 2020

Codecov Report

Merging #13672 into main will decrease coverage by 0.02%.
The diff coverage is 25.00%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
...ient/datascience/interactive-ipynb/nativeEditor.ts 7.78% <0.00%> (-0.08%) ⬇️
...atascience/notebookStorage/nativeEditorProvider.ts 17.26% <ø> (ø)
src/client/datascience/types.ts 100.00% <100.00%> (ø)
src/client/datascience/crossProcessLock.ts 79.41% <0.00%> (-11.77%) ⬇️
src/client/common/utils/platform.ts 60.00% <0.00%> (-8.00%) ⬇️
src/client/linters/pydocstyle.ts 86.66% <0.00%> (-2.23%) ⬇️
src/client/datascience/debugLocationTracker.ts 76.56% <0.00%> (-1.57%) ⬇️
src/client/common/process/proc.ts 14.49% <0.00%> (-0.73%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed3f29f...2833cb4. Read the comment docs.


export const IJupyterExecutionLoggerRegistration = Symbol('IJupyterExecutionLoggerRegistration');

export interface IJupyterExecutionLoggerRegistration {

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 = {
Copy link

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?

Copy link

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');
Copy link

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onExecute<IExecutionInfo>
onKernelEvent<string>

?

Copy link

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>

Copy link
Author

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

Copy link
Author

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

Copy link

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'
Copy link
Author

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

Copy link
Member

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.

Copy link
Author

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

id: string;
source: string;
executionCount: number;
executionEventId: string;

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;

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

Copy link

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.

@@ -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,

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

Copy link
Author

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.

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);

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
@microsoft-github-updates microsoft-github-updates bot changed the base branch from master to main September 3, 2020 21:06
@@ -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>;

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.

Copy link
Author

@DavidKutu DavidKutu Sep 4, 2020

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 {

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.

Copy link
Author

@DavidKutu DavidKutu Sep 4, 2020

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?

}
},
onKernelExecute: notebookExtensibility.onKernelPostExecute,
onKernelRestart: notebookExtensibility.onKernelRestart

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

Copy link

@DonJayamanne DonJayamanne left a 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

@DavidKutu DavidKutu marked this pull request as ready for review September 10, 2020 23:46
@sonarcloud
Copy link

sonarcloud bot commented Sep 11, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@rchiodo rchiodo merged commit c9f2d9c into main Sep 11, 2020
@rchiodo rchiodo deleted the david/gatherExtensibilityPoint branch September 11, 2020 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants