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

v0.5 Release #969

Merged
merged 394 commits into from
Dec 2, 2022
Merged
Changes from 1 commit
Commits
Show all changes
394 commits
Select commit Hold shift + click to select a range
1d1c3dd
Update environment.yml
aryan1107 Jun 21, 2022
7dc03f1
Cleaning
aryan1107 Jun 21, 2022
82860cc
Transformers 4.5.0 doesn't work for FlaxBertForQuestionAnswering usin…
aryan1107 Jun 21, 2022
ccd47cc
Saving work
aryan1107 Jun 21, 2022
35417b2
TyDi Demo : Trying to add attentions and embeddings
aryan1107 Jun 21, 2022
9ff6f36
TyDi Model: Shows Generated text & Scalar score
aryan1107 Jun 21, 2022
c4269e3
Update tydi.py
aryan1107 Jun 21, 2022
0558ef5
Fix AUC/AUCPR metrics calculation; support binary classification task…
cjqian Jun 23, 2022
ed30b23
Updates! Please ignore dalle files
aryan1107 Jun 23, 2022
5df8588
Removed dalle-mini for separate branch
aryan1107 Jun 23, 2022
26fd3df
Generated output to show context instead of question
aryan1107 Jun 23, 2022
a6c039d
MultiSegmentAnnotations
aryan1107 Jun 24, 2022
0b9998e
Update tydi.py
aryan1107 Jun 24, 2022
0ae6a8f
Update question_answering.py
aryan1107 Jun 24, 2022
5889bcd
Update question_answering.py
aryan1107 Jun 24, 2022
2774650
Other languages added!
aryan1107 Jun 26, 2022
6699735
Annotated Text (gold)
aryan1107 Jun 26, 2022
a28f203
Adds tab bar position preset buttons and reduces drag jitter.
RyanMullins Jun 28, 2022
3f2ae88
Metrics Update
aryan1107 Jun 28, 2022
5bb0c65
Update after new feedback! & Metrics
aryan1107 Jun 28, 2022
9a1198d
Display MultiSegmentAnnotations as a comma-separated list in DataTable
RyanMullins Jun 29, 2022
dad8edb
Fixes bug in use of regression and classification source prefixes in
RyanMullins Jun 29, 2022
ecddf59
Merge pull request #4 from PAIR-code/dev
aryan1107 Jun 29, 2022
db1ef3d
Refactor backend types based on shared attributes.
cjqian Jun 30, 2022
c85e556
Add initial class-based LitTypes module and tests.
cjqian Jun 30, 2022
9026a67
Non-editable display formatting for MultiSegmentAnnotations in Datapo…
RyanMullins Jul 1, 2022
f11a242
Merge pull request #5 from PAIR-code/dev
aryan1107 Jul 1, 2022
0cda2a5
Adds type check to CorpusBLEU metric.
RyanMullins Jul 1, 2022
f970958
Use more sensible default values for settings in the clustering module.
eberts-google Jul 6, 2022
99105f7
Merge pull request #6 from PAIR-code/dev
aryan1107 Jul 6, 2022
ba36c67
Update .gitignore
RyanMullins Jul 6, 2022
0e665c0
Merge pull request #7 from PAIR-code/dev
aryan1107 Jul 7, 2022
b9b112c
Adds Python and TypeScript linters and docs
RyanMullins Jul 8, 2022
b8c1097
Adds VS Code settings based on Google's recommendations
RyanMullins Jul 8, 2022
660b8ef
Add utilities for class-based LitTypes.
cjqian Jul 8, 2022
db58fa4
Add another batch of class-based LitTypes and replace existing refere…
cjqian Jul 8, 2022
4b777d7
Better filtering in data table for different types
jameswex Jul 12, 2022
c020d25
Add final batch of class-based LitTypes and replace existing referenc…
cjqian Jul 12, 2022
eb02465
Replace dictionary-based `LitType` approximations with real class con…
cjqian Jul 12, 2022
f846772
Adds a color legend element and integrates it into the embedding proj…
jswong65 Jul 12, 2022
ed07199
Scalars now pulls data from the DataService.
RyanMullins Jul 12, 2022
ffc9996
Some initial updates to help scale # of datapoints usable in LIT.
jameswex Jul 13, 2022
4197a44
Merge pull request #9 from PAIR-code/dev
aryan1107 Jul 13, 2022
33fa5fe
Metrics Logging
aryan1107 Jul 14, 2022
37b15d7
Update app.py
aryan1107 Jul 15, 2022
aca35d8
Closes the onboarding docs dialog when you click the
RyanMullins Jul 18, 2022
6f4dd57
Makes LitCheckbox label clickable and adds tests
RyanMullins Jul 18, 2022
80f5d5d
Updates definition of tabular data and models in docs.
RyanMullins Jul 18, 2022
7a5e8e4
Merge pull request #10 from PAIR-code/dev
aryan1107 Jul 18, 2022
b43044e
Update metrics.py
aryan1107 Jul 18, 2022
4b861df
Metrics
aryan1107 Jul 18, 2022
dd60c3d
Update metrics.py
aryan1107 Jul 18, 2022
64c8b8f
Delete .DS_Store
aryan1107 Jul 18, 2022
e9ff91b
Fixed exact match metrics logic
RyanMullins Jul 19, 2022
d7f8ba8
import clean up
RyanMullins Jul 19, 2022
6baf09f
Added test and language categories for loading mixed dataset!
aryan1107 Jul 19, 2022
fb81dab
Update tydi.py
aryan1107 Jul 19, 2022
c1683ff
Updates Scalars to use .module-* class pattern.
RyanMullins Jul 20, 2022
0e2b8b8
Merge pull request #13 from PAIR-code/dev
aryan1107 Jul 20, 2022
72edd26
Rename String LitType to StringLitType.
cjqian Jul 21, 2022
65c5b8a
Rename remaining instances of `String` to `StringLitType`.
cjqian Jul 22, 2022
0d8341d
Improves robustness of Metrics compatibility checks.
RyanMullins Jul 22, 2022
abb8889
Add default `signed` value to Salience types.
cjqian Jul 22, 2022
0b83f4a
Store calculated numeric feature bins so as not to recalculate them c…
jameswex Jul 25, 2022
0e0d4aa
Merge pull request #15 from PAIR-code/dev
aryan1107 Jul 25, 2022
61596bd
merge conflict update!
aryan1107 Jul 26, 2022
4c93b62
Add boolean typing to ImageSalience's signed property.
cjqian Jul 26, 2022
3e8735b
Remove inaccurate comment about Dataset loading
iftenney Jul 27, 2022
8c6ac11
Replace hard-coded type approximations with references to the new cla…
cjqian Jul 27, 2022
2522e4f
Replace references to hard-coded `List` field types with references t…
cjqian Jul 27, 2022
0f8ff8e
Merge `isLitSubtype` and `findSpecKeys` implementations from `lit_typ…
cjqian Jul 27, 2022
58970de
Consolidate implementations of `createLitTypes` and migrate it into t…
cjqian Jul 27, 2022
4baf746
Merge pull request #17 from PAIR-code/dev
aryan1107 Jul 28, 2022
d12bcb3
Fixes #755. Tabular Feature Attribution Tutorial.
iamshnoo Jul 28, 2022
bb657ba
Pause module reactions and rendering when they are hidden.
jameswex Jul 28, 2022
d0ba035
Adding Multisegment Annotation support to Generated Text Module and V…
RyanMullins Jul 29, 2022
b165b28
Update remaining modules for render/reaction pausing.
jameswex Jul 29, 2022
ba7ad82
Merge pull request #18 from PAIR-code/dev
aryan1107 Jul 29, 2022
7ae9217
Revert "Adding Multisegment Annotation support to Generated Text Modu…
aryan1107 Jul 29, 2022
4dd6ee6
Revert "Merge pull request #18 from PAIR-code/dev"
aryan1107 Jul 29, 2022
afb2e04
Ryan's Generated Text Module update to latest PR
aryan1107 Jul 29, 2022
ef72bfc
Don't pass serialized LitType metadata from the Python back-end, now …
cjqian Aug 1, 2022
40d14e5
Rename Boolean LitType to BooleanLitType.
cjqian Aug 1, 2022
ccbb72c
Add tests for deserializing LitTypes from LitMetadata.
cjqian Aug 1, 2022
a5b9f65
Rename `FieldMatcher` to `SingleFieldMatcher` and consolidate shared …
cjqian Aug 1, 2022
ab1e06a
Remove unused `__mro__` and `__class__` properties from front-end Lit…
cjqian Aug 1, 2022
563cd3d
Solving merge conflict!
aryan1107 Aug 2, 2022
37e24a2
Resolving merge Conflict!
aryan1107 Aug 2, 2022
78a36cf
merge conflict
aryan1107 Aug 2, 2022
6c449a1
Merge branch 'dev' into dev
aryan1107 Aug 2, 2022
8d8cc7a
Revert "Remove unused `__mro__` and `__class__` properties from front…
aryan1107 Aug 2, 2022
d54522a
Updates for better performance on large datasets
jameswex Aug 2, 2022
853edd0
Fix Spec -> object conversion during JSON serialization by removing J…
cjqian Aug 3, 2022
9ec5324
Rename URL to URLLitType in the front end.
cjqian Aug 3, 2022
4a29334
Apply all suggestions from Ryan's code review.
iamshnoo Aug 3, 2022
5336a0b
Explicit use of window.*Timeout() call to resolve typing conflict
RyanMullins Aug 3, 2022
28443bc
Fixes #812. Text Salience Maps Tutorial.
iamshnoo Aug 4, 2022
194fc82
Apply suggestions. Img captions not added yet.
iamshnoo Aug 4, 2022
cb528f1
Update utility signatures to take in LitTypes instead of LitType names.
cjqian Aug 4, 2022
a36a936
Create LitTypes from a generic LitType constructor instead of a strin…
cjqian Aug 5, 2022
74b5dbb
Pass requested LitTypes directly into API `getPreds` query.
cjqian Aug 5, 2022
40a661e
Add Python datatypes (dtypes) to front-end for more specific type-che…
cjqian Aug 5, 2022
e811359
Wrap up typing migration tasks. Replace `__name__` property in front-…
cjqian Aug 5, 2022
d869b8c
Add Dataset.filter() method.
iftenney Aug 8, 2022
c70c9ff
Apply suggestions from code review
iamshnoo Aug 8, 2022
5b73398
Internal change
cjqian Aug 8, 2022
0ead420
Collapse Attention Module by default
RyanMullins Aug 9, 2022
08abc2c
Sync selection state to Python when working in notebooks.
iftenney Aug 9, 2022
3d82886
Progress indicators for warm_start, and fix slow startup in notebooks.
iftenney Aug 9, 2022
32e1224
WebPack build fix while we sort out TS 4.7 and Typings transition.
RyanMullins Aug 12, 2022
0758f89
Fix missing ground truth indicator in classification module.
jameswex Aug 15, 2022
1be609a
Relax required field enforcement in datapoint editor.
iftenney Aug 15, 2022
49cc156
Internal change.
iftenney Aug 15, 2022
7a1e26a
Integrates a color legend into the sequence salience.
jswong65 Aug 18, 2022
d50f7ae
Add suggestions from code review.
iamshnoo Aug 18, 2022
1a6e39f
Replace [Grad ˙ Input] with [Grad · Input]
iamshnoo Aug 18, 2022
fae59e6
Fix info box 2 title.
iamshnoo Aug 19, 2022
ca80f79
Fixes OSS build issue with Potato and other demos
RyanMullins Aug 22, 2022
ab057b5
Adds autorun and config init params to configurable text salience int…
RyanMullins Aug 22, 2022
9ea4ab2
Adds components.core library w/ functions for default interpreters + …
RyanMullins Aug 22, 2022
c8bc872
Integrate the color legend into the salience map module.
jswong65 Aug 24, 2022
60cd69e
Silence type errors generated by new pytype features.
sinopalnikov Aug 28, 2022
a0ad3b5
Fix the blank page issue caused by the invalid layout url param value.
jswong65 Aug 29, 2022
10e2548
Update LIT to TypeScript 4.7
RyanMullins Aug 29, 2022
948adb3
Fixes LIT_TYPES_REGISTRY in OSS builds by preserving TS/JS class names
RyanMullins Aug 29, 2022
24006e7
Fixing bugs causing CI failures in OSS release
RyanMullins Aug 29, 2022
3f990d9
Fixing Python env and test issues in GitHub CI
RyanMullins Aug 30, 2022
fac7ee4
Fixes #812. Text Salience Maps Tutorial.
iamshnoo Aug 4, 2022
1d35979
Apply suggestions from code review
iamshnoo Aug 8, 2022
a586cd3
Add suggestions from code review.
iamshnoo Aug 18, 2022
70bcf7f
Replace [Grad ˙ Input] with [Grad · Input]
iamshnoo Aug 18, 2022
b585e71
Merge branch 'tutorial-text-salience-gsoc' of github.com:PAIR-code/li…
RyanMullins Aug 31, 2022
fc30fcb
Update "Send Feedback" internal redirect.
cjqian Sep 2, 2022
b18d887
Remove the color module.
cjqian Sep 2, 2022
6048e74
Update cache persistence logic.
jameswex Sep 8, 2022
ca3367a
Internal change
a-googler Sep 9, 2022
4056a2e
Documentation update.
iftenney Sep 9, 2022
4dee37e
An improvement for the color legend element by showing a range info f…
jswong65 Sep 21, 2022
4760b4d
Use TypedDict for IndexedInputs
RyanMullins Sep 22, 2022
5e91b19
Adds a threshold property to MulticlassPreds type.
RyanMullins Sep 22, 2022
9f68ef7
Silence new type errors in Python 3.10.
rchen152 Sep 23, 2022
11a60ff
Add a slider for the color legend in the salience map module to allow…
jswong65 Sep 27, 2022
53bd99a
Remove default LIT landing page pop-up on launch.
cjqian Sep 28, 2022
184c8c6
Integrate MegaPlot into Scalars module
RyanMullins Sep 28, 2022
14f82d5
Fixing brush behavior typing in Scalars
RyanMullins Sep 29, 2022
0fef77a
Add dataset and model validation.
jameswex Sep 29, 2022
5f20e0c
Do not select text when shift-click in data table
jameswex Sep 30, 2022
0eaa00c
Support markdown in component descriptions.
iftenney Oct 5, 2022
3c0929f
Support Embeddings in input data.
iftenney Oct 6, 2022
e7ac98b
Enable embedding projector to show for input embeddings.
iftenney Oct 10, 2022
2873bee
JPEGBytes and PNGBytes subtypes to specify encoding format.
iftenney Oct 10, 2022
16d6463
Removes dead color modules styles code.
RyanMullins Oct 11, 2022
4561680
Fixes array access error in TCAV module
RyanMullins Oct 12, 2022
0cc934c
Selected Color by value synced to URL param
jswong65 Oct 12, 2022
14c0977
Fixes rounding error in GroupService.numericBinRange().
RyanMullins Oct 14, 2022
f5b2777
Makes "copy link" button more descriptive.
RyanMullins Oct 17, 2022
8bbcb2d
Show pinned input when filtering view to selected data.
cjqian Oct 17, 2022
9bbd6af
Eliminates snap when opening IG interpreter controls.
RyanMullins Oct 17, 2022
b3c3c60
Fix datapoint selection confusion.
jameswex Oct 17, 2022
2443e4a
Improved formatting for Model and Dataset descriptions in the Setting…
iftenney Oct 17, 2022
9b2de92
Adds HotFip.is_compatible() implementaiton.
RyanMullins Oct 17, 2022
c4a7181
Allow launching with new datapoints through POST operation.
jameswex Oct 17, 2022
be51efd
Fix LIME crash on fields containing only whitespace.
iftenney Oct 17, 2022
db94849
Adds AblationFlip.is_compatible() implementation.
RyanMullins Oct 18, 2022
dc79136
Tidying DataTable UX
RyanMullins Oct 18, 2022
f895b07
Fixes page jump in Data Table when adding datapoints.
RyanMullins Oct 18, 2022
c3b6a0c
Allow selection by row clicking in metrics table.
jameswex Oct 18, 2022
7ef4cc3
Eliminates row highlight if only one token-chip-label in a list.
RyanMullins Oct 19, 2022
cbe17dd
Clarify inline documentation of ablation-flip and hot-flip.
jameswex Oct 19, 2022
8bb54d8
Adding informative error msg for dataset load fail.
DeepakRamachandran Oct 19, 2022
5648376
Improve collapse/expand interaction icons, titles and styling.
cjqian Oct 19, 2022
005a7f0
Improve collapse/expand interaction icons, titles and styling.
iftenney Oct 19, 2022
68cb051
Improve collapse/expand interaction icons and titles; leave 16px icon…
cjqian Oct 19, 2022
20a8f31
Adds sparse mode to Classification Results module.
RyanMullins Oct 19, 2022
cd6864e
Use title to clarify function of dice button in Table element
RyanMullins Oct 20, 2022
4851c9d
Adds show only generated toggle to DataTable
RyanMullins Oct 20, 2022
cd14f35
Move starring interaction from app toolbar to per-table data entry.
cjqian Oct 20, 2022
66fbc24
Set primary selection to most newly selected point.
cjqian Oct 20, 2022
840d78e
Update attention module to only return single field being displayed.
jameswex Oct 21, 2022
c2501d4
Unify mwc-icon styles in shared styles.
jameswex Oct 21, 2022
ad657d6
Replace hash values with `primary: [id]` for primary data selection.
cjqian Oct 21, 2022
b774ff8
Add and clean up title text on icons.
cjqian Oct 21, 2022
e4ab24f
Bolds best value in each metric column in the Metrics table.
RyanMullins Oct 21, 2022
1994425
Use expansion panels and pop-out controls for salience module.
iftenney Oct 21, 2022
acea31a
Fix pin/star artifacts and ordering.
cjqian Oct 22, 2022
159ac06
Adds support for GeneratedText[Candidates] in Data Table.
RyanMullins Oct 24, 2022
764674a
Update Scalars to use revised Megaplot binding APIs
RyanMullins Oct 24, 2022
cc5fba2
Fix threshold slider
iftenney Oct 27, 2022
a065a4d
Tidy up pin and star icon handling in the data table
iftenney Oct 27, 2022
670abeb
Port faceting control to use popup-container
iftenney Oct 28, 2022
cca3511
Use <popup-container> for data table column controls
iftenney Oct 28, 2022
7254de3
Add documentation links to modules.
cjqian Oct 31, 2022
ba98322
Adds info button and text to Salience color maps.
RyanMullins Nov 1, 2022
ecd3a66
Adds dataset arg to Component is_compatible() functions.
RyanMullins Nov 3, 2022
de7d8ba
Adds Metrics class to lit_nlp.api.components
RyanMullins Nov 3, 2022
7db22ae
Move the Slice Module to the main toolbar button
jswong65 Nov 3, 2022
77a86f4
Adds title text for metrics table headers.
RyanMullins Nov 3, 2022
4efd58e
Ensure PR and ROC curves have points in correct order for plotting
jameswex Nov 7, 2022
06613b9
Fix state syncing in notebooks.
iftenney Nov 8, 2022
d23ecfc
Option to download or copy Data Table contents and generator output.
iftenney Nov 8, 2022
fd2b976
Don't show sequence salience in regular salience module
iftenney Nov 9, 2022
eac9382
Adds exact match metrics to LIT.
RyanMullins Nov 10, 2022
353b96e
Refactors Scalars module to eliminate duplication for different models.
RyanMullins Nov 11, 2022
757cea5
Merge branch 'dev' of github.com:PAIR-code/lit into tutorial-text-sal…
RyanMullins Nov 12, 2022
636db02
Merge branch 'dev' of github.com:PAIR-code/lit into tutorial-tab-feat…
RyanMullins Nov 12, 2022
2c0703d
Merge pull request #801 from PAIR-code:tutorial-tab-feat-attr-gsoc
a-googler Nov 14, 2022
dce80cd
Merge branch 'dev' of github.com:PAIR-code/lit into tutorial-text-sal…
RyanMullins Nov 14, 2022
4159527
Merge pull request #815 from PAIR-code:tutorial-text-salience-gsoc
a-googler Nov 14, 2022
155e0c4
Adds a "static" Facets Dive-like visualization to LIT.
RyanMullins Nov 14, 2022
1d17ca2
Adds selection states and interactivity to Dive module.
RyanMullins Nov 14, 2022
a0da9cf
Adds zoom and pan interactions to Dive module.
RyanMullins Nov 14, 2022
2392e3f
Bug fix for unused args passing to main() in container demos
RyanMullins Nov 15, 2022
6f7db10
Improved docs for running LIT with Docker.
RyanMullins Nov 15, 2022
902d775
Fix broken link and example parameter in documentation.
cjqian Nov 16, 2022
a090561
docs: cleanup LaTex in Gradient-dot-Input docs
dleve123 Aug 10, 2022
c51d9d6
docs: cleanup LaTex in Gradient Norm docs
dleve123 Aug 10, 2022
0e16619
docs: cleanup LaTex in Integrated Gradients docs
dleve123 Aug 15, 2022
2c913aa
Hotflip integration test fixes
RyanMullins Nov 16, 2022
616a713
Update package versions and clean up dependencies
iftenney Nov 16, 2022
e70c21f
Merge pull request #833 from dleve123:improve-latex-for-saliency-docs
a-googler Nov 16, 2022
691058e
Internal change
RyanMullins Nov 16, 2022
829bc3f
Redo of GitHub PR #833.
RyanMullins Nov 16, 2022
931a782
Rename `Learning Interpretability Tool` to `Language Interpretability…
cjqian Nov 16, 2022
cb5a708
Updated images and captions for the website.
RyanMullins Nov 17, 2022
8c572d6
Update notebook examples and feature documentation
iftenney Nov 17, 2022
94a2f33
LIT v0.5 release notes and docs for Dive and Tabular Feature Attribution
RyanMullins Nov 17, 2022
2e61eb5
Update g3doc images for 0.5 release.
cjqian Nov 17, 2022
e5f0907
T5 demo uses 5% slices of datasets
RyanMullins Nov 17, 2022
1300857
Final content updates for v0.5.0
RyanMullins Nov 18, 2022
ea97b2e
Change the description of the input salience eval demo.
eberts-google Nov 18, 2022
cb560ff
Fixes duplicate pinned datapoint when DataTable.onlySelected == true
RyanMullins Nov 21, 2022
1311081
Fixes SHAP explainer for Multiclass and SparseMulticlass preds.
RyanMullins Nov 22, 2022
3daa9c7
Adds support for loading T5 demo datasets from CSV files.
RyanMullins Nov 23, 2022
dac2128
Fix inconsistent shift-selection bug when toolbar navigation is used.
cjqian Nov 23, 2022
b600cd4
Fix unsorted navigation through datapoint selection bug.
cjqian Nov 23, 2022
bb05699
Consolidate datapoint navigation controls.
cjqian Nov 23, 2022
9a76c10
Adds color block to color legend when "Color By" is None.
RyanMullins Nov 28, 2022
78c4f13
Add padding between widget buttons.
cjqian Nov 29, 2022
fb5f793
Remove "unused" prefix when model isn't used.
cjqian Nov 29, 2022
2d40606
Fixes ScatterGL jitter and disappearance in Embeddings projector
RyanMullins Nov 29, 2022
98b23d7
Fixes LitType parsing bug in serialize._obj_from_json()
RyanMullins Nov 30, 2022
46a4c92
Fixes embedding projector color by behavior
RyanMullins Nov 30, 2022
c3d58d0
Update g3doc images for 0.5 release.
cjqian Nov 30, 2022
2efbb07
Tabular feature attribution tutorial content updates after SHAP inter…
RyanMullins Dec 1, 2022
dc7efed
Ensures "show selected" and "show generated" act as a set intersection.
RyanMullins Dec 1, 2022
ed90576
Support shift select across generated points in Data Table
RyanMullins Dec 1, 2022
febfc5a
Updated gifs for v0.5 release
RyanMullins Dec 1, 2022
f8faefe
Update external images for 0.5 release.
cjqian Dec 1, 2022
93ee4fd
Adding jinja2 to environment.yml
RyanMullins Dec 2, 2022
8653090
Website update for v0.5 release
RyanMullins Dec 2, 2022
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
Prev Previous commit
Next Next commit
Revert "Merge pull request #18 from PAIR-code/dev"
This reverts commit ba7ad82, reversing
changes made to d0ba035.
  • Loading branch information
