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

Get variable info with background thread #15495

Merged
merged 7 commits into from
Apr 5, 2024
Merged

Conversation

amunger
Copy link
Contributor

@amunger amunger commented Apr 4, 2024

Fixes #15485

5b84fba might be going against the intention of code dependency restrictions, but I seem to need to have a dependency from kernels -> standalone Api,

codeWithReturnStatement: string[],
token: CancellationToken
): Promise<T | undefined> {
return execCodeInBackgroundThread(kernel, codeWithReturnStatement, token);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just noticed this PR, and wanted to provide some quick feedback,
We try to avoid injections where possible, as this slows the extension startup.
In this case you can just keep the class, but remove teh `@injectable decorator
& construct the class when you need it, or just pass it from the calling code
Or remove the class entirely and just use the function, I'm assuming you need the class for mocking/testing purposes
Else having this class is not necessary, as it just wraps a function

For instance today we don't use this class in other places, but use the function directly.
Personally prefer to remove this class and keep the function, else there are two ways of doing the same thing

@rebornix /cc thoughts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I need it to work around import zone restrictions - the function is in standalone (which doesn't seem right to me, but it depends on the API code which is also in that zone), and the caller is in kernel. Neither of those zones can depend on the other.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah yes, then please feel free to move the function out of standalone.
Or leave this as is and I'll fix that later,

Copy link
Member

Choose a reason for hiding this comment

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

+1 for avoiding injectable if possible. This is a static helper function that can be optimized by bundlers, making it an injectable function doesn't seem to give us any benefit at this moment.

Reading the dependencies of execCodeInBackgroundThread, it seems we can move it into kernel component. src\kernels\execution\helpers.ts might be a good place.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can do that, and you can keep this pr as is . Or feel free to make the change.
I'm fine with either

Copy link
Member

Choose a reason for hiding this comment

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

I missed that const api = createKernelApiForExtension(JVSC_EXTENSION_ID, kernel); which depends on NotebookKernelExecution#onDidReceiveDisplayUpdate. It needs some code movement to make it happen. Like @DonJayamanne suggested, probably we leave it to him for the refactoring.

@amunger amunger marked this pull request as ready for review April 5, 2024 16:43
@amunger amunger merged commit b9fa243 into main Apr 5, 2024
28 checks passed
@amunger amunger deleted the aamunger/retreiveVariables branch April 5, 2024 18:12
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.

use background thread on kernel to gather variable information
4 participants