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

fix: Allow LayoutHints to be accessible from Python, TreeTables #5543

Closed
wants to merge 2 commits into from

Conversation

mofojed
Copy link
Member

@mofojed mofojed commented May 29, 2024

  • 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 (they were already accessible through Groovy)
  • Will have a follow up UI change as well to read the layout hints correctly from a JsTreeTable
  • Fixes Expose layout_hints on TreeTable, RollupTable in Python #5554

Tested with the following snippet:

# For RollupTable
from deephaven import empty_table, agg
source = empty_table(100).update(["K1 = ii", "K2=K1%10", "Y=randomDouble(0, 10)", "Z=randomDouble(0, 10)"])
result_norollup = source.layout_hints(column_groups=[{"name": "MyCols", "children": ["Y", "Z"]}])
result_rollup = source.rollup([agg.avg(["Y", "Z"])], "K2", False).layout_hints(column_groups=[{"name": "MyCols", "children": ["Y", "Z"]}])

# For TreeTable
from deephaven.constants import NULL_INT
from deephaven import empty_table

source2 = empty_table(100).update_view(
    ["ID = i", "Parent = i == 0 ? NULL_INT : (int)(i / 4)", "X=Math.sin(i)", "Y=Math.cos(i)"]
)

result2_tree = source2.tree(id_col="ID", parent_col="Parent").layout_hints(column_groups=[{"name": "Trig", "children": ["X", "Y"]}])

- 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
@mofojed mofojed added NoDocumentationNeeded NoReleaseNotesNeeded No release notes are needed. labels May 29, 2024
@mofojed mofojed self-assigned this May 29, 2024
mofojed added a commit to mofojed/web-client-ui that referenced this pull request May 29, 2024
- 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
@mofojed mofojed requested a review from niloc132 May 29, 2024 21:44
niloc132
niloc132 previously approved these changes May 30, 2024
Comment on lines 256 to 257
column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table:
""" Sets layout hints on the Table
Copy link
Contributor

@jmao-denver jmao-denver May 30, 2024

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.

Copy link
Member Author

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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> Table:
column_groups: List[dict] = None, search_display_mode: SearchDisplayMode = None) -> TreeTable:

@jmao-denver
Copy link
Contributor

Do we need some basic test cases?

Copy link
Member

@chipkent chipkent left a 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.
Copy link
Member

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:

  1. Is this separate from front?
  2. Do the frozen columns appear before the front columns?
  3. Do the frozen columns need to be listed in the front columns?

Copy link
Member Author

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:
Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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?

Comment on lines +266 to +270
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
Copy link
Member

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
Copy link
Member

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.

Comment on lines +299 to +300
_j_layout_hint_builder.columnGroup(group.get("name"), j_array_list(group.get("children")),
group.get("color", ""))
Copy link
Member

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,
Copy link
Member

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

Copy link
Member

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?

Copy link
Member Author

@mofojed mofojed Jun 2, 2024

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

@mofojed
Copy link
Member Author

mofojed commented Jun 2, 2024

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.
I've opened PR #5555 to address just the JS API portion, which is required for DH-17076 to be resolved.

@mofojed mofojed closed this Jun 2, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jun 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose layout_hints on TreeTable, RollupTable in Python
4 participants