Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/holoviz/panel into docs_fix…
Browse files Browse the repository at this point in the history
…es_1.4_a1_review
  • Loading branch information
MarcSkovMadsen committed Feb 6, 2024
2 parents 09b9898 + f9acf5f commit 90730f4
Show file tree
Hide file tree
Showing 29 changed files with 778 additions and 80 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Enjoying Panel? Show your support with a [Github star](https://github.com/holovi
<table>
<tbody>
<tr>
<td>Downloads</td>
<td><a href="https://pypistats.org/packages/panel" alt="PyPi Downloads"><img src="https://img.shields.io/pypi/dm/panel?label=pypi" /></a> <a href="https://anaconda.org/pyviz/panel" alt="Conda Downloads"><img src="https://pyviz.org/_static/cache/panel_conda_downloads_badge.svg" /></a></td>
</tr>
<tr>
<td>Build Status</td>
<td><a href="https://github.com/holoviz/panel/actions/workflows/test.yaml?query=branch%3Amain"><img src="https://github.com/holoviz/panel/workflows/tests/badge.svg?query=branch%3Amain" alt="Linux/MacOS Build Status"></a></td>
</tr>
Expand Down Expand Up @@ -65,7 +69,7 @@ Panel works really well with the visualization tools you already know and love l

Panel provides bi-directional communication making it possible to react to clicks, selections, hover etc. events.

[![Vega Selections](https://blog.holoviz.org/images/vega_selection.gif)](https://panel.holoviz.org/reference/panes/Vega.html)
[![Vega Selections](https://assets.holoviz.org/panel/readme/vega_selections.gif)](https://panel.holoviz.org/reference/panes/Vega.html)

You can develop in [Jupyter Notebooks](http://jupyter.org) as well as editors like [VS Code](https://code.visualstudio.com/), [PyCharm](https://www.jetbrains.com/pycharm/) or [Spyder](https://www.spyder-ide.org/).

Expand Down Expand Up @@ -165,7 +169,9 @@ panel serve name_of_notebook.ipynb --show

[![Panel Gallery](https://assets.holoviz.org/panel/readme/gallery.jpg)](https://panel.holoviz.org/gallery/index.html)

[![Awesome Panel Gallery](https://assets.holoviz.org/panel/readme/awesome_panel.jpg)](https://www.awesome-panel.org/gallery?theme=default)
[![Panel Chat Examples](https://assets.holoviz.org/panel/readme/panel-chat-examples.jpg)](https://holoviz-topics.github.io/panel-chat-examples/)

[![Awesome Panel Gallery](https://assets.holoviz.org/panel/readme/awesome_panel.jpg)](https://www.awesome-panel.org)

## Get started

Expand Down
4 changes: 4 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ def get_requirements():
# Override the Sphinx default title that appends `documentation`
html_title = f'{project} v{version}'

# Ensure the global version string includes the SHA to ensure the service
# worker is invalidated on builds between tags
if is_dev:
version = panel.__version__

# Patching GridItemCardDirective to be able to substitute the domain name
# in the link option.
Expand Down
16 changes: 4 additions & 12 deletions doc/gallery/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ A large selection of chat applications showcasing Panels chat components.
::::{grid} 1 2 2 3
:gutter: 1 1 1 2

:::{grid-item-card} awesome-panel.org Gallery
:img-top: https://assets.holoviz.org/panel/gallery/community/awesome_gallery.png
:link: https://awesome-panel.org/gallery
:::{grid-item-card} awesome-panel.org
:img-top: https://assets.holoviz.org/panel/gallery/community/awesome-panel.png
:link: https://awesome-panel.org
:link-type: url

A great selection of applications showcasing various features of Panel built and maintained by Marc Skov Madsen.
A great selection of applications and other resources showcasing various features of Panel.
:::

:::{grid-item-card} cuxfilter
Expand All @@ -225,14 +225,6 @@ A great selection of applications showcasing various features of Panel built and
cuxfilter ( ku-cross-filter ) is a RAPIDS framework to connect web visualizations to GPU accelerated crossfiltering which is built on top of Panel.
:::

:::{grid-item-card} awesome-panel.org Community Gallery
:img-top: https://assets.holoviz.org/panel/gallery/community/awesome_community.png
:link: https://awesome-panel.org/awesome_list
:link-type: url

A list of applications, videos and blog posts about Panel built by the community, curated by Marc Skov Madsen.
:::

:::{grid-item-card} AstronomicalAL
:img-top: https://assets.holoviz.org/panel/gallery/community/AstronomicAL.png
:link: https://github.com/grant-m-s/AstronomicAL
Expand Down
2 changes: 1 addition & 1 deletion doc/how_to/callbacks/load.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Defer Long Running Tasks to Improve the User Experience

This guide addresses how to defer and orchestrate long running background tasks with `pn.state.on_load`. You can use this to improve the user experience of your app.
This guide addresses how to defer and orchestrate long running background tasks with `pn.state.onload`. You can use this to improve the user experience of your app.

---

Expand Down
45 changes: 23 additions & 22 deletions examples/gallery/anaconda-project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,30 @@ variables:
PYVISTA_OFF_SCREEN: "true"

packages:
- panel
- holoviews
- pandas
- scikit-learn
- scikit-image
- fastparquet
- hvplot
- datashader
- graphviz
- networkx
- ipywidgets
- pygraphviz
- plotly
- altair
- pydeck
- pyvista
- seaborn
- xgboost
- python >=3.10.13
- panel >=1.4.0a1
- holoviews >=1.18.2a6
- pandas >=2.2.0
- scikit-learn >=1.4.0
- scikit-image >=0.22.0
- fastparquet >=2023.10.1
- hvplot >=0.9.2
- datashader >=0.16.1a1
- graphviz >=8.1.0
- networkx >=3.2.1
- ipywidgets >=8.1.1
- pygraphviz >=1.11
- plotly >=5.18.0
- altair >=5.2.0
- pydeck >=0.8.0
- pyvista >=0.43.2
- seaborn >=0.13.2
- xgboost >=2.0.3
- vtk=9.2.6=osmesa_py310h7f736e2_103
- pyvista
- mesalib
- numpy<1.24
- numba::llvmlite
- pyvista >=0.43.2
- mesalib >=24.0.0
- numpy >=1.23.5,<1.24
- numba::llvmlite >=0.42.0
- pip:
- ipyvolume
- folium
Expand Down
6 changes: 3 additions & 3 deletions examples/reference/layouts/Column.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
"\n",
"* **``objects``** (list): The list of objects to display in the Column, should not generally be modified directly except when replaced in its entirety.\n",
"* **``scroll``** (boolean): Enable scrollbars if the content overflows the size of the container.\n",
"* **``scroll_position``** (int): Current scroll position of the Column. Setting this value will update the scroll position of the Column. Setting to 0 will scroll to the top.\"\"\"\n",
"* **``scroll_position``** (int): Current scroll position of the Column. Setting this value will update the scroll position of the Column. Setting to 0 will scroll to the top.\n",
"* **``auto_scroll_limit``** (int): Max pixel distance from the latest object in the Column to activate automatic scrolling upon update. Setting to 0 disables auto-scrolling\n",
"* **``scroll_button_threshold``** (int): Min pixel distance from the latest object in the Column to display the scroll button. Setting to 0 disables the scroll button.\"\"\"\n",
"* **``view_latest``** (bool): Whether to scroll to the latest object on init. If not enabled the view will be on the first object.\"\"\"\n",
"* **``scroll_button_threshold``** (int): Min pixel distance from the latest object in the Column to display the scroll button. Setting to 0 disables the scroll button.\n",
"* **``view_latest``** (bool): Whether to scroll to the latest object on init. If not enabled the view will be on the first object.\n",
"___"
]
},
Expand Down
98 changes: 98 additions & 0 deletions examples/reference/layouts/Feed.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import panel as pn\n",
"pn.extension()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The ``Feed`` inherits from the `Column` layout, thus allows arranging multiple panel objects in a vertical container, but limits the number of objects rendered at any given moment.\n",
"\n",
"Like `Column`, it has a list-like API with methods to ``append``, ``extend``, ``clear``, ``insert``, ``pop``, ``remove`` and ``__setitem__``, which make it possible to interactively update and modify the layout.\n",
"\n",
"#### Parameters:\n",
"\n",
"For details on other options for customizing the component see the [layout](../../how_to/layout/index.md) and [styling](../../how_to/styling/index.md) how-to guides.\n",
"\n",
"* **``objects``** (list): The list of objects to display in the Feed, should not generally be modified directly except when replaced in its entirety.\n",
"* **``load_buffer``** (int): The number of objects loaded on each side of the visible objects. When scrolled halfway into the buffer, the Feed will automatically load additional objects while unloading objects on the opposite side.\n",
"* **``scroll``** (boolean): Enable scrollbars if the content overflows the size of the container.\n",
"* **``scroll_position``** (int): Current scroll position of the Feed. Setting this value will update the scroll position of the Column. Setting to 0 will scroll to the top.\n",
"* **``auto_scroll_limit``** (int): Max pixel distance from the latest object in the Feed to activate automatic scrolling upon update. Setting to 0 disables auto-scrolling\n",
"* **``scroll_button_threshold``** (int): Min pixel distance from the latest object in the Feed to display the scroll button. Setting to 0 disables the scroll button.\n",
"* **``view_latest``** (bool): Whether to scroll to the latest object on init. If not enabled the view will be on the first object.\n",
"* **``visible_range``** (list): Read-only upper and lower bounds of the currently visible Feed objects. This list is automatically updated based on scrolling.\n",
"___"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"`Feed` is a `Column-like` layout that displays a Feed of objects. It is useful for displaying long outputs with many rows because of its ability to limit the number of entries loaded at once.\n",
"\n",
"When scrolled halfway into the `load_buffer`, the Feed will automatically load additional entries while unloading entries on the opposite side."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Feed = pn.Feed(*list(range(1000)), load_buffer=20)\n",
"Feed"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"To have the Feeds immediately initialized at the latest entry, set `view_latest=True`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Feed = pn.Feed(*list(range(1000)), view_latest=True)\n",
"Feed"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Additionally, to allow users to scroll to the bottom interactively, set a `scroll_button_threshold` which will make the Feed display a clickable scroll button."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"Feed = pn.Feed(*list(range(1000)), scroll_button_threshold=20, width=300)\n",
"Feed"
]
}
],
"metadata": {
"language_info": {
"name": "python",
"pygments_lexer": "ipython3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
8 changes: 6 additions & 2 deletions panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
from . import param # noqa
from . import pipeline # noqa
from . import reactive # noqa
from . import template # noqa
from . import viewable # noqa
from . import widgets # noqa
from .config import __version__, config, panel_extension as extension # noqa
Expand All @@ -63,8 +64,8 @@
_jupyter_server_extension_paths, cache, ipywidget, serve, state,
)
from .layout import ( # noqa
Accordion, Card, Column, FlexBox, FloatPanel, GridBox, GridSpec, GridStack,
HSpacer, Row, Spacer, Swipe, Tabs, VSpacer, WidgetBox,
Accordion, Card, Column, Feed, FlexBox, FloatPanel, GridBox, GridSpec,
GridStack, HSpacer, Row, Spacer, Swipe, Tabs, VSpacer, WidgetBox,
)
from .pane import panel # noqa
from .param import Param, ReactiveExpr # noqa
Expand All @@ -77,6 +78,7 @@
"Card",
"chat",
"Column",
"Feed",
"FlexBox",
"FloatPanel",
"GridBox",
Expand All @@ -87,6 +89,7 @@
"ReactiveExpr",
"Row",
"Spacer",
"Swipe",
"Tabs",
"Template",
"VSpacer",
Expand All @@ -108,6 +111,7 @@
"rx",
"serve",
"state",
"template",
"viewable",
"widgets",
"widget"
Expand Down
4 changes: 2 additions & 2 deletions panel/chat/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ def __init__(self, *objects, **params):

# forward message params to ChatMessage for convenience
message_params = params.get("message_params", {})
for param_key in list(params.keys()):
if param_key not in ChatFeed.param and param_key in ChatMessage.param:
for param_key in params.copy():
if param_key not in self.param and param_key in ChatMessage.param:
message_params[param_key] = params.pop(param_key)
params["message_params"] = message_params

Expand Down
75 changes: 75 additions & 0 deletions panel/chat/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,3 +597,78 @@ async def _cleanup_response(self):
"""
await super()._cleanup_response()
await self._update_input_disabled()


def send(
self,
value: ChatMessage | dict | Any,
user: str | None = None,
avatar: str | bytes | BytesIO | None = None,
respond: bool = True,
) -> ChatMessage | None:
"""
Sends a value and creates a new message in the chat log.
If `respond` is `True`, additionally executes the callback, if provided.
Arguments
---------
value : ChatMessage | dict | Any
The message contents to send.
user : str | None
The user to send as; overrides the message message's user if provided.
Will default to the user parameter.
avatar : str | bytes | BytesIO | None
The avatar to use; overrides the message message's avatar if provided.
Will default to the avatar parameter.
respond : bool
Whether to execute the callback.
Returns
-------
The message that was created.
"""
if not isinstance(value, ChatMessage):
if user is None:
user = self.user
if avatar is None:
avatar = self.avatar
return super().send(value, user=user, avatar=avatar, respond=respond)

def stream(
self,
value: str,
user: str | None = None,
avatar: str | bytes | BytesIO | None = None,
message: ChatMessage | None = None,
replace: bool = False,
) -> ChatMessage | None:
"""
Streams a token and updates the provided message, if provided.
Otherwise creates a new message in the chat log, so be sure the
returned message is passed back into the method, e.g.
`message = chat.stream(token, message=message)`.
This method is primarily for outputs that are not generators--
notably LangChain. For most cases, use the send method instead.
Arguments
---------
value : str | dict | ChatMessage
The new token value to stream.
user : str | None
The user to stream as; overrides the message's user if provided.
Will default to the user parameter.
avatar : str | bytes | BytesIO | None
The avatar to use; overrides the message's avatar if provided.
Will default to the avatar parameter.
message : ChatMessage | None
The message to update.
replace : bool
Whether to replace the existing text when streaming a string or dict.
Returns
-------
The message that was updated.
"""
return super().stream(value, user=user or self.user, avatar=avatar or self.avatar, message=message, replace=replace)
Loading

0 comments on commit 90730f4

Please sign in to comment.