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

Correctly import Python variable info functions in debug sessions for viewing in data viewer across 2+ scopes #5625

Merged
merged 3 commits into from
Apr 26, 2021

Conversation

joyceerhl
Copy link
Contributor

@joyceerhl joyceerhl commented Apr 24, 2021

For #5627

Our variable info import scripts are only evaluated once per debug session and in the topmost frame ID, so the scripts were subsequently inaccessible from other frames in the same debug session, hence the NameError in the issue description. I think this means that viewing variables in >1 scope in the data viewer in a single debug session hasn't ever worked.

The fix is to use __import__() to import the module and reference our function off it each time. This guarantees we'll have access to the module functions without relying on first sending a custom eval request that imports our function globally, since there isn't actually a way to do that given how Python modules work.

Tested scenarios:

  • Run By Line in custom editor --> open data viewer
  • Debug cell in interactive window --> open data viewer
  • Debug Python file --> open data viewer
  • Open data viewer from variable view
  • Open data viewer from interactive window variable explorer
  • Open data viewer from custom editor variable explorer
  • 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).

@codecov-commenter
Copy link

codecov-commenter commented Apr 24, 2021

Codecov Report

Merging #5625 (1758ec7) into main (70073c0) will increase coverage by 0%.
The diff coverage is 100%.

@@          Coverage Diff          @@
##            main   #5625   +/-   ##
=====================================
  Coverage     68%     68%           
=====================================
  Files        401     401           
  Lines      26724   26720    -4     
  Branches    3893    3893           
=====================================
+ Hits       18361   18362    +1     
+ Misses      6839    6833    -6     
- Partials    1524    1525    +1     
Impacted Files Coverage Δ
...rc/client/datascience/jupyter/debuggerVariables.ts 75% <ø> (-4%) ⬇️
src/client/datascience/constants.ts 99% <100%> (-1%) ⬇️
...active-common/intellisense/intellisenseProvider.ts 74% <0%> (+<1%) ⬆️
src/client/datascience/jupyter/jupyterNotebook.ts 75% <0%> (+<1%) ⬆️
...tascience/jupyter/liveshare/hostJupyterNotebook.ts 45% <0%> (+1%) ⬆️
src/client/common/process/pythonDaemonPool.ts 77% <0%> (+4%) ⬆️

@joyceerhl joyceerhl changed the title Correctly import Python variable info functions Correctly import Python variable info functions in debug sessions for viewing in data viewer across 2+ scopes Apr 25, 2021
@joyceerhl joyceerhl force-pushed the dev/joyceerhl/data-viewer-debugger branch from 7492b86 to 1758ec7 Compare April 25, 2021 01:36
@joyceerhl joyceerhl marked this pull request as ready for review April 26, 2021 17:56
@joyceerhl joyceerhl requested a review from a team as a code owner April 26, 2021 17:56
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.

4 participants