Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

fix search broken bug with incomplete filter #3935

Merged
merged 2 commits into from
Jul 15, 2021
Merged
Changes from all commits
Commits
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
128 changes: 71 additions & 57 deletions ts/webui/src/components/trial-detail/search/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,75 +154,89 @@ function Search(props): any {
}

allFilterConditions.forEach(eachFilterConditionStr => {
let eachFilterConditionArr: string[] = [];

// EXPERIMENT.searchSpace[parameter]._type === 'choice'
if (eachFilterConditionStr.includes('>' || '<')) {
const operator = eachFilterConditionStr.includes('>') === true ? '>' : '<';
eachFilterConditionArr = eachFilterConditionStr.trim().split(operator);
newSearchFilter.push({
name: eachFilterConditionArr[0],
operator: operator,
value1: eachFilterConditionArr[1],
value2: '',
choice: [],
isChoice: false
});
} else if (eachFilterConditionStr.includes('≠')) {
// drop_rate≠6; status≠[x,xx,xxx]; conv_size≠[3,7]
eachFilterConditionArr = eachFilterConditionStr.trim().split('≠');
const filterName = eachFilterConditionArr[0] === 'Status' ? 'StatusNNI' : eachFilterConditionArr[0];
const isChoicesType = isChoiceType(filterName);
newSearchFilter.push({
name: filterName,
operator: '≠',
value1: isChoicesType ? '' : JSON.parse(eachFilterConditionArr[1]),
value2: '',
choice: isChoicesType ? convertStringArrToList(eachFilterConditionArr[1]) : [],
isChoice: isChoicesType ? true : false
});
// input content looks like that: `Trial id:`
if (
eachFilterConditionStr.endsWith(':') ||
eachFilterConditionStr.endsWith('<') ||
eachFilterConditionStr.endsWith('>') ||
eachFilterConditionStr.endsWith('≠')
) {
return;
} else {
// = : conv_size:[1,2,3,4]; Trial id:3; hidden_size:[1,2], status:[val1,val2,val3]
eachFilterConditionArr = eachFilterConditionStr.trim().split(':');
const filterName = eachFilterConditionArr[0] === 'Status' ? 'StatusNNI' : eachFilterConditionArr[0];
const isChoicesType = isChoiceType(filterName);
const isArray =
eachFilterConditionArr.length > 1 && eachFilterConditionArr[1].includes('[' || ']') ? true : false;
if (isArray === true) {
if (isChoicesType === true) {
// status:[SUCCEEDED]
newSearchFilter.push({
name: filterName,
operator: '=',
value1: '',
value2: '',
choice: convertStringArrToList(eachFilterConditionArr[1]),
isChoice: true
});
let eachFilterConditionArr: string[] = [];

// EXPERIMENT.searchSpace[parameter]._type === 'choice'
if (eachFilterConditionStr.includes('>' || '<')) {
const operator = eachFilterConditionStr.includes('>') === true ? '>' : '<';
eachFilterConditionArr = eachFilterConditionStr.trim().split(operator);
newSearchFilter.push({
name: eachFilterConditionArr[0],
operator: operator,
value1: eachFilterConditionArr[1],
value2: '',
choice: [],
isChoice: false
});
} else if (eachFilterConditionStr.includes('≠')) {
// drop_rate≠6; status≠[x,xx,xxx]; conv_size≠[3,7]
eachFilterConditionArr = eachFilterConditionStr.trim().split('≠');
const filterName = eachFilterConditionArr[0] === 'Status' ? 'StatusNNI' : eachFilterConditionArr[0];
const isChoicesType = isChoiceType(filterName);
newSearchFilter.push({
name: filterName,
operator: '≠',
value1: isChoicesType ? '' : JSON.parse(eachFilterConditionArr[1]),
value2: '',
choice: isChoicesType ? convertStringArrToList(eachFilterConditionArr[1]) : [],
isChoice: isChoicesType ? true : false
});
} else if (eachFilterConditionStr.includes(':')) {
// = : conv_size:[1,2,3,4]; Trial id:3; hidden_size:[1,2], status:[val1,val2,val3]
eachFilterConditionArr = eachFilterConditionStr.trim().split(':');
const filterName = eachFilterConditionArr[0] === 'Status' ? 'StatusNNI' : eachFilterConditionArr[0];
const isChoicesType = isChoiceType(filterName);
const isArray =
eachFilterConditionArr.length > 1 && eachFilterConditionArr[1].includes('[' || ']')
? true
: false;
if (isArray === true) {
if (isChoicesType === true) {
// status:[SUCCEEDED]
newSearchFilter.push({
name: filterName,
operator: '=',
value1: '',
value2: '',
choice: convertStringArrToList(eachFilterConditionArr[1]),
isChoice: true
});
} else {
// drop_rate:[1,10]
newSearchFilter.push({
name: eachFilterConditionArr[0],
operator: 'between',
value1: JSON.parse(eachFilterConditionArr[1])[0],
value2: JSON.parse(eachFilterConditionArr[1])[1],
choice: [],
isChoice: false
});
}
} else {
// drop_rate:[1,10]
newSearchFilter.push({
name: eachFilterConditionArr[0],
operator: 'between',
value1: JSON.parse(eachFilterConditionArr[1])[0],
value2: JSON.parse(eachFilterConditionArr[1])[1],
operator: '=',
value1: eachFilterConditionArr[1],
value2: '',
choice: [],
isChoice: false
});
}
} else {
newSearchFilter.push({
name: eachFilterConditionArr[0],
operator: '=',
value1: eachFilterConditionArr[1],
value2: '',
choice: [],
isChoice: false
});
// user input: Trial id
return;
}
}
});

changeTableListPage(newSearchFilter);
}

Expand Down