Skip to content

feat(notebook): add interactive notebook-like runtime support. Closes #540 #654

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Yashika-01
Copy link
Contributor

#540


name: Pull Request
about: Create a pull request to contribute to the project
title: 'feat(notebook): add interactive notebook-like runtime support. Closes #540'
labels: 'feature'
assignees: 'Yashika-01'

Related Issue
Fixes #540

Description of Changes
This pull request introduces an interactive notebook-like runtime in Preswald. The changes include:

  • Backend:

    • Addition of a new NotebookSession class (in notebook.py) to store a shared global namespace, execute code cells, capture output, logs, and errors.
    • Integration with WebSocket in server_service.py to allow sending code cells from the frontend and streaming execution results back.
    • Persistence of cell content on the server so that on browser refresh the cell content is restored, but the executed state (tick marks) resets.
  • Frontend:

    • A new notebook interface in NotebookView.jsx for adding, editing, deleting, and reordering cells (with drag-and-drop support).
    • Integration of a CodeMirror-based Python editor (with syntax highlighting and auto-sizing) for improved cell editing.
    • Use of visual indicators (tick marks) to show when a cell has been executed; these are cleared on refresh to enforce re-running of cells.
    • Rendering of outputs for text, DataFrames, and Plotly charts using the existing HTMLRenderer component.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • New example
  • Test improvement

Testing

  • Ran the notebook mode locally (using --mode notebook) to ensure that users can:
    • Add, edit, delete, and reorder cells.
    • Execute cells individually with inline outputs (including text, DataFrame HTML, and Plotly charts).
  • Verified that after a browser refresh, the cell content is restored while the executed flag resets (tick marks are cleared), requiring the user to re-run cells.
  • Attached relevant screenshots and logs to the PR for reference.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have run my code against examples and ensured no errors
  • Any dependent changes have been merged and published in downstream modules

@shivam-singhal
Copy link
Member

@Yashika-01 can you rebase and resolve merge conflicts?

@Yashika-01 Yashika-01 force-pushed the feature/notebook-runtime branch from 589e3a2 to 5a38942 Compare April 11, 2025 19:06
@Yashika-01
Copy link
Contributor Author

@Yashika-01 can you rebase and resolve merge conflicts?

Done

@Yashika-01
Copy link
Contributor Author

Hello,
I wanted to follow up and kindly ask if someone could review this pull request when convenient. Please let me know if there are any changes or clarifications needed. I'm happy to address any feedback.
Thank you!

@amrutha97 amrutha97 force-pushed the main branch 2 times, most recently from 6ac1dad to bdb2c4e Compare April 24, 2025 07:54
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.

[FEATURE] Add support for interactive notebook-like runtime in Preswald
2 participants