Skip to content

Commit 9444f7e

Browse files
Bricks Integrator Labels out of sync
1 parent ed3c8e3 commit 9444f7e

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import Statuses from "@/src/components/shared/statuses/Statuses";
22
import { selectAllLookupLists, setAllLookupLists } from "@/src/reduxStore/states/pages/lookup-lists";
3-
import { selectAttributes, selectVisibleAttributeAC, setAllAttributes, updateAttributeById } from "@/src/reduxStore/states/pages/settings";
3+
import { selectAttributes, selectVisibleAttributeAC, setAllAttributes, setLabelingTasksAll, updateAttributeById } from "@/src/reduxStore/states/pages/settings";
44
import { selectProjectId } from "@/src/reduxStore/states/project"
55
import { UPDATE_ATTRIBUTE } from "@/src/services/gql/mutations/project-settings";
66
import { LOOKUP_LISTS_BY_PROJECT_ID } from "@/src/services/gql/queries/lookup-lists";
7-
import { GET_ATTRIBUTES_BY_PROJECT_ID, GET_ATTRIBUTE_BY_ATTRIBUTE_ID, GET_PROJECT_TOKENIZATION } from "@/src/services/gql/queries/project-setting";
7+
import { GET_ATTRIBUTES_BY_PROJECT_ID, GET_ATTRIBUTE_BY_ATTRIBUTE_ID, GET_LABELING_TASKS_BY_PROJECT_ID, GET_PROJECT_TOKENIZATION } from "@/src/services/gql/queries/project-setting";
88
import { Attribute, AttributeState } from "@/src/types/components/projects/projectId/settings/data-schema";
99
import { CurrentPage, DataTypeEnum } from "@/src/types/shared/general";
1010
import { postProcessCurrentAttribute } from "@/src/util/components/projects/projectId/settings/attribute-calculation-helper";
@@ -34,7 +34,7 @@ import { CommentType } from "@/src/types/shared/comments";
3434
import BricksIntegrator from "@/src/components/shared/bricks-integrator/BricksIntegrator";
3535
import { AttributeCodeLookup } from "@/src/util/classes/attribute-calculation";
3636
import Dropdown2 from "@/submodules/react-components/components/Dropdown2";
37-
import { getEmptyBricksIntegratorConfig } from "@/src/util/shared/bricks-integrator-helper";
37+
import { postProcessLabelingTasks, postProcessLabelingTasksSchema } from "@/src/util/components/projects/projectId/settings/labeling-tasks-helper";
3838

3939
const EDITOR_OPTIONS = { theme: 'vs-light', language: 'python', readOnly: false };
4040

