@@ -2,13 +2,13 @@ import { useRouter } from "next/router";
22import HeuristicsLayout from "../shared/HeuristicsLayout" ;
33import { useDispatch , useSelector } from "react-redux" ;
44import { selectProjectId } from "@/src/reduxStore/states/project" ;
5- import { useCallback , useEffect , useState } from "react" ;
5+ import { useCallback , useEffect , useMemo , useState } from "react" ;
66import { selectHeuristic , setActiveHeuristics , updateHeuristicsState } from "@/src/reduxStore/states/pages/heuristics" ;
77import { postProcessCurrentHeuristic , postProcessLastTaskLogs } from "@/src/util/components/projects/projectId/heuristics/heuristicId/heuristics-details-helper" ;
88import { Tooltip } from "@nextui-org/react" ;
99import { TOOLTIPS_DICT } from "@/src/util/tooltip-constants" ;
1010import { 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" ;
1212import HeuristicsEditor from "../shared/HeuristicsEditor" ;
1313import DangerZone from "@/src/components/shared/danger-zone/DangerZone" ;
1414import HeuristicRunButtons from "../shared/HeuristicRunButtons" ;
@@ -22,10 +22,9 @@ import { SampleRecord } from "@/src/types/components/projects/projectId/heuristi
2222import { getPythonFunctionRegExMatch } from "@/submodules/javascript-functions/python-functions-parser" ;
2323import CalculationProgress from "./CalculationProgress" ;
2424import { 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" ;
2626import { CommentType } from "@/src/types/shared/comments" ;
2727import { CommentDataManager } from "@/src/util/classes/comments" ;
28- import BricksIntegrator from "@/src/components/shared/bricks-integrator/BricksIntegrator" ;
2928import { InformationSourceCodeLookup , InformationSourceExamples } from "@/src/util/classes/heuristics" ;
3029import { getInformationSourceTemplate } from "@/src/util/components/projects/projectId/heuristics/heuristics-helper" ;
3130import KernDropdown from "@/submodules/react-components/components/KernDropdown" ;
@@ -36,8 +35,8 @@ import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/use
3635import { getAllComments } from "@/src/services/base/comment" ;
3736import { getLabelingTasksByProjectId } from "@/src/services/base/project" ;
3837import { getHeuristicByHeuristicId , getLabelingFunctionOn10Records , getPayloadByPayloadId , updateHeuristicPost } from "@/src/services/base/heuristic" ;
39- import { getStoreSnapshotValue } from "@/src/reduxStore/store" ;
4038import { Application , CurrentPage } from "@/submodules/react-components/hooks/web-socket/constants" ;
39+ import { VisitBricksButton } from "@/src/components/shared/bricks/VisitBricksButton" ;
4140
4241export default function LabelingFunction ( ) {
4342 const dispatch = useDispatch ( ) ;
@@ -53,7 +52,6 @@ export default function LabelingFunction() {
5352 const [ selectedAttribute , setSelectedAttribute ] = useState < Attribute > ( null ) ;
5453 const [ sampleRecords , setSampleRecords ] = useState < SampleRecord > ( null ) ;
5554 const [ displayLogWarning , setDisplayLogWarning ] = useState < boolean > ( false ) ;
56- const [ isInitialLf , setIsInitialLf ] = useState < boolean > ( null ) ; //null as add state to differentiate between initial, not and unchecked
5755 const [ checkUnsavedChanges , setCheckUnsavedChanges ] = useState ( false ) ;
5856 const [ runOn10IsRunning , setRunOn10IsRunning ] = useState ( false ) ;
5957 const [ justClickedRun , setJustClickedRun ] = useState ( false ) ;
@@ -73,9 +71,8 @@ export default function LabelingFunction() {
7371
7472 useEffect ( ( ) => {
7573 if ( ! currentHeuristic ) return ;
76- if ( isInitialLf == null ) setIsInitialLf ( InformationSourceCodeLookup . isCodeStillTemplate ( currentHeuristic . sourceCode ) != null ) ;
7774 refetchTaskByTaskIdAndProcess ( ) ;
78- } , [ currentHeuristic , isInitialLf ] ) ;
75+ } , [ currentHeuristic ] ) ;
7976
8077 useEffect ( ( ) => {
8178 if ( ! projectId || allUsers . length == 0 ) return ;
@@ -199,28 +196,14 @@ export default function LabelingFunction() {
199196 }
200197 } , [ currentHeuristic ] ) ;
201198
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-
221199 const orgId = useSelector ( selectOrganizationId ) ;
222200 useWebsocket ( orgId , Application . REFINERY , CurrentPage . LABELING_FUNCTION , handleWebsocketNotification , projectId ) ;
223201
202+ const bricksUrlExtension = useMemo ( ( ) => {
203+ if ( currentHeuristic ?. labelingTaskType == 'INFORMATION_EXTRACTION' ) return 'extractors' ;
204+ return "classifiers"
205+ } , [ currentHeuristic ?. labelingTaskType ] ) ;
206+
224207 return (
225208 < HeuristicsLayout updateSourceCode = { ( code : string ) => updateSourceCodeToDisplay ( code ) } >
226209 { currentHeuristic && < div >
@@ -244,18 +227,7 @@ export default function LabelingFunction() {
244227 </ div >
245228 < div className = "flex items-center justify-center flex-shrink-0" >
246229 < 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" />
259231 < Tooltip content = { TOOLTIPS_DICT . LABELING_FUNCTION . INSTALLED_LIBRARIES } color = "invert" placement = "left" >
260232 < a href = "https://github.com/code-kern-ai/refinery-lf-exec-env/blob/dev/requirements.txt"
261233 target = "_blank"
@@ -267,9 +239,7 @@ export default function LabelingFunction() {
267239 </ div >
268240 </ div >
269241 < HeuristicsEditor
270- isInitial = { isInitialLf }
271242 updatedSourceCode = { ( code : string ) => updateSourceCode ( code ) }
272- setIsInitial = { ( val : boolean ) => setIsInitialLf ( val ) }
273243 setCheckUnsavedChanges = { ( val : boolean ) => setCheckUnsavedChanges ( val ) } />
274244
275245 < div className = "mt-2 flex flex-grow justify-between items-center float-right" >
0 commit comments