Skip to content

Make data viewer openable from the variables window while debugging#14269

Closed
joyceerhl wants to merge 9 commits intomicrosoft:mainfrom
joyceerhl:tensor-variable-context-menu
Closed

Make data viewer openable from the variables window while debugging#14269
joyceerhl wants to merge 9 commits intomicrosoft:mainfrom
joyceerhl:tensor-variable-context-menu

Conversation

@joyceerhl
Copy link
Copy Markdown

@joyceerhl joyceerhl commented Oct 5, 2020

Per @greazer, changing the scope of this PR to provide users with a way to open the data viewer for data-viewable types, i.e.:

  • 'DataFrame'
  • 'list'
  • 'dict'
  • 'ndarray'
  • 'Series'

dataframes

TODO:

  • Currently doesn't work unless RBL experiment is enabled due to reliance on jupyterVariables.getMatchingVariable which is not implemented for oldJupyterVariables
  • Need integration test

@joyceerhl joyceerhl added the no-changelog No news entry required label Oct 5, 2020
@joyceerhl joyceerhl changed the title Show 'View Tensor in Data Viewer' for tensors Show 'View Tensor in Data Viewer' debug menu option for tensors Oct 5, 2020
(TODO find a better place to add the __vscodeVariableMenuContext property to the DebugProtocol.Variable)
}
return true;
});
const allowedVariables = variablesResponse.body.variables
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

We might want to get in touch with Debugger team about this.
Its something they might find useful or be aware of (the fact that we're adding this).
Personally I'd prefer if all of this was done in debugpy and we just hooked into some message or the like (e.g. we could use capabilities or other flags & use custom messages)
@int19h @karthiknadig /cc

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It would be hard to make it quite as flexible as client-side filtering. If we hardcode the filters, debugpy would have to be touched every time this logic needs revising. And if we don't hardcode them, then the protocol would need to be expressive enough to express all those conditions, which would also make the implementation expensive.

I think client-side filtering is the better option here, unless there are important perf reasons to exclude some variables.

Copy link
Copy Markdown
Author

@joyceerhl joyceerhl Oct 6, 2020

Choose a reason for hiding this comment

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

Just in the interest of clarity (even though I think the conclusion is the same), we're not asking for filtering logic in debugpy. What we're after is debugpy setting the __vscodeVariableMenuContext property on DebugProtocol.Variables before they are sent over to VS Code, several lines down from this spot: https://github.com/microsoft/vscode-python/pull/14269/files#diff-d8fc76e8c5b19f7c5df2b4282409e727R297-R300

As background for anyone unfamiliar with why we need this, the reason we need this property is so that we can make use of the new contribution point for the variable context menu introduced in the August release. VS Code uses the hidden __vscodeVariableMenuContext property to set a per-variable debugProtocolVariableMenuContext key with the same contents (details). Extensions can then use the debugProtocolVariableMenuContext key in when clauses that specify whether a given context menu item with an associated command should be displayed for a given variable.

@joyceerhl joyceerhl changed the title Show 'View Tensor in Data Viewer' debug menu option for tensors Make data viewer openable from the variables window while debugging Oct 8, 2020
}
}

private async onVariablePanelShowDataViewerRequest(request: IShowDataViewerFromVariablePanel) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This seems like a weird spot to handle this. What if there isn't an interactive window open? Seems like it should work without a notebook.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah @jmew clarified with me this morning that we want this to work for regular debugging too, so this will need reworking (currently only works when debugging in the IW)

}
}

// This special DebugAdapterTracker function listens to messages sent from VSCode to the debug adapter
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think you should move this into the DebugLocationTracker. It really does this too (and seems like it's also incorrect). Then make that DebugLocationTracker some global service that this code could use.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done in #14336

@sonarqubecloud
Copy link
Copy Markdown

Kudos, SonarCloud Quality Gate passed!

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

No Coverage information No Coverage information
No Duplication information No Duplication information

@joyceerhl joyceerhl marked this pull request as ready for review October 14, 2020 23:03
@joyceerhl
Copy link
Copy Markdown
Author

Was able to test that this works with debugging Python files through the 'attach' config (debugging via 'launch' is broken for me ATM for some reason).
debugsinglefile

Please review when you have the time!

@joyceerhl
Copy link
Copy Markdown
Author

joyceerhl commented Oct 14, 2020

Actually, going to open a PR off of the main repo. AzDO PR validation still isn't being reported on PRs from forks

@joyceerhl joyceerhl closed this Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog No news entry required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants