-
Notifications
You must be signed in to change notification settings - Fork 80
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
fix: Allow LayoutHints to be accessible from Python, TreeTables #5543
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
py/server/deephaven/table.py
Outdated
column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: | ||
""" Sets layout hints on the Table |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes true - I should also add to TreeTable
as well, not just rollup...
@@ -251,6 +251,66 @@ def with_filters(self, filters: Union[str, Filter, Sequence[str], Sequence[Filte | |||
except Exception as e: | |||
raise DHError(e, "with_filters operation on RollupTable failed.") from e | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table: | |
column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> RollupTable: |
@@ -343,6 +403,65 @@ def with_filters(self, filters: Union[str, Filter, Sequence[str], Sequence[Filte | |||
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, | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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? |
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.
Reviewed Python
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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...)
@@ -251,6 +251,66 @@ def with_filters(self, filters: Union[str, Filter, Sequence[str], Sequence[Filte | |||
except Exception as e: | |||
raise DHError(e, "with_filters operation on RollupTable failed.") from e | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.
See typehint comment above.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably error if there are other keys in the dict. e.g. a misspelling.
@@ -343,6 +403,65 @@ def with_filters(self, filters: Union[str, Filter, Sequence[str], Sequence[Filte | |||
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, |
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.
apply other comments here
return TreeTable(j_tree_table=self.j_tree_table.setLayoutHints(_j_layout_hint_builder.build()), | ||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should PartitionedTable
or PartitionedTableProxy
also have this method?
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.
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_hints
onTreeTable
,RollupTable
in Python #5554Tested with the following snippet: