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

Feature Request: Optional Inclusion of Jupyter Cell Outputs #119

Open
filipchristiansen opened this issue Jan 10, 2025 · 3 comments
Open
Labels
discussion Community talk on a given topic

Comments

@filipchristiansen
Copy link
Collaborator

We are considering a feature to optionally include the outputs of Jupyter code cells. When enabled, the tool would append the last output of each code cell (if any) directly below the cell's source code as a comment.

Proposed Solution:

  • Introduce a command-line flag for the terminal client to toggle this behavior.
  • Add a similar toggle option in the web client's "Advanced Settings" (in a future release) to enable optional inclusion of cell outputs.

Request for Feedback:

Please share your thoughts on the utility of this feature. Your feedback will help us prioritize new features based on actual user needs. Thank you!

@IsNoobgrammer
Copy link

Yes!! , It would help in give llms or users more context on how that "notebook" should work in first place,

as when we see notebook , we see not only its code , but its outputs too , so I think we can try adding it , however I think it should be by default @cyclotruc , Because thats what Notebook are for (Better Understanding and working of code) !!!

@IsNoobgrammer
Copy link

IsNoobgrammer commented Jan 10, 2025

To provide further context
outputs can be of different types like and i will provide my suggestion for every type

__OUTPUT__TYPE__ = "execute_result"
"outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x24ee8f511d0>]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }

So in this case , execute_result should be parsed output= execute_result : [<matplotlib.lines.Line2D at 0x24ee8f511d0>]

__OUTPUT__TYPE__ = "display_data"
   "outputs": [
    {
     "data": {
      "image/png": "B64 IMAGE DATA",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "<Figure size 640x480 with 1 Axes>"
    }

so in this case We don't need that image b64 value output=display_data : <Figure size 640x480 with 1 Axes>

__OUTPUT__TYPE__ = "stream"
"outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hello\n"
     ]
    }
   ]

from this output = hello\n

__OUTPUT__TYPE__ = "error"
"outputs": [
  {
   "ename": "NameError",
   "evalue": "name 'oxe' is not defined",
   "output_type": "error",
   "traceback": [
    "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
    "\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
    "Cell \u001b[1;32mIn[9], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28mprint\u001b[39m(oxe)\n",
    "\u001b[1;31mNameError\u001b[0m: name 'oxe' is not defined"
   ]
  }
 ],

we need output as NameError : name 'oxe' is not defined since in jupyter error is very verbose sometimes

Note: Outputs : List[dict | None] is the output of the cell in all formats , so , earlier I mentioned to parse only outputs[-1] , but that approach was wrong , the better approach would be parse all dicts from outputs according to the proposed format and then write that whole parsed_output as comment

for example

"outputs": [
    {
     "ename": "ValueError",
     "evalue": "'text' is not a valid format string (unrecognized character 't')",
     "output_type": "error",
     "traceback": ["VERY","Verbose","traceback"]
    },
    {
     "data": {
      "image/png": "FILLER b64",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ]

so the expected output from this cell should be

# * output *
#  ValueError : 'text' is not a valid format string (unrecognized character 't')
#  display_data : <Figure size 640x480 with 1 Axes>

@filipchristiansen
Copy link
Collaborator Author

I will leave it up to @cyclotruc to decide about the default behaviour.

@IsNoobgrammer: In the meantime, feel free to draft a PR (or I can also do it once my current priorities are completed.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Community talk on a given topic
Projects
None yet
Development

No branches or pull requests

2 participants