Skip to content

Commit

Permalink
Remove dtypes layout definition; use layout.py
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 444634575
  • Loading branch information
iftenney authored and LIT team committed Apr 26, 2022
1 parent 05824c8 commit d3d19d2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
32 changes: 0 additions & 32 deletions lit_nlp/api/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,35 +120,3 @@ class SequenceSalienceMap(DataTuple):
# <float>[num_tokens_out, num_tokens_in + num_tokens_out]
salience: Sequence[Sequence[float]] # usually, a np.ndarray


##
# DEPRECATED layout class definitions for compatibility. New uses should use
# the versions in layout.py, which enable type checking of module names.
# TODO(b/205853382): remove once all references to LitComponentLayout are
# updated.
# pylint: disable=invalid-name
@attr.s(auto_attribs=True)
class LayoutSettings(DataTuple):
hideToolbar: bool = False
mainHeight: int = 45
centerPage: bool = False


# TODO(b/205853382): remove this once all references are updated.
@attr.s(auto_attribs=True)
class LitComponentLayout(DataTuple):
"""Frontend UI layout (legacy); should match client/lib/types.ts."""
# Keys are names of tabs; one must be called "Main".
# Values are names of LitModule HTML elements,
# e.g. data-table-module for the DataTableModule class.
components: Dict[str, List[str]]
layoutSettings: LayoutSettings = attr.ib(factory=LayoutSettings)
description: Optional[str] = None

def to_json(self) -> JsonDict:
"""Override serialization to properly convert nested objects."""
# Not invertible, but these only go from server -> frontend anyway.
return attr.asdict(self, recurse=True)


# pylint: enable=invalid-name
6 changes: 2 additions & 4 deletions lit_nlp/api/layout.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ def to_json(self) -> JsonDict:
return attr.asdict(self, recurse=True)


# TODO(b/205853382): remove dtypes.LitComponentLayout once references are
# updated.
LitComponentLayouts = Mapping[str, Union[LitComponentLayout, LitCanonicalLayout,
dtypes.LitComponentLayout]]
LitComponentLayouts = Mapping[str, Union[LitComponentLayout,
LitCanonicalLayout]]

# pylint: enable=invalid-name
# LINT.ThenChange(../client/lib/types.ts)

0 comments on commit d3d19d2

Please sign in to comment.