-
Notifications
You must be signed in to change notification settings - Fork 1.7k
HParam UI: Replace RunsTableComponent with DataTable widget behind flag #6394
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,7 +20,7 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| OnInit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from '@angular/core'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {createSelector, Store} from '@ngrx/store'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {combineLatest, Observable, of, Subject} from 'rxjs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {BehaviorSubject, combineLatest, Observable, of, Subject} from 'rxjs'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| distinctUntilChanged, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filter, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -61,6 +61,12 @@ import { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {DataLoadState, LoadState} from '../../../types/data'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {SortDirection} from '../../../types/ui'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {matchRunToRegex} from '../../../util/matcher'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import {getEnableHparamsInTimeSeries} from '../../../feature_flag/store/feature_flag_selectors'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ColumnHeaderType, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| SortingOrder, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| TableData, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } from '../../../widgets/data_table/types'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runColorChanged, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runPageSelectionToggled, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -194,6 +200,7 @@ function matchFilter( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| selector: 'runs-table', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| template: ` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <runs-table-component | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *ngIf="!HParamsEnabled.value" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [experimentIds]="experimentIds" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [useFlexibleLayout]="useFlexibleLayout" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [numSelectedItems]="numSelectedItems$ | async" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -220,6 +227,16 @@ function matchFilter( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (onHparamDiscreteFilterChanged)="onHparamDiscreteFilterChanged($event)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (onMetricFilterChanged)="onMetricFilterChanged($event)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ></runs-table-component> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <tb-data-table | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| *ngIf="HParamsEnabled.value" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [headers]="runsColumns" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [data]="allRunsTableData$ | async" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [sortingInfo]="sortingInfo" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [columnCustomizationEnabled]="columnCustomizationEnabled" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| [smoothingEnabled]="smoothingEnabled" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (sortDataBy)="sortDataBy($event)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| (orderColumns)="orderColumns($event)" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ></tb-data-table> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| `, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| host: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| '[class.flex-layout]': 'useFlexibleLayout', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -239,12 +256,30 @@ function matchFilter( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export class RunsTableContainer implements OnInit, OnDestroy { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private allUnsortedRunTableItems$?: Observable<RunTableItem[]>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| allRunsTableData$: Observable<TableData[]> = of([]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| loading$: Observable<boolean> | null = null; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| filteredItemsLength$?: Observable<number>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| allItemsLength$?: Observable<number>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pageItems$?: Observable<RunTableItem[]>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| numSelectedItems$?: Observable<number>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // TODO(jameshollyer): Move these values to ngrx and make these Observables. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runsColumns = [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: ColumnHeaderType.RUN, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: 'run', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| displayName: 'Run', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| enabled: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sortingInfo = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| header: ColumnHeaderType.RUN, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: 'run', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| order: SortingOrder.ASCENDING, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| columnCustomizationEnabled = true; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| smoothingEnabled = false; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| hparamColumns$: Observable<HparamColumn[]> = of([]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| metricColumns$: Observable<MetricColumn[]> = of([]); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -275,6 +310,7 @@ export class RunsTableContainer implements OnInit, OnDestroy { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sortOption$ = this.store.select(getRunSelectorSort); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| paginationOption$ = this.store.select(getRunSelectorPaginationOption); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| regexFilter$ = this.store.select(getRunSelectorRegexFilter); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| HParamsEnabled = new BehaviorSubject<boolean>(false); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private readonly ngUnsubscribe = new Subject<void>(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| constructor(private readonly store: Store<State>) {} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -286,10 +322,24 @@ export class RunsTableContainer implements OnInit, OnDestroy { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ngOnInit() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.store.select(getEnableHparamsInTimeSeries).subscribe((enabled) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.HParamsEnabled.next(enabled); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const getRunTableItemsPerExperiment = this.experimentIds.map((id) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.getRunTableItemsForExperiment(id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const getRunTableDataPerExperiment$ = this.experimentIds.map((id) => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.getRunTableDataForExperiment(id) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.allRunsTableData$ = combineLatest(getRunTableDataPerExperiment$).pipe( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| map((itemsForExperiments: TableData[][]) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const items = [] as TableData[]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return items.concat(...itemsForExperiments); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const rawAllUnsortedRunTableItems$ = combineLatest( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| getRunTableItemsPerExperiment | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ).pipe( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -519,6 +569,34 @@ export class RunsTableContainer implements OnInit, OnDestroy { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return slicedItems; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private getRunTableDataForExperiment( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| experimentId: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): Observable<TableData[]> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return combineLatest([ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.store.select(getRuns, {experimentId}), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.store.select(getRunColorMap), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ]).pipe( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| map(([runs, colorMap]) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return runs.map((run) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const tableData: TableData = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id: run.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| color: colorMap[run.id], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| this.runsColumns.forEach((column) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| switch (column.type) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| case ColumnHeaderType.RUN: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tableData[column.name!] = run.name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return tableData; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+572
to
+598
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a selector, but I don't mind it being this way for now (until I get my generalized selector checked in). Could this at least be a lot shorter?
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would rather leave it as is. It is more extensible this way for other columns. I definitely see this being moved to a selector. However, the selector would be similar to this structure to accommodate all columns instead of just run. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| private getRunTableItemsForExperiment( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| experimentId: string | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ): Observable<RunTableItem[]> { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this need to be a
BehaviorSubject? It seems much more complicated this wayThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't think I could use an observable as a value in this component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried doing the *ngIf with an async pipe. It did not work. Leaving it as is.