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

Allow queueing of multiple cells in IW #8642

Merged
merged 5 commits into from
Jan 5, 2022
Merged

Allow queueing of multiple cells in IW #8642

merged 5 commits into from
Jan 5, 2022

Conversation

rchiodo
Copy link
Contributor

@rchiodo rchiodo commented Jan 5, 2022

Fixes #8022
Fixes #8615

@rchiodo rchiodo requested a review from a team as a code owner January 5, 2022 18:54
@@ -137,6 +138,7 @@ export class CodeWatcher implements ICodeWatcher {
}
@captureTelemetry(Telemetry.RunAllCells)
public async runAllCells() {
const iw = await this.getActiveInteractiveWindow();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved the IW fetch to outside of addCode so that multiple calls to addcode wouldn't block on it.

editor?: TextEditor,
debug?: boolean
): Promise<boolean> {
this.addCodePromise = this.addCodePromise.then((_previousResult) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The promise chain wasn't necessary here anymore because the IW handles queueing itself now.

@@ -266,3 +266,36 @@ export function testOnlyMethod() {
return descriptor;
};
}

// Mark a method that returns a promise to chain it
export function chainable() {
Copy link
Member

Choose a reason for hiding this comment

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

I know that you had looked at this before, so I don't want to rehash a debate on this. But I'm not keen on something that changes the way the function works this much being "hidden" in a decorator. I like decorators for stuff like logging or error handling. Something like this feels like a big functionality difference which I wouldn't want changed by a decorator. They can also be a pain to debug at times.

I guess if this PR looks good and the chaining cases are all handed then I won't hold things up. But if we run into issue in the future with this decorator hiding real issues or making debugging hard I'd argue against it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Debugging it isn't hard, you just set breakpoints in the decorator. The reason for it is so we don't have duplicate code for chaining a promise. Not sure how else to implement common code for promise chaining though. A wrapper method instead?

Something like:

public doStuffWithPromise() {
   return chained(async () => {
       await doingstuff();
   })
}

Does that grok better? It's essentially the same thing as the decorator but more explicit.

Copy link
Member

Choose a reason for hiding this comment

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

Probably just anti decorator bias on my part. I read decorators like this:

@thisStuffDoesn'tReallyMatter
@youCanReadTheFunctionJustFineWithoutThis
@probablyJustLoggingOrSomethingLikeThat
function doStuff() {}

This feels more like:

@thisIsReallyKindaABigChangeToHowThisFunctionWorks
function doStuff() {}

But there is no reason that a decorator can't do something like you are doing here. So I vote we go for it. I was thinking it might cause issues with the case where there is a python error in the chain (where we return a false and show a message) but it looks like you added that in a later commit.

@codecov-commenter
Copy link

codecov-commenter commented Jan 5, 2022

Codecov Report

Merging #8642 (fb00a6e) into main (70cb636) will decrease coverage by 0%.
The diff coverage is 74%.

❗ Current head fb00a6e differs from pull request most recent head 04665fb. Consider uploading reports for the commit 04665fb to get more accurate results

@@          Coverage Diff          @@
##            main   #8642   +/-   ##
=====================================
- Coverage     71%     71%   -1%     
=====================================
  Files        381     382    +1     
  Lines      24484   24513   +29     
  Branches    3755    3762    +7     
=====================================
+ Hits       17508   17515    +7     
- Misses      5465    5479   +14     
- Partials    1511    1519    +8     
Impacted Files Coverage Δ
src/client/datascience/types.ts 100% <ø> (ø)
...atascience/interactive-window/interactiveWindow.ts 64% <69%> (-3%) ⬇️
...ient/datascience/editor-integration/codewatcher.ts 69% <76%> (-1%) ⬇️
src/client/common/utils/decorators.ts 80% <81%> (+<1%) ⬆️
...t/datascience/errors/interactiveCellResultError.ts 100% <100%> (ø)
...ience/variablesView/variableViewMessageListener.ts 77% <0%> (-23%) ⬇️
...ent/common/application/webviewViews/webviewView.ts 67% <0%> (-11%) ⬇️
...ience/kernel-launcher/localKernelSpecFinderBase.ts 74% <0%> (-3%) ⬇️
src/client/datascience/raw-kernel/rawSocket.ts 82% <0%> (-2%) ⬇️
... and 3 more

@rchiodo rchiodo merged commit 93c49fb into main Jan 5, 2022
@rchiodo rchiodo deleted the rchiodo/queue_iw branch January 5, 2022 21:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants