You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor OutputsManager to align with default Jupyter behavior (#163)
* Add safe msg_id handling in kernel_client.
* Contrain to Python 3.13 in dev environment.
* Create _is_stream_output utility function
* Update stream_limit to 500 to avoid triggering too early
* Use set literal
* Update get_outputs to remove stream_limit logic
The stream_limit logic is being moved in this PR to the writing of outputs, so get_outputs can just return all outputs.
* Create _append_to_stream_file utility method.
* Update process_loaded_notebook to handle exclude_outputs
* Modify private _process_loaded methods to handle exclude_outputs
* Update process_saving_notebooks to handle exclude_outputs
* Add comment about placeholder outputs wrt nbformat
* Fix write to better handle stream outputs and stream_limit at write time
* Remove call to clear in saving logic
* Refactor OutputsManager and add experimental OptimizedOutputsManager
This commit introduces a cleaner architecture for handling notebook outputs
and adds an experimental optimized version that supports excluding outputs
from saved notebook files.
Core changes to OutputsManager:
- Extract private utility functions (_create_output_url, _create_output_placeholder)
- Add comprehensive docstrings to all methods
- Simplify write() method by removing stream_limit logic
- Improve error handling in get_outputs() to return empty list instead of raising
- Consolidate output processing logic into _process_outputs_from_cell()
- Add helper methods: _upgrade_notebook_format(), _ensure_cell_id()
- Always write full outputs to notebook files on save (traditional Jupyter behavior)
- Remove stream-specific handling and StreamAPIHandler route
New OptimizedOutputsManager:
- Extends base OutputsManager with exclude_outputs metadata flag support
- When exclude_outputs=True: outputs stored only in runtime, not in saved files
- When exclude_outputs=False/unset: full outputs included in saved files (default)
- Implements stream_limit (500) for large stream outputs with link placeholders
- Provides _append_to_stream_file() for efficient stream handling
- Stream API handler for accessing accumulated stream outputs
Other improvements:
- Add __all__ to outputs/__init__.py for cleaner exports
- Expand test coverage with comprehensive test suite
- Rename private methods for clarity (_process_loaded_excluded_outputs, etc.)
- Update yroom_file_api to use process_saving_notebook correctly
The OptimizedOutputsManager is currently experimental and disabled by default.
StreamAPIHandler route is commented out until the feature is ready for production.
0 commit comments