Skip to content

Commit 9f3bb23

Browse files
committed
OpenConceptLab/ocl_issues#2322 | Auto match dialog | algos selection
1 parent fd35021 commit 9f3bb23

3 files changed

Lines changed: 47 additions & 24 deletions

File tree

src/components/map-projects/AutoMatchDialog.jsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@ import Button from '@mui/material/Button';
1313
import RadioGroup from '@mui/material/RadioGroup';
1414
import Radio from '@mui/material/Radio';
1515
import FormLabel from '@mui/material/FormLabel';
16+
import Chip from '@mui/material/Chip'
1617

1718
import DoubleArrowIcon from '@mui/icons-material/DoubleArrow';
1819

20+
import map from 'lodash/map'
21+
1922
import CloseIconButton from '../common/CloseIconButton'
2023
import RepoChip from '../repos/RepoVersionChip'
2124
import AIAssistantButton from './AIAssistantButton'
2225

2326

24-
const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnmappedOnly, rowStatuses, autoRunAIAnalysis, setAutoRunAIAnalysis, AIModels, AIModel, setAIModel, repoVersion, onSubmit, inAIAssistantGroup}) => {
27+
const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnmappedOnly, rowStatuses, autoRunAIAnalysis, setAutoRunAIAnalysis, AIModels, AIModel, setAIModel, repoVersion, onSubmit, inAIAssistantGroup, algosSelected}) => {
2528
const { t } = useTranslation()
29+
const [algos, setAlgos] = React.useState(true)
2630
const selectedRows = autoMatchUnmappedOnly ? rowStatuses.unmapped.length : (rowStatuses.unmapped.length + rowStatuses.readyForReview.length)
2731
const totalRows = rowStatuses.unmapped.length + rowStatuses.readyForReview.length + rowStatuses.reviewed.length
2832

@@ -45,7 +49,7 @@ const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnma
4549
return t('map_project.auto_match_note_no_counts');
4650
};
4751

48-
const isDisabled = !repoVersion?.version_url && selectedRows > 0
52+
const isDisabled = !repoVersion?.version_url || selectedRows === 0 || (!algos && !autoRunAIAnalysis)
4953

