jupyter-cache icon indicating copy to clipboard operation
jupyter-cache copied to clipboard

Clarify "Couldn't find cache key" warnings to make clear the root problem is failed execution

Open choldgraf opened this issue 5 years ago • 4 comments

I'm trying to update a test in MyST-NB that requires re-running one of the notebooks. However, the test keeps failing with this error, which I think is independent of MyST-NB:

E       AssertionError: assert '\x1b[31mWARN...x1b[39;49;00m' == ''
E         - WARNING: Execution Failed: /tmp/pytest-of-choldgraf/pytest-304/test_complex_outputs_unrun0/source/complex_outputs_unrun.ipynb
E         - WARNING: Couldn't find cache key for notebook file source/complex_outputs_unrun.ipynb. Outputs will not be inserted.

I can't figure out how to get rid of this error, and it doesn't make sense to me why it'd show up because I think everything in those tests is generated at test-time (at least, the cache etc). Am I doing something wrong? Or is this a bug?

choldgraf avatar Jun 09 '20 18:06 choldgraf

Well, as the warnings suggest 😉; it can't find the cache key, because the notebook failed to execute, and so wasn't added to the cache. So either (a) you haven't got all the dependencies installed to run that notebook (my guess), or (b) whatever you have changed is causing the notebook to fail. You can get the test to print out the full stdout/stderr (can't remember exactly how off-hand), or you can try physically opening the notebook and running it through.

chrisjsewell avatar Jun 09 '20 18:06 chrisjsewell

Ah interesting - OK it makes sense that the execution was failing. I think it was the warnings that threw me off. Because they are printed right after one another, I thought that the execution failed because the cache key couldn't be found. Perhaps there's a more intuitive way of structuring/wording those warnings?

choldgraf avatar Jun 09 '20 19:06 choldgraf

Yeh open for any improvements in wording, but

I thought that the execution failed because the cache key couldn't be found

What are you benjamin button lol; the cache key warning follows the execution warning, which surely implies that the execution failure subsequently caused the cache key failure? (i.e. cause precedes effect)

chrisjsewell avatar Jun 09 '20 19:06 chrisjsewell

I don't think most users are going to analyze their warning messages with the kinds of logical connections that you're showing here lol, most people just look up at the last error message and then assume that's their problem.

choldgraf avatar Jun 09 '20 19:06 choldgraf