-
Notifications
You must be signed in to change notification settings - Fork 7
OpenConceptLab/ocl_issues#2579 | AutoMatch can run on selected rows #50
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
base: main
Are you sure you want to change the base?
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -28,9 +28,10 @@ import AIAssistantSelectorPanel from './AIAssistantSelectorPanel' | |||||
| const AutoMatchDialog = ({ | ||||||
| open, | ||||||
| onClose, | ||||||
| autoMatchUnmappedOnly, | ||||||
| setAutoMatchUnmappedOnly, | ||||||
| autoMatchScope, | ||||||
| setAutoMatchScope, | ||||||
| rowStatuses, | ||||||
| selectedRowCount, | ||||||
| autoRunAIAnalysis, | ||||||
| setAutoRunAIAnalysis, | ||||||
| AIModels, | ||||||
|
|
@@ -47,11 +48,31 @@ const AutoMatchDialog = ({ | |||||
| }) => { | ||||||
| const { t } = useTranslation() | ||||||
| const [algos, setAlgos] = React.useState(true) | ||||||
| const selectedRows = autoMatchUnmappedOnly ? rowStatuses.unmapped.length : (rowStatuses.unmapped.length + rowStatuses.readyForReview.length) | ||||||
| const allRowsCount = rowStatuses.unmapped.length + rowStatuses.readyForReview.length | ||||||
| const rowsInSelectedScope = { | ||||||
| unmapped: rowStatuses.unmapped.length, | ||||||
| all: allRowsCount, | ||||||
| selected: selectedRowCount | ||||||
| } | ||||||
| const rowsToMatchCount = rowsInSelectedScope[autoMatchScope] || 0 | ||||||
| const totalRows = rowStatuses.unmapped.length + rowStatuses.readyForReview.length + rowStatuses.reviewed.length | ||||||
| const hasSelectedRows = selectedRowCount > 0 | ||||||
| const hasUnmappedRows = rowStatuses.unmapped.length > 0 | ||||||
|
|
||||||
| React.useEffect(() => { | ||||||
| if (autoMatchScope === 'unmapped' && !hasUnmappedRows) { | ||||||
| setAutoMatchScope('all') | ||||||
| } | ||||||
| }, [autoMatchScope, hasUnmappedRows, setAutoMatchScope]) | ||||||
|
|
||||||
| const getHelperTextForAutoMatchUnmapped = () => { | ||||||
| if (autoMatchUnmappedOnly) { | ||||||
| if (autoMatchScope === 'selected') { | ||||||
| if (hasSelectedRows) { | ||||||
| return t('map_project.auto_match_selected_rows_note', {count: selectedRowCount.toLocaleString()}); | ||||||
| } | ||||||
| return ''; | ||||||
| } | ||||||
| if (autoMatchScope === 'unmapped') { | ||||||
| const count = rowStatuses.unmapped.length; | ||||||
| if (count > 0) { | ||||||
| return t('map_project.auto_match_unmapped_only_note', {count: count.toLocaleString()}); | ||||||
|
|
@@ -69,7 +90,7 @@ const AutoMatchDialog = ({ | |||||
| return t('map_project.auto_match_note_no_counts'); | ||||||
| }; | ||||||
|
|
||||||
| const isDisabled = !repoVersion?.version_url || selectedRows === 0 || (!algos && !autoRunAIAnalysis) | ||||||
| const isDisabled = !repoVersion?.version_url || rowsToMatchCount === 0 || (!algos && !autoRunAIAnalysis) | ||||||
|
|
||||||
| return ( | ||||||
| <Dialog | ||||||
|
|
@@ -98,22 +119,30 @@ const AutoMatchDialog = ({ | |||||
| } | ||||||
| </div> | ||||||
| <FormControl sx={{marginTop: '16px'}}> | ||||||
| <FormLabel id="automatch-rows">{`${t('map_project.selected_rows')}: ${selectedRows.toLocaleString()} ${t('map_project.out_of')} ${totalRows.toLocaleString()}` }</FormLabel> | ||||||
| <FormLabel id="automatch-rows">{`${t('map_project.rows_to_match')}: ${rowsToMatchCount.toLocaleString()} ${t('map_project.out_of')} ${totalRows.toLocaleString()}` }</FormLabel> | ||||||
| <RadioGroup | ||||||
| row | ||||||
| aria-labelledby="automatch-rows" | ||||||
| name="automatch-rows" | ||||||
| onChange={() => setAutoMatchUnmappedOnly(!autoMatchUnmappedOnly)} | ||||||
| value={autoMatchScope} | ||||||
| onChange={event => setAutoMatchScope(event.target.value)} | ||||||
| > | ||||||
| <FormControlLabel | ||||||
| value="all" | ||||||
| control={<Radio />} | ||||||
| label={`${t('map_project.all_rows')} (${allRowsCount.toLocaleString()})`} | ||||||
|
Member
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. Relabel (per review discussion): this option labeled "All Rows" actually targets Unmapped + Proposed (it skips Approved — see
Suggested change
Then add the key to en/es/zh and remove the now-unused
A true "All (incl. Approved)" / start-from-scratch scope (with a warning) is tracked separately in #2589. |
||||||
| /> | ||||||
| <FormControlLabel | ||||||
| value="unmapped" | ||||||
| control={<Radio checked={autoMatchUnmappedOnly} />} | ||||||
| label={t('map_project.unmapped_only')} | ||||||
| disabled={!hasUnmappedRows} | ||||||
| control={<Radio />} | ||||||
| label={`${t('map_project.unmapped_only')} (${rowStatuses.unmapped.length.toLocaleString()})`} | ||||||
| /> | ||||||
| <FormControlLabel | ||||||
| value="all" | ||||||
| control={<Radio checked={!autoMatchUnmappedOnly} />} | ||||||
| label={t('map_project.all_rows')} | ||||||
| value="selected" | ||||||
| disabled={!hasSelectedRows} | ||||||
| control={<Radio />} | ||||||
| label={`${t('map_project.selected_rows')} (${selectedRowCount.toLocaleString()})`} | ||||||
| /> | ||||||
| </RadioGroup> | ||||||
| </FormControl> | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -224,7 +224,7 @@ const MapProject = () => { | |||||||||||||||||||
|
|
||||||||||||||||||||
| const [matchDialog, setMatchDialog] = React.useState(false) | ||||||||||||||||||||
| const [showItem, setShowItem] = React.useState(false) | ||||||||||||||||||||
| const [autoMatchUnmappedOnly, setAutoMatchUnmappedOnly] = React.useState(true) | ||||||||||||||||||||
| const [autoMatchScope, setAutoMatchScope] = React.useState('unmapped') | ||||||||||||||||||||
| const [autoRunAIAnalysis, setAutoRunAIAnalysis] = React.useState(false) | ||||||||||||||||||||
| const [alert, setAlert] = React.useState(false) | ||||||||||||||||||||
| const [columnVisibilityModel, setColumnVisibilityModel] = React.useState({}) | ||||||||||||||||||||
|
|
@@ -1008,7 +1008,7 @@ const MapProject = () => { | |||||||||||||||||||
| setDecisionTab('candidates') | ||||||||||||||||||||
| setSearchText('') | ||||||||||||||||||||
| setShowItem(false) | ||||||||||||||||||||
| setAutoMatchUnmappedOnly(true) | ||||||||||||||||||||
| setAutoMatchScope('unmapped') | ||||||||||||||||||||
| setAlert(false) | ||||||||||||||||||||
| setSelectedCandidatesScoreBucket(false) | ||||||||||||||||||||
| setScoreBucketSortBy('desc') | ||||||||||||||||||||
|
|
@@ -1591,6 +1591,16 @@ const MapProject = () => { | |||||||||||||||||||
|
|
||||||||||||||||||||
| const getRowsResults = async (rows, selectedAlgos) => { | ||||||||||||||||||||
| abortRef.current = false; | ||||||||||||||||||||
| const selectedRowIndexes = getSelectedRowIndexes(rows) | ||||||||||||||||||||
| const selectedRowIndexSet = new Set(selectedRowIndexes) | ||||||||||||||||||||
| const isAutoMatchUnmappedOnly = autoMatchScope === 'unmapped' | ||||||||||||||||||||
| const isAutoMatchAllRows = autoMatchScope === 'all' | ||||||||||||||||||||
| const isAutoMatchSelectedRows = autoMatchScope === 'selected' | ||||||||||||||||||||
| const selectedRowsLogExtras = isAutoMatchSelectedRows ? { | ||||||||||||||||||||
| selected_rows_count: selectedRowIndexes.length, | ||||||||||||||||||||
| row_indexes: selectedRowIndexes, | ||||||||||||||||||||
| selected_row_indexes: selectedRowIndexes | ||||||||||||||||||||
|
Comment on lines
+1600
to
+1602
Member
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.
Suggested change
|
||||||||||||||||||||
| } : {} | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // Function to process a single batch | ||||||||||||||||||||
| const processBatch = async (_repo, rowBatch, algo) => { | ||||||||||||||||||||
|
|
@@ -1729,15 +1739,18 @@ const MapProject = () => { | |||||||||||||||||||
| let _selectedAlgos = filter(algosSelected, algo => selectedAlgos.includes(algo.id)) | ||||||||||||||||||||
| let subActions = [...map(_selectedAlgos, algo => algo.name || algo.id)] | ||||||||||||||||||||
| subActions.push('reranker') | ||||||||||||||||||||
| if(autoMatchUnmappedOnly) | ||||||||||||||||||||
| if(isAutoMatchUnmappedOnly) | ||||||||||||||||||||
| subActions.push('unmatched_only') | ||||||||||||||||||||
| if(isAutoMatchSelectedRows) | ||||||||||||||||||||
| subActions.push('selected_rows') | ||||||||||||||||||||
| if(inAIAssistantGroup && autoRunAIAnalysis) | ||||||||||||||||||||
| subActions.push('with_ai_analysis') | ||||||||||||||||||||
|
|
||||||||||||||||||||
| projectLog({ | ||||||||||||||||||||
| action: 'auto_match_started', | ||||||||||||||||||||
| extras: { | ||||||||||||||||||||
| sub_actions: subActions, | ||||||||||||||||||||
| ...selectedRowsLogExtras, | ||||||||||||||||||||
| ...(inAIAssistantGroup && autoRunAIAnalysis ? { | ||||||||||||||||||||
| ai_assistant: { | ||||||||||||||||||||
| model: getSelectedAIModel(), | ||||||||||||||||||||
|
|
@@ -1747,13 +1760,25 @@ const MapProject = () => { | |||||||||||||||||||
| } | ||||||||||||||||||||
| }) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| if(!autoMatchUnmappedOnly) | ||||||||||||||||||||
| if(isAutoMatchAllRows) | ||||||||||||||||||||
| setRowStatuses(prev => ({...prev, readyForReview: []})) | ||||||||||||||||||||
| if(isAutoMatchSelectedRows) | ||||||||||||||||||||
| setRowStatuses(prev => ({ | ||||||||||||||||||||
| ...prev, | ||||||||||||||||||||
| readyForReview: without(prev.readyForReview, ...selectedRowIndexes), | ||||||||||||||||||||
| reviewed: without(prev.reviewed, ...selectedRowIndexes) | ||||||||||||||||||||
| })) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| setTimeout(async () => { | ||||||||||||||||||||
| const rowsToProcess = autoMatchUnmappedOnly | ||||||||||||||||||||
| const rowsToProcess = isAutoMatchUnmappedOnly | ||||||||||||||||||||
| ? filter(rows, row => rowStatuses.unmapped.includes(row.__index)) | ||||||||||||||||||||
| : filter(rows, row => !rowStatuses.reviewed.includes(row.__index)) | ||||||||||||||||||||
| : filter(rows, row => { | ||||||||||||||||||||
| if(isAutoMatchSelectedRows) | ||||||||||||||||||||
| return selectedRowIndexSet.has(row.__index) | ||||||||||||||||||||
| if(rowStatuses.reviewed.includes(row.__index)) | ||||||||||||||||||||
| return false | ||||||||||||||||||||
| return true | ||||||||||||||||||||
| }) | ||||||||||||||||||||
|
|
||||||||||||||||||||
| // ocl_online#105 Phase 5: open the run record, then guarantee it is | ||||||||||||||||||||
| // closed out (completed / partial / failed / cancelled) via the finally, | ||||||||||||||||||||
|
|
@@ -1805,6 +1830,7 @@ const MapProject = () => { | |||||||||||||||||||
| action: 'auto_match_finished', | ||||||||||||||||||||
| extras: { | ||||||||||||||||||||
| sub_actions: subActions, | ||||||||||||||||||||
| ...selectedRowsLogExtras, | ||||||||||||||||||||
| ...(inAIAssistantGroup && autoRunAIAnalysis ? { | ||||||||||||||||||||
| ai_assistant: { | ||||||||||||||||||||
| model: getSelectedAIModel(), | ||||||||||||||||||||
|
|
@@ -2043,6 +2069,7 @@ const MapProject = () => { | |||||||||||||||||||
| const onGetCandidates = event => { | ||||||||||||||||||||
| event.stopPropagation() | ||||||||||||||||||||
| event.preventDefault() | ||||||||||||||||||||
| setAutoMatchScope(getSelectedRowIndexes().length ? 'selected' : (rowStatuses.unmapped.length ? 'unmapped' : 'all')) | ||||||||||||||||||||
| setMatchDialog(true) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -2677,7 +2704,10 @@ const MapProject = () => { | |||||||||||||||||||
| }) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const getSelectedRowIndexes = () => selectedRowIds.map(id => parseInt(id)).filter(Number.isFinite) | ||||||||||||||||||||
| const getSelectedRowIndexes = (_rows = data) => { | ||||||||||||||||||||
| const selectedIds = new Set(selectedRowIds.map(id => id?.toString())) | ||||||||||||||||||||
| return _rows.filter(_row => selectedIds.has(_row.__index?.toString())).map(_row => _row.__index) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+2707
to
+2710
Member
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. Robustness regression:
Suggested change
|
||||||||||||||||||||
|
|
||||||||||||||||||||
| const openBulkConfirm = action => { | ||||||||||||||||||||
| const indexes = getSelectedRowIndexes() | ||||||||||||||||||||
|
|
@@ -3934,10 +3964,11 @@ const MapProject = () => { | |||||||||||||||||||
| const rows = getRows() | ||||||||||||||||||||
| const visibleRowIds = rows.map(_row => _row.__index) | ||||||||||||||||||||
| const visibleRowIdKey = visibleRowIds.join(',') | ||||||||||||||||||||
| const selectedRowsCount = selectedRowIds.length | ||||||||||||||||||||
| const selectedRowsCount = getSelectedRowIndexes(rows).length | ||||||||||||||||||||
| React.useEffect(() => { | ||||||||||||||||||||
| setSelectedRowIds(prev => { | ||||||||||||||||||||
| const next = prev.filter(id => visibleRowIds.includes(parseInt(id))) | ||||||||||||||||||||
| const visibleRowIdSet = new Set(visibleRowIds.map(id => id?.toString())) | ||||||||||||||||||||
| const next = prev.filter(id => visibleRowIdSet.has(id?.toString())) | ||||||||||||||||||||
| return next.length === prev.length ? prev : next | ||||||||||||||||||||
| }) | ||||||||||||||||||||
| }, [visibleRowIdKey]) | ||||||||||||||||||||
|
|
@@ -4965,8 +4996,9 @@ const MapProject = () => { | |||||||||||||||||||
| onSubmit={onGetCandidatesSubmit} | ||||||||||||||||||||
| {...{ | ||||||||||||||||||||
| rowStatuses, | ||||||||||||||||||||
| autoMatchUnmappedOnly, | ||||||||||||||||||||
| setAutoMatchUnmappedOnly, | ||||||||||||||||||||
| autoMatchScope, | ||||||||||||||||||||
| setAutoMatchScope, | ||||||||||||||||||||
| selectedRowCount: selectedRowsCount, | ||||||||||||||||||||
| autoRunAIAnalysis, | ||||||||||||||||||||
| setAutoRunAIAnalysis, | ||||||||||||||||||||
| AIModels, | ||||||||||||||||||||
|
|
||||||||||||||||||||
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.
auto_match_selected_rows_note_no_countwas added to all 3 locales but is never referenced — this branch returns'', and it's effectively unreachable anyway (theselectedradio isdisabledwithout a selection). Either wire it here or drop the key from en/es/zh.