Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

fix: DIA-666: [FE] Semantic search polish #266

Merged
merged 21 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4004056
fix: DIA-666: [FE] Semantic search polish
yyassi-heartex Nov 14, 2023
e9eef24
fixing where the upper limit is being set
yyassi-heartex Nov 14, 2023
3a23b25
fixing a null check
yyassi-heartex Nov 15, 2023
abd9f53
Merge branch 'master' into fb-dia-666/semantic-search-polish
yyassi-heartex Nov 15, 2023
46f36d5
applying precision update to similiary upper limit
yyassi-heartex Nov 16, 2023
ead1227
its possible to provide 0 as the max which we cant do defaulting to 10
yyassi-heartex Nov 16, 2023
e69cbd6
dont need to send default - if upper limit undefined just dont show t…
yyassi-heartex Nov 16, 2023
6872fe2
we now invoke an event on view reload
yyassi-heartex Nov 20, 2023
bc180a1
Merge branch 'master' into fb-dia-666/semantic-search-polish
yyassi-heartex Nov 20, 2023
6a748bd
setting a safe fallback for when there is no upper limit
yyassi-heartex Nov 20, 2023
f51cf82
Revert "setting a safe fallback for when there is no upper limit"
yyassi-heartex Nov 20, 2023
4f098f4
send it back if its any nan
yyassi-heartex Nov 20, 2023
cf7ad78
we dont need to save threshold if there is no semantic search
yyassi-heartex Nov 21, 2023
61b3f3a
oops inverse logic
yyassi-heartex Nov 21, 2023
c5d1c39
Merge branch 'master' into fb-dia-666/semantic-search-polish
yyassi-heartex Nov 22, 2023
8af3594
Merge branch 'master' into fb-dia-666/semantic-search-polish
yyassi-heartex Nov 23, 2023
094fafc
this'll prevent a bad min from being saved
yyassi-heartex Nov 23, 2023
fb5f46a
preventing total failure on null for threshold min/max but preventing…
yyassi-heartex Nov 24, 2023
86de28b
Merge branch 'master' into fb-dia-666/semantic-search-polish
yyassi-heartex Nov 27, 2023
9bb8caf
small change to help reduce the number of times we save the view
yyassi-heartex Nov 28, 2023
290f2b2
Merge branch 'master' into fb-dia-666/semantic-search-polish
yyassi-heartex Nov 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/components/Filters/types/String.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { observer } from "mobx-react";
import React from "react";
import { FilterInput } from "../FilterInput";
import { VariantSelect } from "./List";

const BaseInput = observer(({ value, onChange, placeholder }) => {
return (
Expand Down Expand Up @@ -46,10 +45,4 @@ export const StringFilter = [
valueType: "single",
input: (props) => <BaseInput {...props} />,
},
{
key: "similar_to",
label: "similar to",
valueType: "list",
input: (props) => <VariantSelect {...props} />,
},
];
8 changes: 6 additions & 2 deletions src/stores/DataStores/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DynamicModel, registerModel } from "../DynamicModel";
import { CustomJSON } from "../types";
import { FF_DEV_2536, FF_LOPS_E_3, isFF } from "../../utils/feature-flags";

const SIMILARITY_UPPER_LIMIT_PRECISION = 1000;
const fileAttributes = types.model({
"certainty": types.optional(types.maybeNull(types.number), 0),
"distance": types.optional(types.maybeNull(types.number), 0),
Expand Down Expand Up @@ -218,17 +219,19 @@ export const create = (columns) => {
},

postProcessData(data) {
const { total_annotations, total_predictions } = data;
const { total_annotations, total_predictions, similarity_score_upper_limit } = data;

if (total_annotations !== null)
self.totalAnnotations = total_annotations;
if (total_predictions !== null)
self.totalPredictions = total_predictions;
if (similarity_score_upper_limit !== null)
self.similarityUpperLimit = (Math.ceil(similarity_score_upper_limit * SIMILARITY_UPPER_LIMIT_PRECISION) / SIMILARITY_UPPER_LIMIT_PRECISION);
},

}))
.preProcessSnapshot((snapshot) => {
const { total_annotations, total_predictions, ...sn } = snapshot;
const { total_annotations, total_predictions, similarity_score_upper_limit, ...sn } = snapshot;

return {
...sn,
Expand All @@ -239,6 +242,7 @@ export const create = (columns) => {
})),
totalAnnotations: total_annotations,
totalPredictions: total_predictions,
similarityUpperLimit: similarity_score_upper_limit,
};
});
};
20 changes: 14 additions & 6 deletions src/stores/Tabs/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ import { History } from '../../utils/history';
import { FF_DEV_1470, FF_LOPS_12, isFF } from "../../utils/feature-flags";
import { CustomJSON, StringOrNumberID, ThresholdType } from "../types";

const DEFAULT_THRESHOLD = { min: 0, max: 10 };

export const Tab = types
.model("View", {
id: StringOrNumberID,
Expand Down Expand Up @@ -53,7 +51,7 @@ export const Tab = types
editable: true,
deletable: true,
semantic_search: types.optional(types.array(CustomJSON), []),
threshold: types.optional(ThresholdType, DEFAULT_THRESHOLD),
threshold: types.optional(types.maybeNull(ThresholdType), null),
})
.volatile(() => {
const defaultWidth = getComputedStyle(document.body).getPropertyValue("--menu-sidebar-width").replace("px", "").trim();
Expand Down Expand Up @@ -218,7 +216,7 @@ export const Tab = types
columnsDisplayType: self.columnsDisplayType.toPOJO(),
gridWidth: self.gridWidth,
semantic_search: self.semantic_search?.toJSON() ?? [],
threshold: self.threshold?.toJSON() ?? DEFAULT_THRESHOLD,
threshold: self.threshold?.toJSON(),
};

if (self.saved || apiVersion === 1) {
Expand Down Expand Up @@ -305,16 +303,24 @@ export const Tab = types
self.selected = ids;
},

setSemanticSearch(semanticSearchList) {
setSemanticSearch(semanticSearchList, save = true) {
self.semantic_search = semanticSearchList ?? [];
return self.save();
if (self.semantic_search.length === 0) {
self.threshold = null;
}
return save && self.save();
},

setSemanticSearchThreshold(min, max) {
self.threshold = { min, max };
return self.save();
},

clearSemanticSearchThreshold(save = true) {
self.threshold = null;
return save && self.save();
},

selectAll() {
self.selected.toggleSelectedAll();
},
Expand Down Expand Up @@ -381,6 +387,8 @@ export const Tab = types
} else if (isFF(FF_LOPS_12) && self.root.SDK.type === 'labelops') {
yield self.dataStore.reload({ query: self.query, interaction });
}

getRoot(self).SDK.invoke("tabReloaded", self);
}),

deleteFilter(filter) {
Expand Down