Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: OPTIC-1542: remove a buch of stale feature flags #6954

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 0 additions & 2 deletions label_studio/core/feature_flags/stale_feature_flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
'fflag_feat_front_lsdv_4620_richtext_opimization_060423_short': True,
'fflag_feat_front_dev_3873_labeling_ui_improvements_short': True,
'fflag_feat_back_dev_3756_queue_enrollment_min_short': False,
'fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short': True,
'fflag_fix_front_dev_3617_taxonomy_memory_leaks_fix': True,
'ff_front_dev_2432_auto_save_polygon_draft_210622_short': True,
'ff_front_1170_outliner_030222_short': True,
'fflag_fix_front_lsdv_4620_memory_leaks_100723_short': False,
Expand Down
11 changes: 3 additions & 8 deletions web/apps/labelstudio/src/pages/CreateProject/Config/Preview.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Spinner } from "../../../components";
import { cn } from "../../../utils/bem";
import { FF_DEV_3617, isFF } from "../../../utils/feature-flags";
import "./Config.scss";
import { EMPTY_CONFIG } from "./Template";
import { API_CONFIG } from "../../../config/ApiConfig";
Expand Down Expand Up @@ -75,7 +74,7 @@ export const Preview = ({ config, data, error, loading, project }) => {
task,
interfaces: ["side-column"],
// with SharedStore we should use more late event
[isFF(FF_DEV_3617) ? "onStorageInitialized" : "onLabelStudioLoad"](LS) {
onStorageInitialized(LS) {
LS.settings.bottomSidePanel = true;

const initAnnotation = () => {
Expand All @@ -86,12 +85,8 @@ export const Preview = ({ config, data, error, loading, project }) => {
setStoreReady(true);
};

if (isFF(FF_DEV_3617)) {
// and even then we need to wait a little even after the store is initialized
setTimeout(initAnnotation);
} else {
initAnnotation();
}
// and even then we need to wait a little even after the store is initialized
setTimeout(initAnnotation);
},
});

Expand Down
6 changes: 0 additions & 6 deletions web/apps/labelstudio/src/utils/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ export const FF_DEV_1658 = "ff_front_dev_1658_notification_center_170222_short";
// Model version selector per model backend
export const FF_DEV_1682 = "ff_front_dev_1682_model_version_dropdown_070622_short";

/**
* Addresses the memory leak issue in Taxonomy with Repeater
* @link https://app.launchdarkly.com/default/production/features/fflag_fix_front_dev_3617_taxonomy_memory_leaks_fix
*/
export const FF_DEV_3617 = "fflag_fix_front_dev_3617_taxonomy_memory_leaks_fix";

// Fixes how presigned urls are generated and accessed to remove possibility of CORS errors.
export const FF_LSDV_4711 = "fflag_fix_all_lsdv_4711_cors_errors_accessing_task_data_short";
// Enables "Enterprise Awareness" features
Expand Down
9 changes: 2 additions & 7 deletions web/libs/editor/src/mixins/DrawingTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { types } from "mobx-state-tree";
import Utils from "../utils";
import throttle from "lodash.throttle";
import { MIN_SIZE } from "../tools/Base";
import { FF_DEV_3666, FF_DEV_3793, isFF } from "../utils/feature-flags";
import { FF_DEV_3793, isFF } from "../utils/feature-flags";
import { RELATIVE_STAGE_HEIGHT, RELATIVE_STAGE_WIDTH } from "../components/ImageView/Image";

const DrawingTool = types
Expand Down Expand Up @@ -175,12 +175,7 @@ const DrawingTool = types
},

canStartDrawing() {
return (
!self.isIncorrectControl() &&
(!isFF(FF_DEV_3666) || !self.isIncorrectLabel()) &&
self.canStart() &&
!self.annotation.isDrawing
);
return !self.isIncorrectControl() && !self.isIncorrectLabel() && self.canStart() && !self.annotation.isDrawing;
},

