Skip to content

Commit

Permalink
time series: ignore case when matching tags (#5186)
Browse files Browse the repository at this point in the history
This change ignores casing when matching tags with regex or strings.
  • Loading branch information
stephanwlee committed Aug 4, 2021
1 parent bd52711 commit 91f7e34
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class MetricsFilterInputContainer {
map<[string[], string], [string[], RegExp | null]>(
([tags, tagFilter]) => {
try {
const regex = new RegExp(tagFilter);
const regex = new RegExp(tagFilter, 'i');
return [tags, regex];
} catch (e) {
return [tags, null];
Expand Down
15 changes: 15 additions & 0 deletions tensorboard/webapp/metrics/views/main_view/filter_input_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ describe('metrics filter input', () => {
).toEqual(['tagA/Images', 'tagB/meow/cat']);
});

it('filters by regex ignoring casing', () => {
store.overrideSelector(selectors.getMetricsTagFilter, '[ib]');
const fixture = TestBed.createComponent(MetricsFilterInputContainer);
fixture.detectChanges();

const input = fixture.debugElement.query(By.css('input'));
input.nativeElement.focus();
fixture.detectChanges();

const options = getAutocompleteOptions(overlayContainer);
expect(
options.map((option) => option.nativeElement.textContent)
).toEqual(['tagA/Images', 'tagB/meow/cat']);
});

it('responds to input changes', () => {
store.overrideSelector(selectors.getMetricsTagFilter, '');
const fixture = TestBed.createComponent(MetricsFilterInputContainer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class FilteredViewContainer {
}),
map(([cardList, tagFilter]) => {
try {
return {cardList, regex: new RegExp(tagFilter)};
return {cardList, regex: new RegExp(tagFilter, 'i')};
} catch (e) {
return {cardList, regex: null};
}
Expand Down
12 changes: 12 additions & 0 deletions tensorboard/webapp/metrics/views/main_view/main_view_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,18 @@ describe('metrics main view', () => {
]);
});

it('ignores case when matching the regex', () => {
store.overrideSelector(selectors.getMetricsTagFilter, 'taga');
const fixture = TestBed.createComponent(MainViewContainer);
fixture.detectChanges();

expect(getCardGroupNames(getFilterViewContainer(fixture))).toEqual([]);
expect(getFilterviewCardContents(fixture)).toEqual([
'scalars: card1',
'images: card2',
]);
});

it('hides the main, pinned views while the filter view is active', () => {
store.overrideSelector(selectors.getMetricsTagFilter, 'tagA');
const fixture = TestBed.createComponent(MainViewContainer);
Expand Down

0 comments on commit 91f7e34

Please sign in to comment.