Closed machow closed 2 weeks ago
This is happening specifically because Great Table's html output does not include html, body, or script tags, which Positron uses to distinguish what should go in the console vs. Viewer. After pairing with @machow, there could be changes on the Great Tables side to include these tags OR changes on the Positron side to look for a Great Tables identifying tag.
Following https://github.com/posit-dev/great-tables/pull/233 -- there will be a fix in great_tables
to get this output to the right place!
Great tables PR is merged-- there is now infrastructure in place to put the output in the Viewer
pane. It is not turned on right now, since it will require code in great_tables
to be something like ipython.get_ipython().__class__.__name__ == 'PositronShell'
to set the correct HTML output.
So do I understand correctly that it is not (easily) possible for us to get great tables into the Positron viewer pane before we can do a Positron-specific PR to the package? Should we move this issue to Release Candidate?
Correct, the PR would have to include the name Positron
, so this can go anytime after Public Beta.
It appears that even when using great-tables
v0.10 the output is still printed to the console instead of the Viewer.
Is this an action on our end or something we can ask of @machow ?
This is an action on our end; the decision concerning what HTML gets rendered in the Console vs. what gets promoted to the Viewer is based on heuristics, so we would just need to tweak those.
There are heuristics in great_tables
depending on what IDE the table is being rendered in. Right now, it will create a full html page if it is detected that the user is running in Positron, which I believe aligns with Positron's heuristics on what is Viewer-worthy.
with great_tables==0.10.0
I am able to see a table populate the Viewer pane, although there is a lot of context being printed with the call we could clean up 😅 Is there a reprex for it printing in the console?
I am seeing the printing to console, and for some reason last night I swear it wasn't bringing the Viewer into focus or displaying 🤔
The below is working just fine currently.
#minimal
import pandas as pd
from great_tables import GT
df = pd.DataFrame({"x": [1,2,3]})
GT(df)
# more advanced
from great_tables import GT
from great_tables.data import sp500
# Define the start and end dates for the data range
start_date = "2010-06-07"
end_date = "2010-06-14"
# Filter sp500 using Pandas to dates between `start_date` and `end_date`
sp500_mini = sp500[(sp500["date"] >= start_date) & (sp500["date"] <= end_date)]
# Create a display table based on the `sp500_mini` table data
(
GT(sp500_mini)
.tab_header(title="S&P 500", subtitle=f"{start_date} to {end_date}")
.fmt_currency(columns=["open", "high", "low", "close"])
.fmt_date(columns="date", date_style="wd_m_day_year")
.fmt_number(columns="volume", compact=True)
.cols_hide(columns="adj_close")
)
As of July 23, 2024 I can't get great tables plots to show up in the console. Did great tables to a release to fix this? @machow
I can't get great tables plots to show up in the console.
Are you wanting the table to be in the Viewer pane or the Console? I believe the expected behavior at this point is that the table goes to the viewer pane
That was a confusingly worded way of saying: I think this is fixed now. I want them to show up in the viewer pane.
In latest build, I'm still seeing a bunch of HTML content printed to console but not "used", although the table is printing to the Viewer pane.
Positron Version: 2024.07.0 (Universal) build 89 Code - OSS Version: 1.91.0 Commit: 08b25a7c9a8ce879674850f76728517302bc91e3 Date: 2024-07-23T04:47:51.330Z Electron: 29.4.0 Chromium: 122.0.6261.156 Node.js: 20.9.0 V8: 12.2.281.27-electron.0 OS: Darwin arm64 23.5.0
pip freeze | grep great
great-tables==0.10.0
https://github.com/user-attachments/assets/510f2246-c9b7-4fdc-bfef-36df22eb0d8b
That looks like GT
's console representation. If you were to output a GT object in the IPython shell, that's what it would produce. In jupyter lab something like this happens:
_repr_*_()
methods_repr_html_()
)It seems like maybe positron might be keeping the console repr in step (3)? I could have this super wrong, and am happy to do whatever is useful!
Positron Version(s) : 2024.07.0-113
OS Version : OSX
Looks good from console and notebook.
Link(s) to TestRail test cases run or created: N/A
Positron Version:
Positron Version: 2024.01.0 (Universal) build 162 Code - OSS Version: 1.85.0 Commit: aeb47f532448b4f691fe7432f8b6938bcb565d34 Date: 2024-01-17T17:34:28.863Z Electron: 25.9.7 ElectronBuildId: undefined Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Darwin arm64 23.2.0
Steps to reproduce the issue:
pip install great_tables
What did you expect to happen?
Similar to the
gt
R package in RStudio and Positron, it would be nice if the output for the python package displayed in the Viewer pane. However, it gets put into the console output (still formatted at HTML though, which is handy!). We're happy to implement any hooks / checks to handle this on the python side!