5054
return (
5155
<Dialog
@@ -98,6 +102,23 @@ const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnma
98102
getHelperTextForAutoMatchUnmapped()
99103
}
100104
</FormHelperText>
105+
106+
<FormControl sx={{marginTop: '16px'}}>
107+
<FormControlLabel control={<Checkbox checked={algos} onChange={() => setAlgos(!algos)} />} label={t('map_project.retrieve_candidates')} />
108+
<FormLabel id="algorithms">
109+
{t('map_project.retrieve_candidates_helper_text')}
110+
</FormLabel>
111+
<div className='col-xs-12 padding-0'>
112+
{
113+
algosSelected.map(algo => {
114+
return (
115+
<Chip variant='outlined' size='small' color='warning' label={algo.id} key={algo.id} sx={{margin: '4px'}} />
116+
)
117+
})
118+
}
119+
</div>
120+
</FormControl>
121+
101122
{
102123
inAIAssistantGroup &&
103124
<>
@@ -139,7 +160,7 @@ const AutoMatchDialog = ({open, onClose, autoMatchUnmappedOnly, setAutoMatchUnma
139160
sx={{textTransform: 'none', marginLeft: '12px'}}
140161
endIcon={<DoubleArrowIcon />}
141162
disabled={isDisabled}
142-
onClick={onSubmit}
163+
onClick={event => onSubmit(event, algos ? map(algosSelected, val => val?.id) : [])}
143164
>
144165
{t('common.submit')}
145166
</Button>

src/components/map-projects/MapProject.jsx

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ const MapProject = () => {
10621062
}
10631063

10641064

1065-
const getRowsResults = async (rows) => {
1065+
const getRowsResults = async (rows, selectedAlgos) => {
10661066
abortRef.current = false;
10671067

10681068
// Function to process a single batch
@@ -1190,10 +1190,9 @@ const MapProject = () => {
11901190
await Promise.race(activeRequests);
11911191
}
11921192
};
1193-
1194-
let subActions = [...map(algosSelected, algo => algo.name || algo.id)]
1195-
if(!isMultiAlgo)
1196-
subActions.push('reranker')
1193+
let _selectedAlgos = filter(algosSelected, algo => selectedAlgos.includes(algo.id))
1194+
let subActions = [...map(_selectedAlgos, algo => algo.name || algo.id)]
1195+
subActions.push('reranker')
11971196
if(autoMatchUnmappedOnly)
11981197
subActions.push('unmatched_only')
11991198
if(inAIAssistantGroup && autoRunAIAnalysis)
@@ -1209,24 +1208,23 @@ const MapProject = () => {
12091208
? filter(rows, row => rowStatuses.unmapped.includes(row.__index))
12101209
: filter(rows, row => !rowStatuses.reviewed.includes(row.__index))
12111210

1212-
let nextAlgo = {...getFirstAlgoDef()}
12131211
const algoPromises = []
1214-
while(nextAlgo?.id) {
1215-
if(['custom', 'ocl-search', 'ocl-semantic'].includes(nextAlgo.type))
1216-
algoPromises.push(processWithConcurrency(repo, nextAlgo, rowsToProcess));
1217-
else if(nextAlgo.type === 'ocl-ciel-bridge' && canBridge)
1218-
algoPromises.push(fetchBulkBridgeCandidates(rowsToProcess, nextAlgo))
1219-
else if(nextAlgo.type === 'ocl-scispacy' && canScispacy)
1220-
algoPromises.push(fetchBulkScispacyCandidates(rowsToProcess, nextAlgo))
1221-
nextAlgo = getNextAlgoDef(nextAlgo.id)
1222-
}
1212+
forEach(_selectedAlgos, algo => {
1213+
if(['custom', 'ocl-search', 'ocl-semantic'].includes(algo.type))
1214+
algoPromises.push(processWithConcurrency(repo, algo, rowsToProcess));
1215+
else if(algo.type === 'ocl-ciel-bridge' && canBridge)
1216+
algoPromises.push(fetchBulkBridgeCandidates(rowsToProcess, algo))
1217+
else if(algo.type === 'ocl-scispacy' && canScispacy)
1218+
algoPromises.push(fetchBulkScispacyCandidates(rowsToProcess, algo))
1219+
})
12231220
await Promise.all(algoPromises)
1224-
1225-
await processRerankWithConcurrency(rowsToProcess, 2)
1221+
if(_selectedAlgos.length)
1222+
await processRerankWithConcurrency(rowsToProcess, 2)
12261223
if(inAIAssistantGroup && autoRunAIAnalysis) {
12271224
await new Promise(resolve => setTimeout(resolve, 1000))
12281225
await runBulkAIAnalysis(rowsToProcess)
12291226
} else {
1227+
setIsLoadingInDecisionView(false)
12301228
setLoadingMatches(false)
12311229
setEndMatchingAt(moment())
12321230
}
@@ -1416,7 +1414,7 @@ const MapProject = () => {
14161414
setMatchDialog(true)
14171415
}
14181416

1419-
const onGetCandidatesSubmit = event => {
1417+
const onGetCandidatesSubmit = (event, selectedAlgos) => {
14201418
event.stopPropagation()
14211419
event.preventDefault()
14221420
setAlert(false)
@@ -1429,7 +1427,7 @@ const MapProject = () => {
14291427
setScispacyCandidatesStartedAt(null)
14301428
setScispacyCandidatesEndedAt(null)
14311429
setLoadingMatches(true)
1432-
getRowsResults(data)
1430+
getRowsResults(data, selectedAlgos)
14331431
} else {
14341432
setAlert({message: t('map_project.no_valid_columns_for_matching')})
14351433
setTimeout(() => setAlert(false), 10000)
@@ -2880,7 +2878,8 @@ const MapProject = () => {
28802878
AIModel,
28812879
setAIModel,
28822880
repoVersion,
2883-
inAIAssistantGroup
2881+
inAIAssistantGroup,
2882+
algosSelected
28842883
}}
28852884
/>
28862885
</Paper>

src/i18n/locales/en/translations.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@
549549
"ocl_scispacy_loinc_algorithm": "OCL ScispaCy LOINC Algorithm",
550550
"ocl_custom_algorithm": "OCL Custom Algorithm",
551551
"algorithm": "Algorithm",
552+
"algorithms": "Algorithms",
552553
"column_send_to_ai_assistant": "Send to AI Assistant",
553554
"algo_conflicting_id": "Conflicting ID",
554555
"algo_conflicting_name": "Conflicting Name",
@@ -565,7 +566,9 @@
565566
"select_an_algo": "Select an algorithm",
566567
"selected_rows": "Selected Rows",
567568
"all_rows": "All Rows",
568-
"out_of": "out of"
569+
"out_of": "out of",
570+
"retrieve_candidates": "Retrieve Candidates",
571+
"retrieve_candidates_helper_text": "Your project is configured to use the following match algorithms:"
569572
},
570573
"app": {
571574
"web_version": "Web Version",

0 commit comments

Comments
 (0)