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

"Run All" button executes cells in random order #15937

Closed
1 of 2 tasks
y1zhou opened this issue Aug 14, 2024 · 8 comments
Closed
1 of 2 tasks

"Run All" button executes cells in random order #15937

y1zhou opened this issue Aug 14, 2024 · 8 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug *duplicate Issue identified as a duplicate of another issue(s) notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel)

Comments

@y1zhou
Copy link

y1zhou commented Aug 14, 2024

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

Steps taken

  1. Create new notebook
  2. Write x = 1 in cell 1, x in cell 2, y=2 in cell 3, y in cell 4, etc.
  3. Click the "Run All" button, or hover on cell 1 and click "Execute Cell and Below"

Expected outcome

Cells get executed in order.

Observed outcome

Cell 2n raises a NameError of undefined variable because cell 2n-1 was not executed.

VS Code Version

Version: 1.92.1 Commit: eaa41d57266683296de7d118f574d0c2652e1fc4 Date: 2024-08-07T20:16:39.455Z Electron: 30.1.2 ElectronBuildId: 9870757 Chromium: 124.0.6367.243 Node.js: 20.14.0 V8: 12.4.254.20-electron.0 OS: Darwin arm64 23.5.0

Jupyter Extension Version

v2024.7.0

Jupyter logs

14:36:21.029 [warn] Cell completed with errors Qd [Error]: name 'x' is not defined
    at n.execute (/home/~/.vscode-server/extensions/ms-toolsai.jupyter-2024.7.0-linux-x64/dist/extension.node.js:297:4958) {
  ename: 'NameError',
  evalue: "name 'x' is not defined",
  traceback: [
    '\x1B[0;31m---------------------------------------------------------------------------\x1B[0m',
    '\x1B[0;31mNameError\x1B[0m                                 Traceback (most recent call last)',
    'Cell \x1B[0;32mIn[1], line 1\x1B[0m\n\x1B[0;32m----> 1\x1B[0m \x1B[43mx\x1B[49m\n',
    "\x1B[0;31mNameError\x1B[0m: name 'x' is not defined"
  ]
}
14:36:21.029 [warn] Cancel all remaining cells due to cancellation or failure in execution

Coding Language and Runtime Version

Python v3.12.3

Language Extension Version (if applicable)

v2024.12.3

Anaconda Version (if applicable)

conda 23.11.0, micromamba 1.5.8

Running Jupyter locally or remotely?

Remote

@y1zhou y1zhou added the bug Issue identified by VS Code Team member as probable bug label Aug 14, 2024
@vs-code-engineering vs-code-engineering bot added the triage-needed Issue needs to be triaged label Aug 14, 2024
@amunger
Copy link
Contributor

amunger commented Aug 14, 2024

that's strange - I can't think of why that would happen. Just to confirm, if you execute the cells one by one, do they run successfully?

Can you try creating a new profile and just installing the python and jupyter extensions and see if it still repro's.

if so, can you set "jupyter.logging.level": "trace", go through the steps again, and post the logs from that run.

@amunger amunger added info-needed Issue requires more information from poster and removed triage-needed Issue needs to be triaged labels Aug 14, 2024
@y1zhou
Copy link
Author

y1zhou commented Aug 15, 2024

that's strange - I can't think of why that would happen. Just to confirm, if you execute the cells one by one, do they run successfully?

Correct I can still shift+enter all the way down to the end without problems.

Can you try creating a new profile and just installing the python and jupyter extensions and see if it still repro's.

This was a good call! The issue did not reproduce in the new profile. When I switched back to the default profile it also seems to run all cells sequentially without problems, although I had to re-install the Python and Jupyter extensions for some reason.

I'm going to close the issue for now and add comments if the problem comes back. Thanks for the help!

@y1zhou y1zhou closed this as completed Aug 15, 2024
@peterkrull
Copy link

I think what I am experiencing might be related to this, though to me it looks more like cells are executed in a random order, causing it to seem like some are skipped.

2024-08-22.17-48-02.mp4

With a log (though from a different execution) that confirms the strange order:

