-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
Add pn.Feed to allow buffering of feed objects #6031
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #6031 +/- ##
==========================================
- Coverage 84.19% 82.65% -1.55%
==========================================
Files 301 305 +4
Lines 45200 45419 +219
==========================================
- Hits 38058 37542 -516
- Misses 7142 7877 +735
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
You likely need to update index.ts |
Try running this.define<Log.Props>(({ Int }) =>
min_visible: [Int, 10],
})); |
You're magical :D that worked |
Works pretty well now~ import panel as pn
pn.extension()
def prepend(event):
log.insert(0, log[0].object - 1)
def insert(event):
log.insert(50, len(log))
def append(event):
log.append(len(log))
def replace(event):
log.objects = [i for i in range(30)]
log = pn.Log(*[i for i in range(100)], height=200, auto_scroll_limit=100, width=500)
prepend_button = pn.widgets.Button(name='Prepend', button_type='primary', on_click=prepend)
insert_button = pn.widgets.Button(name='Insert', button_type='primary', on_click=insert)
append_button = pn.widgets.Button(name='Append', button_type='primary', on_click=append)
replace_button = pn.widgets.Button(name='Replace', button_type='primary', on_click=replace)
pn.Row(pn.Column(prepend_button, insert_button, append_button, replace_button), log).servable() Screen.Recording.2023-12-13.at.3.10.43.PM.mov |
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'm fine with this approach, just wondering at what point it makes sense to render only the currently visible models plus some buffer and then display a loading indicator if they aren't fetched quick enough. For large numbers of messages this will significantly reduce serialization time.
That sounds like a good idea. How do I subset the number of children rendered? import panel as pn
pn.extension(sizing_mode="stretch_width")
def prepend(event):
log.insert(0, log[0].object - 1)
def insert(event):
log.insert(50, len(log))
def append(event):
log.append(len(log))
def replace(event):
log.objects = [i for i in range(30)]
def limit(event):
log.loaded_entries = 10
log = pn.Log(*[i for i in range(100)], height=200, auto_scroll_limit=100, width=500)
prepend_button = pn.widgets.Button(name="Prepend", on_click=prepend)
insert_button = pn.widgets.Button(name="Insert", on_click=insert)
append_button = pn.widgets.Button(name="Append", on_click=append)
replace_button = pn.widgets.Button(name="Replace", on_click=replace)
limit_button = pn.widgets.Button(name="Limit", on_click=limit)
pn.Row(
pn.Column(
prepend_button,
insert_button,
append_button,
replace_button,
limit_button,
pn.widgets.IntInput.from_param(log.param.loaded_entries),
max_width=200
),
log,
).servable() |
It's probably going to be pretty involved. It'd look something like this:
In practice that means overriding |
Needs cleanup, tests, and maybe some logic fixes with the timeout, but now it only renders the loaded_entries. Screen.Recording.2023-12-19.at.5.50.19.PM.mov |
Will add reference gallery tomorrow. Screen.Recording.2023-12-26.at.5.45.04.PM.movStrangely, it takes a long time to serve: import panel as pn
pn.extension()
pn.Log(
*list(range(10000)), scroll=True, height=250, width=250
).servable() vs one order of magnitude less so I'm not sure if it's still rendering everything first then cutting out the pieces.
|
The current implementation doesn't really seem like what we discussed, specifically I thought the idea was that we would keep track of the items that are in the viewport and load (and unload) a buffer around that but here it seems like we are just continuously loading more models and only ever loading items from the bottom. I'll have a go at changing the implementation. |
Right, I wanted to get the loading part right before trying to add the unload/buffer part, but if I'd appreciate you having a go at the implementation. |
Okay, I think this implementation works pretty well. There's a couple things left to do:
|
Another todo(?) is to connect setting visible objects and scrolling to those visible objects, e.g. But I'm wondering what happens if |
Cannot reproduce your browser issues, and yes, visible_objects should be readonly. |
Another idea is to set an int param |
What are you trying to solve for with that? At minimum we would need the first and last. |
I guess we already have a scroll_position, but perhaps we should have a scroll_index. Do we need the first and last? I thought it's just |
After testing integrating Feed to ChatFeed, I had to cover some edge cases where:
I think this is ready to be merged after your final review. Here's the trapping in action (before the fixes): Screen.Recording.2024-02-02.at.11.31.16.AM.movThe after fix: |
Closes #6021
Sets up the plumbing to add a Logs layout, for the internal _chat_log inside
ChatFeed
.See bottom for demo.