aryan1107 committed Jul 29, 2022
commit 4dd6ee6bcae703006393dab0092b479c243f370c
61 changes: 10 additions & 51 deletions documentation/frontend_development.md
Original file line number Diff line number Diff line change
@@ -106,10 +106,9 @@ outlined below:
@customElement('demo-module') // (0)
export class DemoTextModule extends LitModule {
static override title = 'Demo Module'; // (1)
static override template =
(model: string, selectionServiceIndex: number, shouldReact: number) => // (2)
html`<demo-module model=${model} .shouldReact=${shouldReact}
selectionServiceIndex=${selectionServiceIndex}></demo-module>`;
static override template = (model = '') => { // (2)
return html`<demo-module model=${model}></demo-module>`;
};
static override duplicateForModelComparison = true; // (3)

static override get styles() {
@@ -137,7 +136,7 @@ export class DemoTextModule extends LitModule {
this.pigLatin = results;
}

override renderImpl() { // (10)
override render() { // (10)
const color = this.colorService.getDatapointColor(
this.selectionService.primarySelectedInputData);
return html`
@@ -209,14 +208,14 @@ of the data. Since we're using mobx observables to store and compute our state,
we do this all in a reactive way.

First, since the `LitModule` base class derives from `MobxLitElement`, any
observable data that we use in the `renderImpl` method automatically triggers a
observable data that we use in the `render` method automatically triggers a
re-render when updated. This is excellent for simple use cases, but what about
when we want to trigger more complex behavior, such as the asynchronous request
outlined above?

The pattern that we leverage across the app is as follows: The `renderImpl`
method (10) accesses a private observable `pigLatin` property (6) that, when
updated, will re-render the template and show the results of the translation
The pattern that we leverage across the app is as follows: The `render` method
(10) accesses a private observable `pigLatin` property (6) that, when updated,
will re-render the template and show the results of the translation
automatically. In order to update the `pigLatin` observable, we need to set up a
bit of machinery. In the lit-element lifecycle method `firstUpdated`, we use a
helper method `reactImmediately` (7) to set up an explicit reaction to the user
@@ -225,10 +224,7 @@ selecting data. Whatever is returned by the first function (in this case
second function immediately **and** whenever it changes, allowing us to do
something whenever the selection changes. Note, another helper method `react` is
used in the same way as `reactImmediately`, in instances where you don't want to
immediately invoke the reaction. Also note that modules should override
`renderImpl` and not the base `render` method as our `LitModule` base class
overrides `render` with custom logic which calls our `renderImpl` method for
modules to perform their rendering in.
immediately invoke the reaction.

We pass the selection to the `getTranslation` method to fetch the data from our
API service. However rather than awaiting our API request directly, we pass the
@@ -272,48 +268,11 @@ reconciliation of what needs to be updated per render.
this.drawCanvas(canvas);
}

override renderImpl() {
render() {
return html`<canvas></canvas>`;
}
```

### Stateful Child Elements

Some modules may contain stateful child elements, where the element has some
internal state that can have an effect on the module that contains it. Examples of this include any modules that contain the
[elements/faceting_control.ts](../lit_nlp/client/elements/faceting_control.ts) element.

With these types of child elements, it's important for the containing module
to construct them programmatically and store them in a class member variable,
as opposed to only constructing them in the module's html template
string returned by the `renderImpl` method. Otherwise they will be destroyed
and recreated when a module is hidden off-screen and then brought back
on-screen, leading them to lose whatever state they previously held.
Below is a snippet of example code to handle these types of elements.

```typescript
// An example of a LITModule using a stateful child element.
@customElement('example-module')
export class ExampleModule extends LitModule {
private readonly facetingControl = document.createElement('faceting-control');

constructor() {
super();

const facetsChange = (event: CustomEvent<FacetsChange>) => {
// Do something with the information from the event.
};
// Set the necessary properties on the faceting-control element.
this.facetingControl.contextName = ExampleModule.title;
this.facetingControl.addEventListener(
'facets-change', facetsChange as EventListener)
}

override renderImpl() {
// Render the faceting-control element.
return html`${this.facetingControl}`;
}
```
## Style Guide

* Please disable clang-format on `lit-html` templates and format these
11 changes: 1 addition & 10 deletions lit_nlp/client/core/faceting_control.ts
Original file line number Diff line number Diff line change
@@ -54,16 +54,7 @@ export interface FacetsChange {

type FeatureChangeHandler = (event?: Event) => void;

/**
* Controls for defining faceting behavior.
*
* This faceting control should be created using the call
* `document.createElement('faceting-control')"` or `new FacetingControl()` and
* stored as a data member of any module that wishes to make use of it, as
* opposed to being invoked through element templating in a `renderImpl` method
* call. This is done so that options set in this control aren't reset when a
* module's render is skipped due to the module being off-screen.
*/
/** Controls for defining faceting behavior. */
@customElement('faceting-control')
export class FacetingControl extends ReactiveElement {
private readonly featureConfigs = new Map<string, FacetingConfig>();
34 changes: 2 additions & 32 deletions lit_nlp/client/core/lit_module.ts
Original file line number Diff line number Diff line change
@@ -76,8 +76,8 @@ export abstract class LitModule extends ReactiveElement {

// Template function. Should return HTML to create this element in the DOM.
static template:
(model: string, selectionServiceIndex: number,
shouldReact: number) => TemplateResult = () => html``;
(model: string,
selectionServiceIndex: number) => TemplateResult = () => html``;

@property({type: String}) model = '';
@observable @property({type: Number}) selectionServiceIndex = 0;
@@ -109,36 +109,6 @@ export abstract class LitModule extends ReactiveElement {
});
}

/**
* Base module render function - not to be overridden by clients.
*
* This render function will call the renderImpl method if the module is set
* to react, otherwise it will not render anything.
*
* Any client overridding this method will not get the standard behavior of
* pausing rendering when a module is set to not react. This may cause issues
* as the module will still have reactions paused in this case. Therefore,
* clients should avoid overidding this method and instead they should
* implement renderImpl.
*/
override render() {
// If the module is not reactive, then do not render anything.
if (this.shouldReact === 0) {
return;
}
return this.renderImpl();
}

/**
* Render function for each LIT module to override.
*
* Only called if the module is reactive, meaning it is visibly on-screen.
* Clients should override this method as opposed to the base render() method.
*/
protected renderImpl(): unknown {
return html``;
}

/**
* A helper method for wrapping async API calls in machinery that a)
* automatically sets the loading state of the parent widget container and
13 changes: 5 additions & 8 deletions lit_nlp/client/core/modules.ts
Original file line number Diff line number Diff line change
@@ -395,9 +395,8 @@ export class LitModules extends ReactiveElement {
const classes = classMap({selected, 'components-group-holder': true});
return html`
<div class=${classes}>
${
this.renderWidgetGroups(
configs, tabName, layoutWidths, `${idPrefix}-${i}`, selected)}
${this.renderWidgetGroups(configs, tabName, layoutWidths,
`${idPrefix}-${i}`)}
</div>`;
});
}
@@ -425,9 +424,8 @@ export class LitModules extends ReactiveElement {
});
}

renderWidgetGroups(
configs: RenderConfig[][], section: string, layoutWidths: LayoutWidths,
idPrefix: string, visible: boolean) {
renderWidgetGroups(configs: RenderConfig[][], section: string,
layoutWidths: LayoutWidths, idPrefix: string) {
// Recalculate the widget group widths when isMinimized state changes.
const onMin = () => {
this.calculatePanelWidths(section, configs, layoutWidths);
@@ -492,8 +490,7 @@ export class LitModules extends ReactiveElement {
// clang-format off
return html`
<lit-widget-group id=${id} .configGroup=${configGroup} .width=${width}
@widget-group-minimized-changed=${onMin}
?visible=${visible}>
@widget-group-minimized-changed=${onMin}>
</lit-widget-group>
${isLastGroup ? html`` : html`
<div class="expander" style=${expanderStyles}>
16 changes: 6 additions & 10 deletions lit_nlp/client/core/widget_group.ts
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@
* limitations under the License.
*/

// tslint:disable:no-new-decorators
import '../elements/checkbox';
import '../elements/spinner';
import '@material/mwc-icon-button-toggle';
@@ -26,7 +25,6 @@ import {html} from 'lit';
import {customElement, property} from 'lit/decorators';
import {classMap} from 'lit/directives/class-map';
import {styleMap} from 'lit/directives/style-map';
import {observable} from 'mobx';

import {ReactiveElement} from '../lib/elements';
import {styles as sharedStyles} from '../lib/shared_styles.css';
@@ -61,7 +59,6 @@ export class WidgetGroup extends ReactiveElement {
@property({type: Boolean, reflect: true}) minimized = false;
@property({type: Boolean, reflect: true}) maximized = false;
@property({type: Boolean, reflect: true}) dragging = false;
@observable @property({type: Boolean, reflect: true}) visible = false;
@property({type: Number}) width = 0;
private widgetScrollTop = 0;
private widgetScrollLeft = 0;
@@ -223,18 +220,18 @@ export class WidgetGroup extends ReactiveElement {
config: RenderConfig, styles: {[key: string]: string},
showSubtitle: boolean) {
const moduleType = config.moduleType;
const modelName = config.modelName || 'unused';
const selectionServiceIndex = config.selectionServiceIndex || 0;
const shouldReact = this.visible && !this.minimized;
const modelName = config.modelName;
const selectionServiceIndex = config.selectionServiceIndex;

let subtitle = modelName ?? '';
/**
* If defined, modules show "Selected" for 0 and "Pinned" for 1,
* If undefined, modules do not show selectionService related info in their
* titles (when compare examples mode is disabled)."
*/
if (moduleType.duplicateForExampleComparison) {
if (typeof selectionServiceIndex !== 'undefined' && moduleType.duplicateForExampleComparison) {
subtitle = subtitle.concat(`${subtitle ? ' - ' : ''} ${
selectionServiceIndex ? 'Pinned' : 'Selected'}`);
selectionServiceIndex ? 'Pinned' : 'Selected'}`);
}
// Track scolling changes to the widget and request a rerender.
const widgetScrollCallback = (event: CustomEvent<WidgetScroll>) => {
@@ -255,8 +252,7 @@ export class WidgetGroup extends ReactiveElement {
widgetScrollTop=${this.widgetScrollTop}
style=${styleMap(styles)}
>
${moduleType.template(modelName, selectionServiceIndex,
shouldReact ? 1 : 0)}
${moduleType.template(modelName, selectionServiceIndex)}
</lit-widget>
`;
// clang-format on
56 changes: 2 additions & 54 deletions lit_nlp/client/lib/elements.ts
Original file line number Diff line number Diff line change
@@ -21,14 +21,9 @@

// tslint:disable:no-new-decorators
import {MobxLitElement} from '@adobe/lit-mobx';
import {property} from 'lit/decorators';
import {IReactionDisposer, IReactionOptions, IReactionPublic, observable, reaction} from 'mobx';
import {IReactionDisposer, IReactionOptions, IReactionPublic, reaction} from 'mobx';

type ReactionInputFn<T> = (r: IReactionPublic) => T;
// tslint:disable:no-any
type PendingReactionMap =
Map<(arg: any, r: IReactionPublic) => void, {arg: any, r: IReactionPublic}>;
// tslint:enable:no-any

/**
* Extension of MobxLitElement, with automatic reaction disposal.
@@ -42,51 +37,15 @@ export abstract class ReactiveElement extends MobxLitElement {
// TODO(b/204677206): remove this once we clean up property declarations.
__allowInstanceProperties = true; // tslint:disable-line

/**
* Indicates if the element should perform reactions. Set to 0 if the
* element is not visible to the user and any other number if it is visible.
* Not using a boolean here as web components cannot have boolean attributes
* that default to true if not specified due to how boolean attributes are
* passed to elements, given that we want this attribute to default to true
* for backwards compabitibility with elements that don't have this value set
* through an attribute.
*/
@observable @property({type: Number}) shouldReact = 1;

private readonly reactionDisposers: IReactionDisposer[] = [];

// Map of pending reactions that are stored when an element is in a state
// where it shouldn't react which are performed when the element is set to
// react again.
private readonly pendingReactions: PendingReactionMap = new Map();

constructor() {
super();
reaction(() => this.shouldReact, shouldReact => {
if (shouldReact === 0) {
return;
}
this.performPendingReactions();
});
}

override disconnectedCallback() {
super.disconnectedCallback();
this.reactionDisposers.forEach(disposer => {
disposer();
});
}

/**
* Performs all pending reactions and clears them from the map.
*/
private performPendingReactions() {
this.pendingReactions.forEach((value, effect) => {
effect.apply(window, [value.arg, value.r]);
});
this.pendingReactions.clear();
}

/**
* A simple wrapper method around mobx `reaction`. Note that this reaction
* is not called immediately (for that, use this.reactImmediately).
@@ -96,18 +55,7 @@ export abstract class ReactiveElement extends MobxLitElement {
protected react<T>(
fn: ReactionInputFn<T>, effect: (arg: T, r: IReactionPublic) => void,
opts: IReactionOptions = {}) {
// Wrapper function to pass to the mobx reaction call. If the element is
// set to react, then the effect happens immediately. If not, the arguments
// for the effect are stored in the map, keyed by the effect, so that
// the latest reaction of each type is stored for later use.
const reactWrapper = (arg: T, r: IReactionPublic) => {
if (this.shouldReact !== 0) {
effect.apply(window, [arg, r]);
} else {
this.pendingReactions.set(effect, {arg, r});
}
};
const disposer = reaction(fn, reactWrapper, opts);
const disposer = reaction(fn, effect, opts);
this.reactionDisposers.push(disposer);
}

3 changes: 1 addition & 2 deletions lit_nlp/client/lib/types.ts
Original file line number Diff line number Diff line change
@@ -283,8 +283,7 @@ export type ServiceUser = object;
export interface LitModuleClass {
title: string;
template:
(modelName: string, selectionServiceIndex: number,
shouldReact: number) => TemplateResult;
(modelName?: string, selectionServiceIndex?: number) => TemplateResult;
shouldDisplayModule: (modelSpecs: ModelInfoMap, datasetSpec: Spec) => boolean;
duplicateForExampleComparison: boolean;
duplicateForModelComparison: boolean;
Loading