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

Commit

Permalink
Merge branch 'master' into fb-dia-736/export-sync
Browse files Browse the repository at this point in the history
  • Loading branch information
yyassi-heartex authored Nov 30, 2023
2 parents 3474257 + dc7e27b commit 1e54365
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 19 deletions.
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 (!isNaN(similarity_score_upper_limit))
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,
};
});
};
36 changes: 28 additions & 8 deletions src/stores/Tabs/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import { TabSelectedItems } from "./tab_selected_items";
import { History } from '../../utils/history';
import { FF_DEV_1470, FF_LOPS_12, isFF } from "../../utils/feature-flags";
import { CustomJSON, StringOrNumberID, ThresholdType } from "../types";
import { clamp } from "../../utils/helpers";

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

export const Tab = types
.model("View", {
Expand Down Expand Up @@ -53,7 +55,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 +220,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,14 +307,30 @@ export const Tab = types
self.selected = ids;
},

setSemanticSearch(semanticSearchList) {
setSemanticSearch(semanticSearchList, min, max) {
self.semantic_search = semanticSearchList ?? [];
return self.save();
/* if no semantic search we have to clean up threshold */
if (self.semantic_search.length === 0) {
self.threshold = null;
return self.save();
}
/* if we have a min and max we need to make sure we save that too.
this prevents firing 2 view save requests to accomplish the same thing */
return ( !isNaN(min) && !isNaN(max) ) ? self.setSemanticSearchThreshold(min, max) : self.save();
},

setSemanticSearchThreshold(min, max) {
self.threshold = { min, max };
return self.save();
setSemanticSearchThreshold(_min, max) {
const min = clamp(_min ?? THRESHOLD_MIN, THRESHOLD_MIN, max - THRESHOLD_MIN_DIFF);

if (self.semantic_search?.length && !isNaN(min) && !isNaN(max)) {
self.threshold = { min, max };
return self.save();
}
},

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

selectAll() {
Expand Down Expand Up @@ -381,6 +399,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
4 changes: 2 additions & 2 deletions src/stores/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ export const HtmlOrReact = types.custom({
});

export const ThresholdType = types.model("ThresholdType", {
min: types.number,
max: types.number,
min: types.maybeNull(types.number),
max: types.maybeNull(types.number),
});

0 comments on commit 1e54365

Please sign in to comment.