Skip to content

Commit f04ca97

Browse files
committed
fix bug with run selection
1 parent 58736bd commit f04ca97

File tree

1 file changed

+59
-45
lines changed

1 file changed

+59
-45
lines changed

tensorboard/webapp/metrics/views/card_renderer/scalar_card_container.ts

Lines changed: 59 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
getMetricsCardRangeSelectionEnabled,
5757
getRun,
5858
getRunColorMap,
59+
getCurrentRouteRunSelection,
5960
} from '../../../selectors';
6061
import {DataLoadState} from '../../../types/data';
6162
import {
@@ -499,6 +500,7 @@ export class ScalarCardContainer implements CardRenderer, OnInit, OnDestroy {
499500
);
500501
}),
501502
combineLatestWith(
503+
this.store.select(getCurrentRouteRunSelection),
502504
this.store.select(getFilteredRenderableRunsIdsFromRoute),
503505
this.store.select(getRunColorMap),
504506
this.store.select(getMetricsScalarSmoothing)
@@ -508,55 +510,67 @@ export class ScalarCardContainer implements CardRenderer, OnInit, OnDestroy {
508510
// debounce by a microtask to emit only single change for the runs
509511
// store change.
510512
debounceTime(0),
511-
map(([namedPartitionedSeries, renderableRuns, colorMap, smoothing]) => {
512-
const metadataMap: ScalarCardSeriesMetadataMap = {};
513-
const shouldSmooth = smoothing > 0;
513+
map(
514+
([
515+
namedPartitionedSeries,
516+
runSelectionMap,
517+
renderableRuns,
518+
colorMap,
519+
smoothing,
520+
]) => {
521+
const metadataMap: ScalarCardSeriesMetadataMap = {};
522+
const shouldSmooth = smoothing > 0;
523+
524+
for (const partitioned of namedPartitionedSeries) {
525+
const {
526+
seriesId,
527+
runId,
528+
displayName,
529+
alias,
530+
partitionIndex,
531+
partitionSize,
532+
} = partitioned;
533+
534+
metadataMap[seriesId] = {
535+
type: SeriesType.ORIGINAL,
536+
id: seriesId,
537+
alias,
538+
displayName:
539+
partitionSize > 1
540+
? `${displayName}: ${partitionIndex}`
541+
: displayName,
542+
visible: Boolean(
543+
runSelectionMap &&
544+
runSelectionMap.get(runId) &&
545+
renderableRuns.has(runId)
546+
),
547+
color: colorMap[runId] ?? '#fff',
548+
aux: false,
549+
opacity: 1,
550+
};
551+
}
552+
553+
if (!shouldSmooth) {
554+
return metadataMap;
555+
}
556+
557+
for (const [id, metadata] of Object.entries(metadataMap)) {
558+
const smoothedSeriesId = getSmoothedSeriesId(id);
559+
metadataMap[smoothedSeriesId] = {
560+
...metadata,
561+
id: smoothedSeriesId,
562+
type: SeriesType.DERIVED,
563+
aux: false,
564+
originalSeriesId: id,
565+
};
514566

515-
for (const partitioned of namedPartitionedSeries) {
516-
const {
517-
seriesId,
518-
runId,
519-
displayName,
520-
alias,
521-
partitionIndex,
522-
partitionSize,
523-
} = partitioned;
524-
525-
metadataMap[seriesId] = {
526-
type: SeriesType.ORIGINAL,
527-
id: seriesId,
528-
alias,
529-
displayName:
530-
partitionSize > 1
531-
? `${displayName}: ${partitionIndex}`
532-
: displayName,
533-
visible: Boolean(renderableRuns.has(runId)),
534-
color: colorMap[runId] ?? '#fff',
535-
aux: false,
536-
opacity: 1,
537-
};
538-
}
567+
metadata.aux = true;
568+
metadata.opacity = 0.25;
569+
}
539570

540-
if (!shouldSmooth) {
541571
return metadataMap;
542572
}
543-
544-
for (const [id, metadata] of Object.entries(metadataMap)) {
545-
const smoothedSeriesId = getSmoothedSeriesId(id);
546-
metadataMap[smoothedSeriesId] = {
547-
...metadata,
548-
id: smoothedSeriesId,
549-
type: SeriesType.DERIVED,
550-
aux: false,
551-
originalSeriesId: id,
552-
};
553-
554-
metadata.aux = true;
555-
metadata.opacity = 0.25;
556-
}
557-
558-
return metadataMap;
559-
}),
573+
),
560574
startWith({} as ScalarCardSeriesMetadataMap)
561575
);
562576

0 commit comments

Comments
 (0)