-
Notifications
You must be signed in to change notification settings - Fork 892
improvement: downgrade dataframe in non-interactive environments #7940
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR improves the rendering of dataframe-based UI components in non-interactive environments (such as GitHub viewers) by renaming the is_no_js() function to is_non_interactive() for better clarity, and implementing _mime_() methods that downgrade interactive table and dataframe widgets to plain HTML representations when JavaScript is not available.
Changes:
- Renamed
is_no_js()tois_non_interactive()across the codebase for better semantic clarity - Implemented
_mime_()methods intableanddataframeclasses to provide plain HTML fallbacks in non-interactive environments - Added test coverage for both
mo.ui.table()andmo.ui.dataframe()in the export fixture
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| marimo/_output/hypertext.py | Renamed is_no_js() to is_non_interactive() for better semantic clarity |
| marimo/_output/md.py | Updated function call to use is_non_interactive() |
| marimo/_output/formatting.py | Updated function call to use is_non_interactive() |
| marimo/_output/formatters/df_formatters.py | Updated function call to use is_non_interactive() |
| marimo/_plugins/ui/_impl/table.py | Replaced _repr_markdown_() with _mime_() method that conditionally returns plain HTML in non-interactive environments |
| marimo/_plugins/ui/_impl/dataframes/dataframe.py | Added _mime_() method to provide plain HTML fallback in non-interactive environments |
| marimo/_plugins/ui/_impl/plotly.py | Updated function call to use is_non_interactive() |
| marimo/_plugins/ui/_impl/altair_chart.py | Updated function call to use is_non_interactive() |
| tests/fixtures/notebook_with_media.py | Added test cells for mo.ui.table() and mo.ui.dataframe() |
| tests/_cli/snapshots/export/ipynb/ipynb_with_media_outputs.txt | Updated snapshot with expected HTML outputs for table and dataframe widgets |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
| repr_html = getattr(self._data, "_repr_html_", None) | ||
| if repr_html is not None and callable(repr_html): | ||
| return ("text/html", cast(str, repr_html())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we move this logic to hypertext.py?
the logic is also repeated in table.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the duplication is fine since, its about 2 lines and they are both tested
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.19.7-dev3 |
This prints plain HTML dataframes when we are exporting to non-interactive environments (e.g. ipynb, pdf)