startDrawing(x, y) {
Expand Down
9 changes: 1 addition & 8 deletions web/libs/editor/src/mixins/SelectedModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { types } from "mobx-state-tree";

import Tree from "../core/Tree";
import { isDefined } from "../utils/utilities";
import { FF_DEV_3666, isFF } from "../utils/feature-flags";

const SelectedModelMixin = types
.model()
Expand Down Expand Up @@ -82,13 +81,7 @@ const SelectedModelMixin = types
},

checkMaxUsages() {
if (isFF(FF_DEV_3666)) {
return self.tiedChildren.filter((c) => !c.canBeUsed());
}
const list = self.tiedChildren.filter((c) => !c.canBeUsed());

if (list.length) list.forEach((c) => c.setSelected(false));
return list;
return self.tiedChildren.filter((c) => !c.canBeUsed());
},

selectFirstVisible() {
Expand Down
4 changes: 2 additions & 2 deletions web/libs/editor/src/stores/Annotation/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Types from "../../core/Types";
import { StoreExtender } from "../../mixins/SharedChoiceStore/extender";
import { ViewModel } from "../../tags/visual";
import Utils from "../../utils";
import { FF_DEV_3034, FF_DEV_3391, FF_DEV_3617, FF_SIMPLE_INIT, isFF } from "../../utils/feature-flags";
import { FF_DEV_3034, FF_DEV_3391, FF_SIMPLE_INIT, isFF } from "../../utils/feature-flags";
import { emailFromCreatedBy } from "../../utils/utilities";
import { Annotation } from "./Annotation";
import { HistoryItem } from "./HistoryItem";
Expand Down Expand Up @@ -563,4 +563,4 @@ const AnnotationStoreModel = types
};
});

export default types.compose("AnnotationStore", AnnotationStoreModel, ...(isFF(FF_DEV_3617) ? [StoreExtender] : []));
export default types.compose("AnnotationStore", AnnotationStoreModel, StoreExtender);
56 changes: 21 additions & 35 deletions web/libs/editor/src/tags/control/Taxonomy/Taxonomy.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,7 @@ import SelectedChoiceMixin from "../../../mixins/SelectedChoiceMixin";
import { SharedStoreMixin } from "../../../mixins/SharedChoiceStore/mixin";
import VisibilityMixin from "../../../mixins/Visibility";
import { parseValue } from "../../../utils/data";
import {
FF_DEV_3617,
FF_LEAP_218,
FF_LSDV_4583,
FF_TAXONOMY_ASYNC,
FF_TAXONOMY_LABELING,
isFF,
} from "../../../utils/feature-flags";
import { FF_LEAP_218, FF_LSDV_4583, FF_TAXONOMY_ASYNC, FF_TAXONOMY_LABELING, isFF } from "../../../utils/feature-flags";
import ControlBase from "../Base";
import ClassificationBase from "../ClassificationBase";

Expand Down Expand Up @@ -218,7 +211,7 @@ const Model = types
pid: types.optional(types.string, guidGenerator),