@@ -66,6 +66,7 @@ export default function AttributeCalculation() {
6666
const [refetchProjectTokenization] = useLazyQuery(GET_PROJECT_TOKENIZATION, { fetchPolicy: "no-cache" });
6767
const [refetchAttributeByAttributeId] = useLazyQuery(GET_ATTRIBUTE_BY_ATTRIBUTE_ID, { fetchPolicy: "no-cache" });
6868
const [refetchComments] = useLazyQuery(REQUEST_COMMENTS, { fetchPolicy: "no-cache" });
69+
const [refetchLabelingTasksByProjectId] = useLazyQuery(GET_LABELING_TASKS_BY_PROJECT_ID, { fetchPolicy: "network-only" });
6970

7071
useEffect(unsubscribeWSOnDestroy(router, [CurrentPage.ATTRIBUTE_CALCULATION]), []);
7172

@@ -89,6 +90,7 @@ export default function AttributeCalculation() {
8990
dispatch(setAllLookupLists(res.data['knowledgeBasesByProjectId']));
9091
});
9192
}
93+
refetchLabelingTasksAndProcess();
9294
checkProjectTokenization();
9395
WebSocketsService.subscribeToNotification(CurrentPage.ATTRIBUTE_CALCULATION, {
9496
projectId: projectId,
@@ -249,6 +251,13 @@ export default function AttributeCalculation() {
249251
setIsInitial(false);
250252
}
251253

254+
function refetchLabelingTasksAndProcess() {
255+
refetchLabelingTasksByProjectId({ variables: { projectId: projectId } }).then((res) => {
256+
const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']);
257+
dispatch(setLabelingTasksAll(postProcessLabelingTasksSchema(labelingTasks)));
258+
});
259+
}
260+
252261
const handleWebsocketNotification = useCallback((msgParts: string[]) => {
253262
if (!currentAttribute) return;
254263
if (!projectId) return;

src/components/projects/projectId/heuristics/heuristicId/active-learning/ActiveLearning.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { getPythonClassName, getPythonClassRegExMatch } from "@/submodules/javas
2828
import { WebSocketsService } from "@/src/services/base/web-sockets/WebSocketsService";
2929
import { CurrentPage } from "@/src/types/shared/general";
3030
import { unsubscribeWSOnDestroy } from "@/src/services/base/web-sockets/web-sockets-helper";
31-
import { selectAllUsers, setBricksIntegrator, setComments } from "@/src/reduxStore/states/general";
31+
import { selectAllUsers, setBricksIntegrator, setComments, setLabelsBricksIntegrator } from "@/src/reduxStore/states/general";
3232
import { CommentType } from "@/src/types/shared/comments";
3333
import { CommentDataManager } from "@/src/util/classes/comments";
3434
import { REQUEST_COMMENTS } from "@/src/services/gql/queries/projects";
@@ -37,6 +37,7 @@ import { InformationSourceCodeLookup, InformationSourceExamples } from "@/src/ut
3737
import { getInformationSourceTemplate } from "@/src/util/components/projects/projectId/heuristics/heuristics-helper";
3838
import Dropdown2 from "@/submodules/react-components/components/Dropdown2";
3939
import LoadingIcon from "@/src/components/shared/loading/LoadingIcon";
40+
import { BricksCodeParser } from "@/src/util/classes/bricks-integrator/bricks-integrator";
4041

4142
export default function ActiveLearning() {
4243
const dispatch = useDispatch();
@@ -221,7 +222,7 @@ export default function ActiveLearning() {
221222
function setValueToLabelingTask(value: string) {
222223
const labelingTask = labelingTasks.find(a => a.id == value);
223224
updateHeuristicMut({ variables: { projectId: projectId, informationSourceId: currentHeuristic.id, labelingTaskId: labelingTask.id } }).then((res) => {
224-
dispatch(updateHeuristicsState(currentHeuristic.id, { labelingTaskId: labelingTask.id, labelingTaskName: labelingTask.name, labels: labelingTask.labels }))
225+
dispatch(updateHeuristicsState(currentHeuristic.id, { labelingTaskId: labelingTask.id, labelingTaskName: labelingTask.name, labels: labelingTask.labels }));
225226
});
226227
}
227228

src/components/shared/bricks-integrator/BricksIntegrator.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ export default function BricksIntegrator(_props: BricksIntegratorProps) {
372372
const configCopy = BricksCodeParser.prepareCode(jsonCopy(config), props.executionTypeFilter, props.nameLookups, taskId, forIde, labelingTasks);
373373
dispatch(setBricksIntegrator(configCopy));
374374
}
375-
props.newTaskId(taskId)
375+
dispatch(setLabelsBricksIntegrator(BricksCodeParser.getLabels(taskId, labelingTasks)))
376+
props.newTaskId(taskId);
376377
}
377378

378379
return (

src/components/shared/bricks-integrator/VariableSelect.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { selectBricksIntegratorAttributes, selectBricksIntegratorEmbeddings, selectBricksIntegratorLabelingTasks, selectBricksIntegratorLabels, selectBricksIntegratorLanguages, selectBricksIntegratorLookupLists, setAttributesBricksIntegrator, setEmbeddingsBricksIntegrator, setLabelingTasksBricksIntegrator, setLabelsBricksIntegrator, setLanguagesBricksIntegrator, setLookupListsBricksIntegrator } from "@/src/reduxStore/states/general";
2-
import { selectLabelingTasksAll, setLabelingTasksAll } from "@/src/reduxStore/states/pages/settings";
1+
import { selectBricksIntegratorAttributes, selectBricksIntegratorEmbeddings, selectBricksIntegratorLabels, selectBricksIntegratorLanguages, selectBricksIntegratorLookupLists, setAttributesBricksIntegrator, setEmbeddingsBricksIntegrator, setLabelingTasksBricksIntegrator, setLabelsBricksIntegrator, setLanguagesBricksIntegrator, setLookupListsBricksIntegrator } from "@/src/reduxStore/states/general";
2+
import { selectLabelingTasksAll } from "@/src/reduxStore/states/pages/settings";
33
import { selectProjectId } from "@/src/reduxStore/states/project";
44
import { WebSocketsService } from "@/src/services/base/web-sockets/WebSocketsService";
55
import { unsubscribeWSOnDestroy } from "@/src/services/base/web-sockets/web-sockets-helper";
@@ -41,7 +41,6 @@ export default function VariableSelect(props: VariableSelectProps) {
4141

4242
useEffect(() => {
4343
if (!projectId) return;
44-
refetchLabelingTasksAndProcess(null);
4544
WebSocketsService.subscribeToNotification(CurrentPage.BRICKS_INTEGRATOR, {
4645
projectId: projectId,
4746
whitelist: ['attributes_updated', 'calculate_attribute', 'label_created', 'label_deleted', 'labeling_task_deleted', 'labeling_task_updated', 'labeling_task_created', 'embedding', 'embedding_deleted', 'knowledge_base_deleted', 'knowledge_base_created'],
@@ -146,7 +145,6 @@ export default function VariableSelect(props: VariableSelectProps) {
146145
function refetchLabelingTasksAndProcess(typeFilter: string) {
147146
refetchLabelingTasksByProjectId({ variables: { projectId: projectId } }).then((res) => {
148147
const labelingTasks = postProcessLabelingTasks(res['data']['projectByProjectId']['labelingTasks']['edges']);
149-
dispatch(setLabelingTasksAll(labelingTasks));
150148
if (!labelingTasks) {
151149
console.log("labeling Tasks not yet loaded");
152150
return null;

0 commit comments

Comments
 (0)