@@ -2,13 +2,13 @@ import { useRouter } from "next/router";
2
2
import HeuristicsLayout from "../shared/HeuristicsLayout" ;
3
3
import { useDispatch , useSelector } from "react-redux" ;
4
4
import { selectProjectId } from "@/src/reduxStore/states/project" ;
5
- import { useCallback , useEffect , useState } from "react" ;
5
+ import { useCallback , useEffect , useMemo , useState } from "react" ;
6
6
import { selectHeuristic , setActiveHeuristics , updateHeuristicsState } from "@/src/reduxStore/states/pages/heuristics" ;
7
7
import { postProcessCurrentHeuristic , postProcessLastTaskLogs } from "@/src/util/components/projects/projectId/heuristics/heuristicId/heuristics-details-helper" ;
8
8
import { Tooltip } from "@nextui-org/react" ;
9
9
import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants" ;
10
10
import { postProcessLabelingTasks , postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper" ;
11
- import { selectVisibleAttributesHeuristics , selectLabelingTasksAll , setLabelingTasksAll , SELECT_LABELING_TASKS_ALL_SNAPSHOT_ACCESS } from "@/src/reduxStore/states/pages/settings" ;
11
+ import { selectVisibleAttributesHeuristics , selectLabelingTasksAll , setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings" ;
12
12
import HeuristicsEditor from "../shared/HeuristicsEditor" ;
13
13
import DangerZone from "@/src/components/shared/danger-zone/DangerZone" ;
14
14
import HeuristicRunButtons from "../shared/HeuristicRunButtons" ;
@@ -22,10 +22,9 @@ import { SampleRecord } from "@/src/types/components/projects/projectId/heuristi
22
22
import { getPythonFunctionRegExMatch } from "@/submodules/javascript-functions/python-functions-parser" ;
23
23
import CalculationProgress from "./CalculationProgress" ;
24
24
import { copyToClipboard } from "@/submodules/javascript-functions/general" ;
25
- import { selectAllUsers , selectOrganizationId , setBricksIntegrator , setComments } from "@/src/reduxStore/states/general" ;
25
+ import { selectAllUsers , selectOrganizationId , setComments } from "@/src/reduxStore/states/general" ;
26
26
import { CommentType } from "@/src/types/shared/comments" ;
27
27
import { CommentDataManager } from "@/src/util/classes/comments" ;
28
- import BricksIntegrator from "@/src/components/shared/bricks-integrator/BricksIntegrator" ;
29
28
import { InformationSourceCodeLookup , InformationSourceExamples } from "@/src/util/classes/heuristics" ;
30
29
import { getInformationSourceTemplate } from "@/src/util/components/projects/projectId/heuristics/heuristics-helper" ;
31
30
import KernDropdown from "@/submodules/react-components/components/KernDropdown" ;
@@ -36,8 +35,8 @@ import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/use
36
35
import { getAllComments } from "@/src/services/base/comment" ;
37
36
import { getLabelingTasksByProjectId } from "@/src/services/base/project" ;
38
37
import { getHeuristicByHeuristicId , getLabelingFunctionOn10Records , getPayloadByPayloadId , updateHeuristicPost } from "@/src/services/base/heuristic" ;
39
- import { getStoreSnapshotValue } from "@/src/reduxStore/store" ;
40
38
import { Application , CurrentPage } from "@/submodules/react-components/hooks/web-socket/constants" ;
39
+ import { VisitBricksButton } from "@/src/components/shared/bricks/VisitBricksButton" ;
41
40
42
41
export default function LabelingFunction ( ) {
43
42
const dispatch = useDispatch ( ) ;
@@ -53,7 +52,6 @@ export default function LabelingFunction() {
53
52
const [ selectedAttribute , setSelectedAttribute ] = useState < Attribute > ( null ) ;
54
53
const [ sampleRecords , setSampleRecords ] = useState < SampleRecord > ( null ) ;
55
54
const [ displayLogWarning , setDisplayLogWarning ] = useState < boolean > ( false ) ;
56
- const [ isInitialLf , setIsInitialLf ] = useState < boolean > ( null ) ; //null as add state to differentiate between initial, not and unchecked
57
55
const [ checkUnsavedChanges , setCheckUnsavedChanges ] = useState ( false ) ;
58
56
const [ runOn10IsRunning , setRunOn10IsRunning ] = useState ( false ) ;
59
57
const [ justClickedRun , setJustClickedRun ] = useState ( false ) ;
@@ -73,9 +71,8 @@ export default function LabelingFunction() {
73
71
74
72
useEffect ( ( ) => {
75
73
if ( ! currentHeuristic ) return ;
76
- if ( isInitialLf == null ) setIsInitialLf ( InformationSourceCodeLookup . isCodeStillTemplate ( currentHeuristic . sourceCode ) != null ) ;
77
74
refetchTaskByTaskIdAndProcess ( ) ;
78
- } , [ currentHeuristic , isInitialLf ] ) ;
75
+ } , [ currentHeuristic ] ) ;
79
76
80
77
useEffect ( ( ) => {
81
78
if ( ! projectId || allUsers . length == 0 ) return ;
@@ -199,28 +196,14 @@ export default function LabelingFunction() {
199
196
}
200
197
} , [ currentHeuristic ] ) ;
201
198
202
-
203
- const setValueToLabelingTask = useCallback ( ( value : string ) => {
204
- const labelingTask = labelingTasks . find ( a => a . id == value ) ;
205
- const updateHeuristic = ( labelingTasks : any [ ] , maxI : number , task ?: any ) => {
206
- const labelingTask = task || labelingTasks . find ( a => a . id == value ) ;
207
- if ( ! labelingTask && maxI > 0 ) {
208
- setTimeout ( ( ) => updateHeuristic ( getStoreSnapshotValue ( SELECT_LABELING_TASKS_ALL_SNAPSHOT_ACCESS ) , maxI - 1 ) , 100 ) ;
209
- } else {
210
- updateHeuristicPost ( projectId , currentHeuristic . id , labelingTask . id , currentHeuristic . sourceCode , currentHeuristic . description , currentHeuristic . name , ( res ) => {
211
- dispatch ( updateHeuristicsState ( currentHeuristic . id , { labelingTaskId : labelingTask . id , labelingTaskName : labelingTask . name , labels : labelingTask . labels } ) )
212
- } ) ;
213
- }
214
- }
215
- if ( ! labelingTask ) {
216
- //try timeout as this is usually caused by race condition (creating the task+label through the integrator)
217
- setTimeout ( ( ) => updateHeuristic ( getStoreSnapshotValue ( SELECT_LABELING_TASKS_ALL_SNAPSHOT_ACCESS ) , 5 ) , 100 ) ;
218
- } else updateHeuristic ( labelingTasks , 0 , labelingTask ) ;
219
- } , [ projectId , currentHeuristic , labelingTasks ] )
220
-
221
199
const orgId = useSelector ( selectOrganizationId ) ;
222
200
useWebsocket ( orgId , Application . REFINERY , CurrentPage . LABELING_FUNCTION , handleWebsocketNotification , projectId ) ;
223
201
202
+ const bricksUrlExtension = useMemo ( ( ) => {
203
+ if ( currentHeuristic ?. labelingTaskType == 'INFORMATION_EXTRACTION' ) return 'extractors' ;
204
+ return "classifiers"
205
+ } , [ currentHeuristic ?. labelingTaskType ] ) ;
206
+
224
207
return (
225
208
< HeuristicsLayout updateSourceCode = { ( code : string ) => updateSourceCodeToDisplay ( code ) } >
226
209
{ currentHeuristic && < div >
@@ -244,18 +227,7 @@ export default function LabelingFunction() {
244
227
</ div >
245
228
< div className = "flex items-center justify-center flex-shrink-0" >
246
229
< div className = "flex flex-row flex-nowrap items-center ml-auto" >
247
- < BricksIntegrator
248
- moduleTypeFilter = { currentHeuristic . labelingTaskType == 'MULTICLASS_CLASSIFICATION' ? 'classifier' : 'extractor' }
249
- executionTypeFilter = "pythonFunction,premium"
250
- functionType = "Heuristic"
251
- labelingTaskId = { currentHeuristic . labelingTaskId }
252
- preparedCode = { ( code : string ) => {
253
- updateSourceCode ( code ) ;
254
- setIsInitialLf ( false ) ;
255
- } }
256
- newTaskId = { ( value ) => setValueToLabelingTask ( value ) }
257
- />
258
-
230
+ < VisitBricksButton urlExtension = { bricksUrlExtension } tooltipPlacement = "left" size = "small" />
259
231
< Tooltip content = { TOOLTIPS_DICT . LABELING_FUNCTION . INSTALLED_LIBRARIES } color = "invert" placement = "left" >
260
232
< a href = "https://github.com/code-kern-ai/refinery-lf-exec-env/blob/dev/requirements.txt"
261
233
target = "_blank"
@@ -267,9 +239,7 @@ export default function LabelingFunction() {
267
239
</ div >
268
240
</ div >
269
241
< HeuristicsEditor
270
- isInitial = { isInitialLf }
271
242
updatedSourceCode = { ( code : string ) => updateSourceCode ( code ) }
272
- setIsInitial = { ( val : boolean ) => setIsInitialLf ( val ) }
273
243
setCheckUnsavedChanges = { ( val : boolean ) => setCheckUnsavedChanges ( val ) } />
274
244
275
245
< div className = "mt-2 flex flex-grow justify-between items-center float-right" >
0 commit comments