fix: Allow LayoutHints to be accessible from Python, TreeTables#5543
fix: Allow LayoutHints to be accessible from Python, TreeTables#5543mofojed wants to merge 2 commits intodeephaven:mainfrom
Conversation
- Related to Enterprise ticket DH-17076, which has been identified as a Blocker by support - Groovy had setLayoutHints exposed on TreeTables, but was not exposed through JsTreeTable and was also not accessible through Python - Added layoutHints to JsTreeTable, and exposed layout_hints through Python - Will have a follow up UI change as well to read the layout hints correctly from a JsTreeTable
- Related to DH-17076 - Needed a Core patch: deephaven/deephaven-core#5543 - Tested using both the Python and Groovy snippets from the ticket - Fixes deephaven#2035
| column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: | ||
| """ Sets layout hints on the Table |
There was a problem hiding this comment.
Should it be a TreeTable or RollupTable? Either way, some of the typehints/docstring/messages need to reflect that.
There was a problem hiding this comment.
Yes true - I should also add to TreeTable as well, not just rollup...
|
|
||
| def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, List[str]] = None, | ||
| freeze: Union[str, List[str]] = None, hide: Union[str, List[str]] = None, | ||
| column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: |
There was a problem hiding this comment.
| column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: | |
| column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> RollupTable: |
|
|
||
| def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, List[str]] = None, | ||
| freeze: Union[str, List[str]] = None, hide: Union[str, List[str]] = None, | ||
| column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: |
There was a problem hiding this comment.
| column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: | |
| column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> TreeTable: |
|
Do we need some basic test cases? |
| Args: | ||
| front (Union[str, List[str]]): the columns to show at the front. | ||
| back (Union[str, List[str]]): the columns to show at the back. | ||
| freeze (Union[str, List[str]]): the columns to freeze to the front. |
There was a problem hiding this comment.
This leaves a lot of questions for me:
- Is this separate from
front? - Do the frozen columns appear before the front columns?
- Do the frozen columns need to be listed in the front columns?
There was a problem hiding this comment.
I just copied these from the existing layout_hints method that is already on Table. Should I make updates there as well?
I'm just trying to get this supposed Enterprise blocker completed. Didn't expect/need to refactor a whole bunch of APIs, as this is supposed to be a hotfix - trying to change as little as possible, while just exposing this functionality in Python (though they did only ask about Groovy...)
|
|
||
| def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, List[str]] = None, | ||
| freeze: Union[str, List[str]] = None, hide: Union[str, List[str]] = None, | ||
| column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: |
There was a problem hiding this comment.
dict isn't a great type hint because it doesn't indicate the contents of the dict. It should include the acceptable key and value types.
| freeze (Union[str, List[str]]): the columns to freeze to the front. | ||
| These will not be affected by horizontal scrolling. | ||
| hide (Union[str, List[str]]): the columns to hide. | ||
| column_groups (List[Dict]): A list of dicts specifying which columns should be grouped in the UI. |
| freeze (Union[str, List[str]]): the columns to freeze to the front. | ||
| These will not be affected by horizontal scrolling. | ||
| hide (Union[str, List[str]]): the columns to hide. | ||
| column_groups (List[Dict]): A list of dicts specifying which columns should be grouped in the UI. |
There was a problem hiding this comment.
What does "grouped in the UI" mean?
| The dicts can specify the following: | ||
|
|
||
| * name (str): The group name | ||
| * children (List[str]): The column names in the group | ||
| * color (Optional[str]): The hex color string or Deephaven color name |
There was a problem hiding this comment.
This is very unclear. e.g. is name the dict key? are children and color values? etc.
| def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, List[str]] = None, | ||
| freeze: Union[str, List[str]] = None, hide: Union[str, List[str]] = None, | ||
| column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: | ||
| """ Sets layout hints on the RollupTable |
There was a problem hiding this comment.
Pydocs do not mention the default behaviors.
| _j_layout_hint_builder.columnGroup(group.get("name"), j_array_list(group.get("children")), | ||
| group.get("color", "")) |
There was a problem hiding this comment.
This should probably error if there are other keys in the dict. e.g. a misspelling.
| except Exception as e: | ||
| raise DHError(e, "with_filters operation on TreeTable failed.") from e | ||
|
|
||
| def layout_hints(self, front: Union[str, List[str]] = None, back: Union[str, List[str]] = None, |
| id_col=self.id_col, parent_col=self.parent_col) | ||
| except Exception as e: | ||
| raise DHError(e, "failed to set layout hints on tree table") from e | ||
|
|
There was a problem hiding this comment.
Should PartitionedTable or PartitionedTableProxy also have this method?
There was a problem hiding this comment.
Those classes don't extend GridAttributes which has the setLayoutHints method defined in Java.
Seems like ticket #2890 (comment) is related
|
I'm going to refactor the JS API part out of this as that's all that's technically required for DH-17076. I've opened a new ticket #5554 to address the inconsistency between Python/Groovy implementations of layout hints, and linked this PR as a fix, but I'm not going to continue work on this PR. |
layout_hintsonTreeTable,RollupTablein Python #5554Tested with the following snippet: