-
Notifications
You must be signed in to change notification settings - Fork 293
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
Conversation
@@ -137,6 +138,7 @@ export class CodeWatcher implements ICodeWatcher { | |||
} | |||
@captureTelemetry(Telemetry.RunAllCells) | |||
public async runAllCells() { | |||
const iw = await this.getActiveInteractiveWindow(); |
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.
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) => { |
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 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() { |
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 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.
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.
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.
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.
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 Report
@@ 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
|
Fixes #8022
Fixes #8615