18:06:22.022 [debug] Handle Execution of Cells 0,1,2,3,4,5 for ~/Dropbox/University/ES9/jupyterbug.ipynb
18:06:22.120 [trace] Cell Index:2 sent to kernel
18:06:22.141 [trace] Start cell 2 execution @ 1724342782140 (clear output)
18:06:22.145 [debug] Kernel acknowledged execution of cell 2 @ 1724342782140
18:06:22.150 [trace] Cell 2 completed in 0.009s (start: 1724342782140, end: 1724342782149)
18:06:22.151 [trace] Cell 2 executed successfully
18:06:22.154 [trace] Cell Index:4 sent to kernel
18:06:22.163 [trace] Start cell 4 execution @ 1724342782163 (clear output)
18:06:22.165 [debug] Kernel acknowledged execution of cell 4 @ 1724342782163
18:06:22.168 [trace] Cell 4 completed in 0.005s (start: 1724342782163, end: 1724342782168)
18:06:22.170 [trace] Cell 4 executed successfully
18:06:22.173 [trace] Cell Index:3 sent to kernel
18:06:22.185 [trace] Start cell 3 execution @ 1724342782185 (clear output)
18:06:22.188 [debug] Kernel acknowledged execution of cell 3 @ 1724342782185
18:06:22.191 [trace] Cell 3 completed in 0.006s (start: 1724342782185, end: 1724342782191)
18:06:22.192 [trace] Cell 3 executed successfully
18:06:22.195 [trace] Cell Index:0 sent to kernel
18:06:22.206 [trace] Start cell 0 execution @ 1724342782205 (clear output)
18:06:22.208 [debug] Kernel acknowledged execution of cell 0 @ 1724342782205
18:06:22.216 [trace] Cell 0 completed in 0.011s (start: 1724342782205, end: 1724342782216)
18:06:22.218 [trace] Cell 0 executed successfully
18:06:22.222 [trace] Cell Index:5 sent to kernel
18:06:22.231 [trace] Start cell 5 execution @ 1724342782231 (clear output)
18:06:22.233 [debug] Kernel acknowledged execution of cell 5 @ 1724342782231
18:06:22.240 [trace] Cell 5 completed in 0.009s (start: 1724342782231, end: 1724342782240)
18:06:22.245 [trace] Cell 5 executed successfully
18:06:22.247 [trace] Cell Index:1 sent to kernel
18:06:22.260 [trace] Start cell 1 execution @ 1724342782260 (clear output)
18:06:22.261 [debug] Kernel acknowledged execution of cell 1 @ 1724342782260
18:06:22.268 [trace] Cell 1 completed in 0.007s (start: 1724342782260, end: 1724342782267)
18:06:22.270 [trace] Cell 1 executed successfully

@y1zhou
Copy link
Author

y1zhou commented Aug 23, 2024

I also ran into the issue a few times and it does seem to happen randomly. Sometimes it works fine after restarting the kernel.

@y1zhou y1zhou reopened this Aug 23, 2024
@y1zhou y1zhou changed the title "Run All" button skips cells randomly "Run All" button executes cells in random order Aug 23, 2024
@y1zhou
Copy link
Author

y1zhou commented Aug 30, 2024

@amunger Following up to see if additional information is needed. Thanks!

@SmallhillCZ
Copy link

SmallhillCZ commented Sep 4, 2024

+1

I have the same issue for a few weeks. Happens only sometimes and usually causes NameError: name 'X' is not defined as the cell that should define it runs before, so cells look as though they are skipped, but might be just random order of execution. Also Shift+Enter works good for me.

@peterkrull
Copy link

Yeah this is pretty much breaking issue for those of us that experience it. I would be happy to provide system/configuration information if needed.

@amunger amunger removed the info-needed Issue requires more information from poster label Sep 4, 2024
@DonJayamanne DonJayamanne assigned DonJayamanne and unassigned amunger Sep 4, 2024
@DonJayamanne DonJayamanne added notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel) *duplicate Issue identified as a duplicate of another issue(s) labels Sep 4, 2024
@DonJayamanne
Copy link
Contributor

DonJayamanne commented Sep 4, 2024

This is a duplicate of #15746
Please install the latest pre-release version of the Jupyter extension (2024.8.***) or the latest release (should get released some time today/tomorrow).

@peterkrull @SmallhillCZ @y1zhou
If the problem still persists, please do ping here or feel free to create a new issue.

  • Open the extensions page, search for Jupyter and click the button Switch to Pre-Release Version
    (image for reference only, on how to locate and install the pre-release version)

Screenshot 2023-02-04 at 09 24 37

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug *duplicate Issue identified as a duplicate of another issue(s) notebook-execution Kernels issues (start/restart/switch/execution, install ipykernel)
Projects
None yet
Development

No branches or pull requests

5 participants