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

Fix support for IPyWidgets in Interactive Window #4208

Merged
merged 3 commits into from
Dec 10, 2020
Merged

Conversation

DonJayamanne
Copy link
Contributor

For #4203

Copy link
Contributor

@rchiodo rchiodo left a comment

Choose a reason for hiding this comment

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

🌮

@DonJayamanne DonJayamanne requested a review from rchiodo December 10, 2020 23:06
@codecov-io
Copy link

Codecov Report

Merging #4208 (965f6bb) into main (26942ae) will increase coverage by 73%.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           main   #4208      +/-   ##
=======================================
+ Coverage      0     73%     +73%     
=======================================
  Files         0     384     +384     
  Lines         0   25141   +25141     
  Branches      0    3595    +3595     
=======================================
+ Hits          0   18504   +18504     
- Misses        0    5220    +5220     
- Partials      0    1417    +1417     
Impacted Files Coverage Δ
src/client/common/installer/productInstaller.ts 56% <0%> (ø)
src/client/common/application/notebook.ts 86% <0%> (ø)
...ent/datascience/interactive-common/linkProvider.ts 34% <0%> (ø)
...datascience/interactive-common/showPlotListener.ts 71% <0%> (ø)
src/client/common/process/constants.ts 100% <0%> (ø)
src/client/extensionActivation.ts 92% <0%> (ø)
src/client/datascience/kernel-launcher/types.ts 61% <0%> (ø)
src/client/datascience/notebook/helpers/helpers.ts 34% <0%> (ø)
src/client/datascience/export/exportToPython.ts 37% <0%> (ø)
...datascience/notebookStorage/nativeEditorStorage.ts 81% <0%> (ø)
... and 374 more

@DonJayamanne DonJayamanne merged commit f1218f9 into main Dec 10, 2020
@DonJayamanne DonJayamanne deleted the issue4203 branch December 10, 2020 23:23
Copy link
Contributor

@Victor-Savu Victor-Savu left a comment

Choose a reason for hiding this comment

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

Proposing a way to avoid the split between the create and initialize.

@@ -94,6 +92,19 @@ export class CommonMessageCoordinator {
this.getIPyWidgetScriptSource()?.onMessage(message, payload);
}

public async initialize() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this function need to be async? It does not seem to use await anywhere.

const result = new CommonMessageCoordinator(identity, serviceContainer);
await result.initialize();
return result;
public static create(identity: Uri, serviceContainer: IServiceContainer): CommonMessageCoordinator {
Copy link
Contributor

Choose a reason for hiding this comment

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

The purpose of this factory method was to ensure that initialize is called once (and only once) after creation and that the object is not used until the initialization is done. By taking out the call to initialize and making initialize public, we now rely on the user of the class to be diligent and to not:

  • call initialize twice
  • use the object before calling initialize
  • use the object before the call to initialize finishes

@@ -62,7 +62,7 @@ export class WebviewIPyWidgetCoordinator implements IInteractiveWindowListener {
// There should be an instance of the WebviewMessageCoordinator per notebook webview or interactive window. Create
// the message coordinator as soon as we're sure what notebook we're in.
this.notebookIdentity = args.resource;
this.messageCoordinator = await CommonMessageCoordinator.create(this.notebookIdentity, this.serviceContainer);
this.messageCoordinator = CommonMessageCoordinator.create(this.notebookIdentity, this.serviceContainer);
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that the reason for this change was to allow for a specialization of the postEmitter.event of the CommonMessageCoordinator before the initialization takes place.

To avoid making initialize public and relying on end-user cooperation, I would recommend modifying the factory method create to take an optional parameter that allows the caller to inject the postEmitter.

@Victor-Savu
Copy link
Contributor

For convenience, I opened #4273 addressing these comments.

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.

4 participants