type: "taxonomy",
[isFF(FF_DEV_3617) ? "_children" : "children"]: Types.unionArray(["choice"]),
_children: Types.unionArray(["choice"]),
})
.volatile(() => ({
maxUsagesReached: false,
Expand All @@ -227,22 +220,17 @@ const Model = types
_api: "", // will be filled after the first load in updateValue()
_items: [], // items loaded via API
}))
.views((self) =>
isFF(FF_DEV_3617)
? {
get children() {
return self._children;
},
set children(val) {
self._children = val;
},
get isLabeling() {
return isFF(FF_TAXONOMY_LABELING) && self.labeling;
},
}
: {},
)
.views((self) => ({
get children() {
return self._children;
},
set children(val) {
self._children = val;
},
get isLabeling() {
return isFF(FF_TAXONOMY_LABELING) && self.labeling;
},

get userLabels() {
return self.annotation.store.userLabels;
},
Expand Down Expand Up @@ -362,7 +350,7 @@ const Model = types

const children = ChildrenSnapshots.get(self.name) ?? [];

if (isFF(FF_DEV_3617) && self.store && children.length !== self.children.length) {
if (self.store && children.length !== self.children.length) {
// we have to update it during config parsing to let other code work
// with correctly added children.
// looks like there are no obstacles to do it in the same tick
Expand Down Expand Up @@ -559,17 +547,15 @@ const Model = types
};
})
.preProcessSnapshot((sn) => {
if (isFF(FF_DEV_3617)) {
const children = sn._children ?? sn.children;

if (children && !ChildrenSnapshots.has(sn.name)) {
ChildrenSnapshots.set(sn.name, children);
}
const children = sn._children ?? sn.children;

delete sn._children;
delete sn.children;
if (children && !ChildrenSnapshots.has(sn.name)) {
ChildrenSnapshots.set(sn.name, children);
}

delete sn._children;
delete sn.children;

return sn;
});

Expand All @@ -582,7 +568,7 @@ const TaxonomyModel = types.compose(
AnnotationMixin,
RequiredMixin,
Model,
...(isFF(FF_DEV_3617) ? [SharedStoreMixin] : []),
SharedStoreMixin,
PerRegionMixin,
...(isFF(FF_LSDV_4583) ? [PerItemMixin] : []),
...(isFF(FF_TAXONOMY_LABELING) ? [TaxonomyLabelingResult] : []),
Expand Down Expand Up @@ -614,7 +600,7 @@ const HtxTaxonomy = observer(({ item }) => {
// they are indicated by loading icon on the item itself
const firstLoad = item.isLoadedByApi ? !item.items.length : true;

if (item.loading && isFF(FF_DEV_3617) && firstLoad) {
if (item.loading && isFF(FF_TAXONOMY_ASYNC) && firstLoad) {
return (
<div className={className} style={visibleStyle}>
<div className={styles.taxonomy__loading}>
Expand Down
12 changes: 3 additions & 9 deletions web/libs/editor/src/tags/object/Base.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { types } from "mobx-state-tree";
import isMatch from "lodash.ismatch";
import InfoModal from "../../components/Infomodal/Infomodal";
import { AnnotationMixin } from "../../mixins/AnnotationMixin";
import { FF_DEV_3391, FF_DEV_3666, isFF } from "../../utils/feature-flags";
import { FF_DEV_3391, isFF } from "../../utils/feature-flags";
import { BaseTag } from "../TagBase";

const ObjectBase = types
Expand Down Expand Up @@ -71,14 +71,8 @@ const ObjectBase = types
// `checkMaxUsages` may unselect labels with already reached `maxUsages`
const checkAndCollect = (list, s) => (s.checkMaxUsages ? list.concat(s.checkMaxUsages()) : list);
const allStates = self.states() || [];
let exceeded;

if (isFF(FF_DEV_3666)) {
exceeded = allStates.reduce(checkAndCollect, []).filter((e) => e.selected);
exceeded.forEach((e) => e.setSelected(false));
} else {
exceeded = allStates.reduce(checkAndCollect, []);
}
const exceeded = allStates.reduce(checkAndCollect, []).filter((e) => e.selected);
exceeded.forEach((e) => e.setSelected(false));

const states = self.activeStates() || [];

Expand Down
12 changes: 2 additions & 10 deletions web/libs/editor/src/tags/object/Image/Image.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import ToolsManager from "../../../tools/Manager";
import { parseValue } from "../../../utils/data";
import {
FF_DEV_3377,
FF_DEV_3666,
FF_DEV_3793,
FF_LSDV_4583,
FF_LSDV_4583_6,
Expand Down Expand Up @@ -1106,15 +1105,8 @@ const Model = types
},

checkLabels() {
let labelStates;

if (isFF(FF_DEV_3666)) {
// there should be at least one available label or none of them should be selected
labelStates = self.activeStates() || [];
} else {
// there is should be at least one state selected for *labels object
labelStates = (self.states() || []).filter((s) => s.type.includes("labels"));
}
// there should be at least one available label or none of them should be selected
const labelStates = self.activeStates() || [];
const selectedStates = self.getAvailableStates();

return selectedStates.length !== 0 || labelStates.length === 0;
Expand Down
6 changes: 3 additions & 3 deletions web/libs/editor/src/tags/object/Paragraphs/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { SyncableMixin } from "../../../mixins/Syncable";
import { ParagraphsRegionModel } from "../../../regions/ParagraphsRegion";
import Utils from "../../../utils";
import { parseValue } from "../../../utils/data";
import { FF_DEV_2669, FF_DEV_2918, FF_DEV_3666, FF_LSDV_E_278, isFF } from "../../../utils/feature-flags";
import { FF_DEV_2669, FF_DEV_2918, FF_LSDV_E_278, isFF } from "../../../utils/feature-flags";
import messages from "../../../utils/messages";
import { clamp, isDefined, isValidObjectURL } from "../../../utils/utilities";
import ObjectBase from "../Base";
Expand Down Expand Up @@ -516,7 +516,7 @@ const ParagraphsLoadingModel = types.model().actions((self) => ({

addRegions(ranges) {
const areas = [];
const states = isFF(FF_DEV_3666) ? self.getAvailableStates() : self.activeStates();
const states = self.getAvailableStates();

if (states.length === 0) return;

Expand All @@ -540,7 +540,7 @@ const ParagraphsLoadingModel = types.model().actions((self) => ({
if (isFF(FF_DEV_2918)) {
return self.addRegions([range])[0];
}
const states = isFF(FF_DEV_3666) ? self.getAvailableStates() : self.activeStates();
const states = self.getAvailableStates();

if (states.length === 0) return;

Expand Down
3 changes: 1 addition & 2 deletions web/libs/editor/src/tools/Brush.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { DrawingTool } from "../mixins/DrawingTool";
import { Tool } from "../components/Toolbar/Tool";
import { Range } from "../common/Range/Range";
import { NodeViews } from "../components/Node/Node";
import { FF_DEV_3666, isFF } from "../utils/feature-flags";

const MIN_SIZE = 1;
const MAX_SIZE = 50;
Expand Down Expand Up @@ -213,7 +212,7 @@ const _Tool = types

self.addPoint(x, y);
} else {
if (isFF(FF_DEV_3666) && !self.canStartDrawing()) return;
if (!self.canStartDrawing()) return;
if (self.tagTypes.stateTypes === self.control.type && !self.control.isSelected) return;
self.annotation.history.freeze();
self.mode = "drawing";
Expand Down
4 changes: 2 additions & 2 deletions web/libs/editor/src/tools/KeyPoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import BaseTool from "./Base";
import ToolMixin from "../mixins/Tool";
import { NodeViews } from "../components/Node/Node";
import { DrawingTool } from "../mixins/DrawingTool";
import { FF_DEV_3666, FF_DEV_3793, isFF } from "../utils/feature-flags";
import { FF_DEV_3793, isFF } from "../utils/feature-flags";

const _Tool = types
.model("KeyPointTool", {
Expand All @@ -29,7 +29,7 @@ const _Tool = types
}))
.actions((self) => ({
clickEv(ev, [x, y]) {
if (isFF(FF_DEV_3666) && !self.canStartDrawing()) return;
if (!self.canStartDrawing()) return;

const c = self.control;

Expand Down
12 changes: 0 additions & 12 deletions web/libs/editor/src/utils/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@ export const FF_DEV_3377 = "fflag_fix_front_dev_3377_image_regions_shift_on_resi
// Refactoring to use separate trees for every annotation to allow real annotations in View All
export const FF_DEV_3391 = "fflag_fix_front_dev_3391_interactive_view_all";

/**
* Addresses the memory leak issue in Taxonomy with Repeater
* @link https://app.launchdarkly.com/default/production/features/fflag_fix_front_dev_3617_taxonomy_memory_leaks_fix
*/
export const FF_DEV_3617 = "fflag_fix_front_dev_3617_taxonomy_memory_leaks_fix";

/**
* Fixing maxUsages prop of *labels on region creation.
* @link https://app.launchdarkly.com/default/test/features/fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short
*/
export const FF_DEV_3666 = "fflag_fix_front_dev_3666_max_usages_on_region_creation_171122_short";

/**
* Fixing "Auto Detect" tool undo functionality and bugs with skipNextUndoState.
* @link https://app.launchdarkly.com/default/production/features/fflag_fix_front_dev_1284_auto_detect_undo_281022_short
Expand Down
Loading
Loading