-
Notifications
You must be signed in to change notification settings - Fork 892
refactor: consolidate watch_and_export implementations
#8000
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
refactor: consolidate watch_and_export implementations
#8000
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@mscolnick I deviated from #7997 (comment) in this refactor and kept |
marimo/_server/export/__init__.py
Outdated
| @dataclass | ||
| class ExportResult: | ||
| contents: str | ||
| contents: bytes |
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.
there might be a small inefficiency over converting from text to bytes and back. maybe we could do:
contents: bytes | str
with a @property (or @cached_property) for bytes and text that will check the contents type and convert or not convert
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.
Great point.
To make sure we don't shadow the built-in bytes via a def bytes(self) ...: how about contents: bytes | str and either as_bytes() / as_text() or via cached_property data_bytes / data_text ?
or just bytez? (:
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.
yes, great call
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.19.7-dev23 |
📝 Summary
Consolidate
watch_and_export_bytesandwatch_and_exportimplementations & representExportResultcontents as bytes while still allowing string-based access.Follow-up of #7997
🔍 Description of Changes
ExportResultrepresent results as bytes instead of strings to support cases like PDF exporthttpx,requests, etc.watch_and_export_bytesinstead ofwatch_and_exportso thatexport_callbackcan keep returningExportResultobjects to (1) avoid duplicating encode / decode logic, (2) have a place for cross-cutting helpers like.text/.from_textand (3) keep the door open for additional metadata like e.g. warnings or execution stats📋 Checklist