-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Run by line partial implementation #11608
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
Conversation
Remove exclusions as they mess up subsequent runs
@@ -406,3 +430,11 @@ export class CellHashProvider implements ICellHashProvider, INotebookExecutionLo | |||
return traceFrame; | |||
} | |||
} | |||
|
|||
export function getCellHashProvider(notebook: INotebook): ICellHashProvider | undefined { |
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.
getCellHashProvider [](start = 16, length = 19)
Figured it made sense to centralize this here.
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.
If you just need the loggers looks like this should just take INotebookExecutionLogger[] instead of the entire notebook. So it doesn't have to expose the whole interface.
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.
Then the caller has to know that it comes from an array of loggers. Two pieces of information isntead of one. They have to have a notebook, why tell them the cell hash provider is on the loggers?
In reply to: 420474295 [](ancestors = 420474295)
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.
As in the CellHashProvider knows it's in the logger list for a notebook, nobody else needs to know this. They just know it's associated with a notebook. We might change how the cell hash provider is associated with a notebook in the future, but we'd likely still have it associated with a notebook itself.
In reply to: 420482187 [](ancestors = 420482187,420474295)
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.
My objection here is more how much is on the INotebook interface. The CellHashProvider could just call notebook.Dispose() here. Or notebook.restartKernel(). I feel like that's something we do a lot, especially with INotebook and IJupyterServer.
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.
But then the caller would have to understand about loggers. I don't think that scopes it down at all. I think it does the opposite. CellHashProvider knows it's a logger on a notebook. Nothing else needs to know that. However other things need some way to get the provider. I suppose other ways we could have done this would be to add a function to the notebook to retrieve it (that seems worse), add some sort of helper class that all you pass in is the notebook identity (that doesn't sound too bad), or this way.
In reply to: 420884909 [](ancestors = 420884909)
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.
Maybe we should split the notebook interface then. Something that's smaller (or readonly).
In reply to: 420881550 [](ancestors = 420881550)
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.
LIke IExecutableNotebook and INotebook where all of the state modifying items are on IExecutableNotebook.
In reply to: 420915749 [](ancestors = 420915749,420881550)
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 don't know if we need to do it now, but if you remember the question that I was asking at the end of the SOLID talk about oversized interfaces, INotebook was totally one of the interfaces that I was thinking about. I think part of the advice there was that breaking up the interface might be a good first step to at least make it hard in code to mess with something that should not be messed with. Splitting that might be part of a bigger overall code-health fix, so that might be better to not mess with in this PR.
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.
With Ian on this, we're passing something that's too broad.
this.getDocument(), | ||
this.getVariableHover(wordAtPosition) | ||
]); | ||
if (!variableHover && languageServer && document) { |
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.
If there's a word under the cursor and the debugger (or kernel) knows about it, it takes precedence over normal hover.
|
||
// tslint:disable: no-any | ||
@injectable() | ||
export class NativeEditorDebuggerListener |
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 should put a comment on this saying what this class is for.
glyphMarginClassName: 'codicon codicon-debug-stackframe', | ||
stickiness | ||
}; | ||
const TOP_STACK_FRAME_DECORATION: monacoEditor.editor.IModelDecorationOptions = { |
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.
Copied these from the VS code decorators they setup when debugging.
Codecov Report
@@ Coverage Diff @@
## master #11608 +/- ##
==========================================
- Coverage 60.70% 60.58% -0.12%
==========================================
Files 626 627 +1
Lines 33767 33865 +98
Branches 4748 4763 +15
==========================================
+ Hits 20498 20517 +19
- Misses 12289 12359 +70
- Partials 980 989 +9
Continue to review full report at Codecov.
|
hidden={this.isMarkdownCell()} | ||
disabled={this.props.busy} | ||
> | ||
<div className="codicon codicon-button">{'\uead7'}</div> |
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 should probably make these unicode values constants.
@@ -567,7 +567,7 @@ export abstract class InteractiveBase extends WebViewHost<IInteractiveWindowMapp | |||
line, | |||
id, | |||
originator: this.id, | |||
debug: debug !== undefined ? debug : false | |||
debug: debug !== undefined ? true : false |
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.
This almost looked like an error skimming down due the change from a bool to an object. This is just an up to you thing. But if the function took a debugInfo? it might make a bit more sense. Debug just sounds like a bool property to me and we use it as a bool property right here in a different call.
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.
if (debug.runByLine && debug.hashFileName) { | ||
await this.jupyterDebugger.startRunByLine(this._notebook, debug.hashFileName); | ||
} else { | ||
await this.jupyterDebugger.startDebugging(this._notebook); |
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.
runByLine = true without a debug.hasFileName just goes down the normal debugging path, which seems a bit funny. Is that intended?
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.
@@ -352,12 +358,12 @@ export class NativeEditor extends InteractiveBase implements INotebookEditor { | |||
line: number, | |||
id?: string, | |||
data?: nbformat.ICodeCell | nbformat.IRawCell | nbformat.IMarkdownCell, | |||
debug?: boolean, | |||
debugOptions?: { runByLine: boolean; hashFileName?: string }, |
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.
Didn't even see this when I made my comment on the debug options above. I do like this name better than the debug name for the options object above.
@@ -196,6 +199,18 @@ const images: { [key: string]: { light: string; dark: string } } = { | |||
JupyterServerDisconnected: { | |||
light: require('./images/JupyterServerDisconnected/disconnected-light.svg'), | |||
dark: require('./images/JupyterServerDisconnected/disconnected-dark.svg') | |||
}, | |||
RunByLine: { |
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.
Actually I don't really need this. I'll delete them.
} | ||
} | ||
} | ||
} catch (exc) { |
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 try here is around a bunch of code. If hashjs in getCellHashProvider throws an error I'm not sure if we want it showing up as cell output.
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.
Or maybe we do? Guess we have to see it somewhere.
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.
Yeah we do this elsewhere when running cells in a notebook.
In reply to: 420482775 [](ancestors = 420482775)
"DataScience.libraryRequiredToLaunchJupyterKernelNotInstalledInterpreter": "Data Science library {1} is not installed in interpreter {0}. Install?" | ||
"DataScience.libraryRequiredToLaunchJupyterKernelNotInstalledInterpreter": "Data Science library {1} is not installed in interpreter {0}. Install?", | ||
"DataScience.runByLine": "Run by line", | ||
"DataScience.continueRunByLine": "Stop" |
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.
Continue will say stop.
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.
|
||
// Then use that to make a hash value | ||
const hashedCode = stripped.join(''); | ||
const hash = hashjs.sha1().update(hashedCode).digest('hex').substr(0, 12); |
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.
Why only first 12 characters?
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.
That's what jupyter uses to generate the file name internally.
@@ -406,3 +430,11 @@ export class CellHashProvider implements ICellHashProvider, INotebookExecutionLo | |||
return traceFrame; | |||
} | |||
} | |||
|
|||
export function getCellHashProvider(notebook: INotebook): ICellHashProvider | undefined { |
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.
With Ian on this, we're passing something that's too broad.
private async handleRunByLine(runByLine: IRunByLine) { | ||
try { | ||
// If there's any payload, it has the code and the id | ||
if (runByLine.cell.id && runByLine.cell.data.cell_type !== 'messages') { |
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.
What if cell_type=markdown or raw
.
Shouldn't we handle other cell types.
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.
This should be impossible so it should just throw an exception unless it's a code cell
Kudos, SonarCloud Quality Gate passed!
|
For #11607
Partial implementation of run by line behind a flag. Should be enough for a demo.
List of stuff to be done after this: