Skip to content
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

In the Tabulator of panel 1.3.2, using HTMLTemplateFormatter for the Index now raises an exception. #5915

Closed
kuri-menu opened this issue Nov 24, 2023 · 3 comments · Fixed by #5922
Milestone

Comments

@kuri-menu
Copy link

It worked fine in panel 1.3.1

ALL software version info

Windows 10 python 3.11.6

bokeh 3.3.1
holoviews 1.18.1
panel 1.3.2
param 2.0.1
jupyter-bokeh 3.0.7
jupyter_client 7.4.9
jupyter_core 5.3.1
jupyter-events 0.6.3
jupyter-lsp 2.2.0
jupyter_server 2.5.0
jupyter_server_terminals 0.4.4
jupyterlab 4.0.9
jupyterlab-pygments 0.2.2
jupyterlab_server 2.23.0
jupyterlab-widgets 3.0.8
ipykernel 6.24.0

Description of expected behavior and the observed behavior

Complete, minimal, self-contained example code that reproduces the issue


from bokeh.models.widgets.tables import HTMLTemplateFormatter
import panel as pn
pn.extension('tabulator')

df = pd.DataFrame(
    {
        'A':[1,2,3],
        'B':[1,2,3],
    }
)
df = df.set_index('A')

tabu = pn.widgets.Tabulator(
    df,
    formatters=dict(
        A=HTMLTemplateFormatter(template='<a href="https://www.google.com/search?code=<%= value %>"><%= value %></a>'),
    ),
)
tabu

Stack traceback and/or browser JavaScript console output


AttributeError Traceback (most recent call last)
File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\IPython\core\formatters.py:974, in MimeBundleFormatter.call(self, obj, include, exclude)
971 method = get_real_method(obj, self.print_method)
973 if method is not None:
--> 974 return method(include=include, exclude=exclude)
975 return None
976 else:

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\panel\viewable.py:774, in Viewable.repr_mimebundle(self, include, exclude)
771 loaded = hv.extension._loaded
773 if config.comms in ('vscode', 'ipywidgets'):
--> 774 widget = ipywidget(self)
775 if hasattr(widget, 'repr_mimebundle'):
776 return widget.repr_mimebundle(include=include, exclude=exclude), {}

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\panel\io\notebook.py:527, in ipywidget(obj, doc, **kwargs)
525 from ..pane import panel
526 doc = doc if doc else Document()
--> 527 model = panel(obj, **kwargs).get_root(doc=doc)
528 widget = BokehModel(model, combine_events=True)
529 if hasattr(widget, '_view_count'):

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\panel\viewable.py:670, in Renderable.get_root(self, doc, comm, preprocess)
668 root_view = wrapper
669 else:
--> 670 root = self._get_model(doc, comm=comm)
671 root_view = self
672 if preprocess:

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\panel\widgets\tables.py:1679, in Tabulator._get_model(self, doc, root, parent, comm)
1672 def _get_model(
1673 self, doc: Document, root: Optional[Model] = None,
1674 parent: Optional[Model] = None, comm: Optional[Comm] = None
1675 ) -> Model:
1676 Tabulator._widget_type = lazy_load(
1677 'panel.models.tabulator', 'DataTabulator', isinstance(comm, JupyterComm), root
1678 )
-> 1679 model = super()._get_model(doc, root, parent, comm)
1680 root = root or model
1681 self._child_panels = child_panels = self._get_children()

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\panel\widgets\tables.py:334, in BaseTable._get_model(self, doc, root, parent, comm)
330 def _get_model(
331 self, doc: Document, root: Optional[Model] = None,
332 parent: Optional[Model] = None, comm: Optional[Comm] = None
333 ) -> Model:
--> 334 properties = self._get_properties(doc)
335 model = self._widget_type(**properties)
336 root = root or model

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\panel\widgets\tables.py:1637, in Tabulator._get_properties(self, doc)
1636 def _get_properties(self, doc: Document) -> Dict[str, Any]:
-> 1637 properties = super()._get_properties(doc)
1638 properties['configuration'] = self._get_configuration(properties['columns'])
1639 properties['cell_styles'] = self._get_style_data()

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\panel\widgets\tables.py:325, in BaseTable._get_properties(self, doc)
323 def _get_properties(self, doc: Document) -> Dict[str, Any]:
324 properties = super()._get_properties(doc)
--> 325 properties['columns'] = self._get_columns()
326 properties['source'] = cds = ColumnDataSource(data=self._data)
327 cds.selected.indices = self.selection

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\panel\widgets\tables.py:161, in BaseTable._get_columns(self)
159 fields = self._get_fields()
160 df = self.value.reset_index() if len(indexes) > 1 else self.value
--> 161 return self._get_column_definitions(fields, df)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\panel\widgets\tables.py:238, in BaseTable._get_column_definitions(self, col_names, df)
236 warn(msg, RuntimeWarning)
237 elif col in self.indexes:
--> 238 formatter.text_align = 'left'
240 if isinstance(self.widths, int):
241 col_kwargs['width'] = self.widths

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\bokeh\core\has_props.py:340, in HasProps.setattr(self, name, value)
337 if isinstance(descriptor, property): # Python property
338 return super().setattr(name, value)
--> 340 self._raise_attribute_error_with_matches(name, properties)

File ~\AppData\Local\Programs\Python\Python311\Lib\site-packages\bokeh\core\has_props.py:375, in HasProps._raise_attribute_error_with_matches(self, name, properties)
372 if not matches:
373 matches, text = sorted(properties), "possible"
--> 375 raise AttributeError(f"unexpected attribute {name!r} to {self.class.name}, {text} attributes are {nice_join(matches)}")

AttributeError: unexpected attribute 'text_align' to HTMLTemplateFormatter, possible attributes are js_event_callbacks, js_property_callbacks, name, subscribed_events, syncable, tags or template

@hoxbro
Copy link
Member

hoxbro commented Nov 24, 2023

Introduced in #5866

Are you up for trying to fix this regression?

@kuri-menu
Copy link
Author

I am unable to fix this regression.

@philippjfr philippjfr added this to the v1.4.0 milestone Nov 26, 2023
@philippjfr
Copy link
Member

May need a quick followup release (i.e. 1.3.3) for this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants