Skip to content

Commit

Permalink
Option to download or copy Data Table contents and generator output.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 486805465
  • Loading branch information
iftenney authored and LIT team committed Nov 8, 2022
1 parent 06613b9 commit d23ecfc
Show file tree
Hide file tree
Showing 18 changed files with 205 additions and 72 deletions.
18 changes: 11 additions & 7 deletions documentation/faq.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Frequently Asked Questions

<!--* freshness: { owner: 'lit-dev' reviewed: '2022-08-13' } *-->
<!--* freshness: { owner: 'lit-dev' reviewed: '2022-11-07' } *-->

<!-- [TOC] placeholder - DO NOT REMOVE -->

Expand Down Expand Up @@ -107,13 +107,17 @@ but using `data0`, `data1`, `data2`, e.g. `data0_<fieldname>=<value>`.

### Downloading or exporting data

There is currently limited support for this via the settings (⚙️) menu. Click
the "Dataset" tab and enter a path to save to. This is done server-side, so be
sure the path is accessible to the server process.
Currently, there are three ways to export data from the LIT UI:

In the future, we hope to make this workflow more robust, including more control
over data format, as well as browser-based uploads and downloads of the examples
(such as from csv files or Google Sheets).
- In the Data Table, you can copy or download the current view in CSV format -
see [the UI guide](./ui_guide.md#data-table) for more details.
- In the "Dataset" tab of the settings (⚙️) menu, you can enter a path to save
data to. Data is pushed to the server and written by the server backend, so
be sure the path is writable.

- If using LIT in a Colab or other notebook environment, you can access the
current selection from another cell using `widget.ui_state.primary`,
`widget.ui_state.selection`, and `widget.ui_state.pinned`.

### Loading data from the UI

Expand Down
Binary file added documentation/images/lit-datatable-export.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 11 additions & 2 deletions documentation/ui_guide.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# UI Guide

<!--* freshness: { owner: 'lit-dev' reviewed: '2021-12-16' } *-->
<!--* freshness: { owner: 'lit-dev' reviewed: '2022-11-07' } *-->

This is a user guide for the Language Interpretability Tool (LIT) UI.

Expand Down Expand Up @@ -248,7 +248,7 @@ header row. All columns that have filters set on them have their search button
outlined. Clicking the **"x"** button in the search box for a column will clear
that column's filter.

The **"only show selected"** checkbox toggles the data table to only show the
The **"show only selected"** checkbox toggles the data table to only show the
datapoints that are currently selected.

The **"reset view"** button returns the data table to its standard, default
Expand All @@ -269,6 +269,15 @@ selected. A pinned datapoint can be unpinned by clicking on its pin icon again.

![LIT data table](./images/lit-datatable.png "LIT data table")<!-- DO NOT REMOVE {width="500"} -->

You can also export data to CSV using the copy or download buttons in the bottom
right:

![LIT data table](./images/lit-datatable-export.png "LIT data table export controls")<!-- DO NOT REMOVE {width="400"} -->

This will export all data in the current table view. To export only the
selection, use the "Show only selected" toggle. To include additional
columns such as model predictions, enable them from the "Columns" dropdown.

### Datapoint Editor

The datapoint editor shows the details of the primary selected datapoint, if one
Expand Down
1 change: 1 addition & 0 deletions lit_nlp/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import math
import os
import random
import threading
import time
from typing import Optional, Mapping, Sequence, Union, Callable, Iterable

Expand Down
1 change: 1 addition & 0 deletions lit_nlp/client/core/app_statusbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
.close-button-holder {
display: flex;
justify-content: flex-end;
column-gap: 8px;
margin: 10px;
}

Expand Down
22 changes: 16 additions & 6 deletions lit_nlp/client/core/app_statusbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ import './global_settings';
import '../elements/spinner';

import {MobxLitElement} from '@adobe/lit-mobx';
import {html} from 'lit';
import {customElement} from 'lit/decorators';
import { html} from 'lit';
import {classMap} from 'lit/directives/class-map';
import {observable} from 'mobx';

import {styles as sharedStyles} from '../lib/shared_styles.css';
import {StatusService} from '../services/services';
import {AppState, StatusService} from '../services/services';

import {app} from './app';
import {styles} from './app_statusbar.css';
Expand All @@ -45,6 +45,7 @@ export class StatusbarComponent extends MobxLitElement {
return [sharedStyles, styles];
}

private readonly appState = app.getService(AppState);
private readonly statusService = app.getService(StatusService);
@observable private renderFullMessages = false;

Expand Down Expand Up @@ -87,10 +88,21 @@ export class StatusbarComponent extends MobxLitElement {
`;
}

renderPopup() {
renderPopupControls() {
const close = () => {
this.renderFullMessages = false;
};

// clang-format off
return html`
<button class='hairline-button' @click=${() => {close();}}>
Close
</button>
`;
// clang-format on
}

renderPopup() {
// clang-format off
return html`
<div class='modal-container'>
Expand All @@ -102,9 +114,7 @@ export class StatusbarComponent extends MobxLitElement {
message => html`<div class="error-message">${message}</div>`)}
</div>
<div class='close-button-holder'>
<button class='hairline-button' @click=${() => {close();}}>
Close
</button>
${this.renderPopupControls()}
</div>
</div>
</div>`;
Expand Down
5 changes: 1 addition & 4 deletions lit_nlp/client/core/app_toolbar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {classMap} from 'lit/directives/class-map';

import {styles as sharedStyles} from '../lib/shared_styles.css';
import {datasetDisplayName} from '../lib/types';
import {copyToClipboard} from '../lib/utils';
import {AppState, ModulesService, SettingsService, StatusService} from '../services/services';

import {app} from './app';
Expand Down Expand Up @@ -274,9 +273,7 @@ export class ToolbarComponent extends MobxLitElement {
}

onClickCopyLink() {
const urlBase =
(this.appState.metadata.canonicalURL || window.location.host);
copyToClipboard(urlBase + window.location.search);
navigator.clipboard.writeText(this.appState.getBestURL());
}

renderRightCorner() {
Expand Down
17 changes: 16 additions & 1 deletion lit_nlp/client/elements/table.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
z-index: 0;
}

.holder table.paginated {
.holder table.has-footer {
height: 100%;
min-height: 100%;
}
Expand Down Expand Up @@ -231,6 +231,21 @@ tbody td {
flex-direction: row;
}

.footer-spacer {
flex: 1;
}

popup-container.download-popup {
--popup-bottom: 28px;
--popup-right: 0;
}

.download-popup-controls {
display: flex;
align-items: center;
column-gap: 4px;
}

.current-page-num {
display: inline-block;
text-align: center;
Expand Down

0 comments on commit d23ecfc

Please sign in to comment.