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

Add fields that are already supported in the underlying typescript types to the node data builder. #264

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 48 additions & 1 deletion src/server/package/src/model_explorer/node_data_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import json
import os
from dataclasses import asdict, dataclass, field
from typing import Union
from typing import Literal, Union

from .utils import remove_none

Expand Down Expand Up @@ -92,6 +92,50 @@ class GraphNodeData:
# (optional)
gradient: list['GradientItem'] = field(default_factory=list)

# Whether to hide the corresponding column in aggregated stats table
# (the first table).
#
# If all columns in that table are hidden, the whole table will be hidden.
#
# (optional)
hideInAggregatedStatsTable: bool = False

# Whether to hide the corresponding column in children stats table
# (the second table).
#
# If all columns in that table are hidden, the whole table will be hidden.
#
# (optional)
hideInChildrenStatsTable: bool = False

# The stats to hide in the aggregated stats table (the first table).
#
# The value for the hidden stat will be displayed as '-'.
#
# (optional)
hideAggregatedStats: Union[None, list['AggregatedStat']] = None

# Controls whether to display a detailed value distribution summary on the
# group node.
#
# By default, a color bar representing the value distribution of
# all descendant nodes is shown at the bottom of the group node. If this
# field is set to true, we will show a more detailed summary, with each
# value's label, percentage, and count shown on a separate line.
#
# For now this only works with non-numerical (e.g. string) node data values.
#
# (optional)
showExpandedSummaryOnGroupNode: bool = False

# Whether to display the label count columns in the children stats table in
# the side panel.
#
# For now this only works with non-numerical (e.g. string) node data values.
#
# (optional)
showLabelCountColumnsInChildrenStatsTable: bool = False

def save_to_file(self, path: str, indent: Union[int, None] = 2) -> None:
"""Writes the data into the given file."""
abs_path = os.path.abspath(os.path.expanduser(path))
Expand Down Expand Up @@ -173,3 +217,6 @@ class GradientItem:
#
# (optional)
textColor: Union[str, None] = None


AggregatedStat = Literal['min', 'max', 'sum', 'avg']
Loading