Skip to content

Restart for raw sessions + rawSession now owns process lifetime #11230

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

Merged

Conversation

IanMatthewHuff
Copy link
Member

For #10767

  • 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.

@IanMatthewHuff IanMatthewHuff added the no-changelog No news entry required label Apr 17, 2020
public abstract async changeKernel(kernel: IJupyterKernelSpec | LiveKernelModel, timeoutMS: number): Promise<void>;
public abstract async waitForIdle(timeout: number): Promise<void>;

public async shutdown(): Promise<void> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Most of the big chunks of changes in this file are not new changes, but refactors. Previous to this change I had restart and shutdown just implemented in the raw and jupyter session classes. Now they have moved into the base class so that they can share code. So shutdown and restart code was pulled from the jupyter specific class into the base class and changes were made to support that.

@@ -228,6 +330,68 @@ export abstract class BaseJupyterSession implements IJupyterSession {
}
}

// Sub classes need to implement their own restarting specific code
protected abstract startRestartSession(): void;
Copy link
Member Author

Choose a reason for hiding this comment

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

The restart code above is common and unchanged from previous jupyter code, but there are specific start and restart functions for the jupyter / raw subclasses.

protected async shutdownSession(
session: ISession | undefined,
statusHandler: Slot<ISession, Kernel.Status> | undefined
): Promise<void> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Previous JupyterSession code for shutting down a session

Choose a reason for hiding this comment

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

Thanks for comment, was trying to figure out what waas old and new.
This is one of those cases where I feel splitting PR into two helps, one for refactoring and other for new changes. This way the refactoring code requires less review, as we're merely moving stuff around.
Also makes for smaller PRs..

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I did that with the notebook provider refactor and it was really helpful. But I didn't here, will try to make sure that I do that in the future as much as I can. 👍 👍 For smaller PRs as well.

@@ -28,9 +28,9 @@ export interface IKernelConnection {

export interface IKernelProcess extends IDisposable {
process: ChildProcess | undefined;
readonly connection: Readonly<IKernelConnection> | undefined;
readonly connection: Readonly<IKernelConnection>;
Copy link
Member Author

Choose a reason for hiding this comment

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

I changed the code in a previous checkin to pass the connection and spec in directly to kernelProcess constructor so they are guaranteed, but didn't pull the undefined off of the type.

@@ -24,55 +26,33 @@ It's responsible for translating our IJupyterSession interface into the
jupyterlabs interface as well as starting up and connecting to a raw session
*/
export class RawJupyterSession extends BaseJupyterSession {
private currentKernelProcess: IKernelProcess | undefined;
Copy link
Member Author

Choose a reason for hiding this comment

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

I really didn't like keeping the process off here separate from the session. Was ok with one session, but when you added in a restart session it was getting ugly to juggle. So I made a change to push the process into the lower level RawSession. This helps with both not having to track it here when I restart session or change kernels, but now the shared shutdownSession code between the jupyter and raw session can both just call shutdown and the RawSession will dispose the process at that point.

@@ -43,13 +47,21 @@ suite('Data Science - RawJupyterSession', () => {
// Set up a fake kernel process for the launcher to return
processExitEvent = new EventEmitter<number | null>();
kernelProcess = createTypeMoq<IKernelProcess>('kernel process');
kernelProcess.setup((kp) => kp.kernelSpec).returns(() => 'testspec' as any);
kernelProcess
Copy link
Member Author

Choose a reason for hiding this comment

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

Since I have an "in" check to see if my spec is not a live model I needed this as an object.

@IanMatthewHuff
Copy link
Member Author

@rchiodo @DonJayamanne @DavidKutu . Would someone mind taking a gander at this PR? Would like to make changes before our dogfooding if I can.

Copy link

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

🕐

Copy link

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

:shipit:

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

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

No Coverage information No Coverage information
0.0% 0.0% Duplication

@IanMatthewHuff IanMatthewHuff merged commit acdc910 into microsoft:master Apr 17, 2020
@IanMatthewHuff IanMatthewHuff deleted the dev/ianhu/restartChangeRawKernel branch April 17, 2020 21:08
@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
no-changelog No news entry required
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants