Skip to content

Commit

Permalink
fix: LEAP-947: Check task when we get a response from ML (#5742)
Browse files Browse the repository at this point in the history
Add a wrapper to check that we are going to apply response from
ML-backend to the same task we sent a request from in a first place.

---------

Co-authored-by: robot-ci-heartex <[email protected]>
  • Loading branch information
hlomzik and robot-ci-heartex authored Apr 17, 2024
1 parent 91e2618 commit b2fb581
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 10 deletions.
15 changes: 14 additions & 1 deletion web/apps/labelstudio/src/pages/DataManager/DataManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,20 @@ export const DataManagerPage = ({ ...props }) => {
},
});

lsf.loadSuggestions(suggestionsRequest, (response) => {
// we'll check that we are processing the same task
const wrappedRequest = new Promise(async (resolve, reject) => {
const response = await suggestionsRequest;

// right now task might be an old task,
// so in order to get a current one we need to get it from lsf
if (task.id === dataManager.lsf.task.id) {
resolve(response);
} else {
reject();
}
});

lsf.loadSuggestions(wrappedRequest, (response) => {
if (response.data) {
return response.data.result;
}
Expand Down
2 changes: 1 addition & 1 deletion web/dist/apps/labelstudio/main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/apps/labelstudio/main.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/apps/labelstudio/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/apps/labelstudio/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.js.map

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions web/libs/editor/src/stores/AppStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,11 +796,18 @@ export default types
self.suggestionsRequest = requestId;

self.setFlags({ awaitingSuggestions: true });
const response = yield request;

if (requestId === self.suggestionsRequest) {
self.annotationStore.selected.setSuggestions(dataParser(response));
try {
const response = yield request;

if (requestId === self.suggestionsRequest) {
self.annotationStore.selected.setSuggestions(dataParser(response));
self.setFlags({ awaitingSuggestions: false });
}
} catch(e) {
self.setFlags({ awaitingSuggestions: false });
// @todo handle errors + situation when task is changed
return;
}
});

Expand Down

0 comments on commit b2fb581

Please sign in to comment.