feat: improve Python notebook cell output (#1505)#1857
Open
stu-code wants to merge 4 commits intosassoftware:mainfrom
Open
feat: improve Python notebook cell output (#1505)#1857stu-code wants to merge 4 commits intosassoftware:mainfrom
stu-code wants to merge 4 commits intosassoftware:mainfrom
Conversation
added 2 commits
April 7, 2026 21:09
- Suppress SAS log for Python cells; show output only when there is Python stdout, a Python error, or a SAS-level error - Python code that fails to run results in an X on the notebook cell - Render Python exceptions using VS Code's built-in error renderer with coloring and highlighting - New default - Auto-display the last expression in a Python cell: objects with _repr_html_() (DataFrames, sklearn models, pipelines) are rendered as rich HTML via base64 extraction; all other values fall back to print(). A second optional mode, SAS.show(), renders via ODS HTML5 and is configurable via SAS.notebook.python.autoPrintMethod. Configuration is available in UI. Signed-off-by: Stu Sztukowski <stu.sztukowski@sas.com>
Signed-off-by: Stu Sztukowski <stu.sztukowski@sas.com>
Author
|
Note that in order for this to pass the build test, it will need to be updated for the new Python code block output behavior. |
Signed-off-by: Stu Sztukowski <stu.sztukowski@sas.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary:
Improvements to Python code blocks based on feature request 1505:
Python code that fails to run results in an X on the notebook cell
New default - Auto-display the last expression in a Python cell: objects with repr_html() (DataFrames, sklearn models, pipelines) are rendered as rich HTML via base64 extraction; all other values fall back to print(). A second optional mode, SAS.show(), renders via ODS HTML5 and is configurable via SAS.notebook.python.autoPrintMethod. Configuration is available in UI.
Testing:
Tests were performed manually in a Python code block with the exception of (4) which uses a SAS code block to create a SAS error condition. (See TODOs for updating build tests)
1. Tests for if there is no Python stdout or an error:
Test 1.1:
Expected result: No output
Test 1.2:
Expected result: No output
Test 1.3:
Expected result: No output
2. Tests for Python output:
Test 2.1:
Expected result:
Test 2.2:
{'Hello': 'world'}Expected result:
Test 2.3:
asdfExpected result:
3. Test DataFrame and model rendering.
Test 3.1:
Test 3.2: Switch to SAS.show from (auto) in SAS extension Python autoprint settings:
Expected result: DataFrame renders in ODS HTML5. Model produces the following:
4. Test SAS errors: run the following SAS code, then run a Python code block:
Test 4.1:
'Hello world!'Expected result:
TODOs: