Skip to content

Commit

Permalink
Add fields that are already supported in the underlying typescript ty…
Browse files Browse the repository at this point in the history
…pes to the node data builder.
  • Loading branch information
jinjingforever committed Dec 10, 2024
1 parent a7da313 commit ec7d82d
Showing 1 changed file with 48 additions and 1 deletion.
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


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

0 comments on commit ec7d82d

Please sign in to comment.