-
Notifications
You must be signed in to change notification settings - Fork 29
Encourage coarser mags when annotating a high number of voxels #8961
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
base: master
Are you sure you want to change the base?
Changes from all commits
c4ba568
f6074a1
98d45b2
cfae01d
425959b
5819d92
683849c
fa10734
461fc7a
a5fbb91
18fc591
977f391
2012b1b
63c6332
c956a5b
38df61b
63129bb
9e916a2
fd7e73c
a9aa7ad
a9165c5
c6af70d
f8bf436
613f58b
9f22533
1696a6b
b68663f
3a1463f
dc774c1
1edc7e8
64093d5
b00c9c9
5a7d667
401e815
87e68b5
3f61c1a
658c788
7411227
2fcf0b9
8425875
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import type DataCube from "viewer/model/bucket_data_handling/data_cube"; | |
import { createCompressedUpdateBucketActions } from "viewer/model/bucket_data_handling/wkstore_adapter"; | ||
import Store from "viewer/store"; | ||
import { escalateErrorAction } from "../actions/actions"; | ||
import { pushSaveQueueTransaction } from "../actions/save_actions"; | ||
import { notifyAboutUpdatedBucketsAction, pushSaveQueueTransaction } from "../actions/save_actions"; | ||
import type { UpdateActionWithoutIsolationRequirement } from "../sagas/volume/update_actions"; | ||
|
||
// Only process the PushQueue after there was no user interaction (or bucket modification due to | ||
|
@@ -155,7 +155,8 @@ class PushQueue { | |
createCompressedUpdateBucketActions(batch), | ||
); | ||
Store.dispatch(pushSaveQueueTransaction(items)); | ||
|
||
Store.dispatch(notifyAboutUpdatedBucketsAction(items.length)); | ||
console.log("notify about ", items.length, " items"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
this.compressingBucketCount -= batch.length; | ||
} catch (error) { | ||
// See other usage of escalateErrorAction for a detailed explanation. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
import { getUpdateActionLog } from "admin/rest_api"; | ||
import features from "features"; | ||
import ErrorHandling from "libs/error_handling"; | ||
import Toast from "libs/toast"; | ||
import { sleep } from "libs/utils"; | ||
import _ from "lodash"; | ||
import { call, fork, put, takeEvery } from "typed-redux-saga"; | ||
import type { APIUpdateActionBatch } from "types/api_types"; | ||
import { getLayerByName, getMappingInfo } from "viewer/model/accessors/dataset_accessor"; | ||
import { setVersionNumberAction } from "viewer/model/actions/save_actions"; | ||
import { showManyBucketUpdatesWarningAction } from "viewer/model/actions/annotation_actions"; | ||
import { | ||
type NotifyAboutUpdatedBucketsAction, | ||
setVersionNumberAction, | ||
} from "viewer/model/actions/save_actions"; | ||
import { applySkeletonUpdateActionsFromServerAction } from "viewer/model/actions/skeletontracing_actions"; | ||
import { applyVolumeUpdateActionsFromServerAction } from "viewer/model/actions/volumetracing_actions"; | ||
import { globalPositionToBucketPositionWithMag } from "viewer/model/helpers/position_converter"; | ||
import type { Saga } from "viewer/model/sagas/effect-generators"; | ||
import { select } from "viewer/model/sagas/effect-generators"; | ||
import { ensureWkReady } from "viewer/model/sagas/ready_sagas"; | ||
import { Model } from "viewer/singletons"; | ||
import { Model, Store } from "viewer/singletons"; | ||
import type { SkeletonTracing, VolumeTracing } from "viewer/store"; | ||
import { takeEveryWithBatchActionSupport } from "../saga_helpers"; | ||
import { updateLocalHdf5Mapping } from "../volume/mapping_saga"; | ||
|
@@ -31,11 +36,49 @@ export function* setupSavingToServer(): Saga<void> { | |
yield* takeEvery("INITIALIZE_ANNOTATION_WITH_TRACINGS", setupSavingForAnnotation); | ||
yield* takeEveryWithBatchActionSupport("INITIALIZE_SKELETONTRACING", setupSavingForTracingType); | ||
yield* takeEveryWithBatchActionSupport("INITIALIZE_VOLUMETRACING", setupSavingForTracingType); | ||
yield* takeEvery("WK_READY", watchForNumberOfBucketsInSaveQueue); | ||
} | ||
|
||
const VERSION_POLL_INTERVAL_COLLAB = 10 * 1000; | ||
const VERSION_POLL_INTERVAL_READ_ONLY = 60 * 1000; | ||
const VERSION_POLL_INTERVAL_SINGLE_EDITOR = 30 * 1000; | ||
const CHECK_NUMBER_OF_BUCKETS_IN_SAVE_QUEUE_INTERVAL = 10 * 1000; | ||
const CHECK_NUMBER_OF_BUCKETS_SLIDING_WINDOW = 120 * 1000; | ||
|
||
function* watchForNumberOfBucketsInSaveQueue(): Saga<void> { | ||
const bucketSaveWarningThreshold = features().bucketSaveWarningThreshold; | ||
let bucketsForCurrentInterval = 0; | ||
let currentBuckets: Array<number> = []; | ||
const bucketCountArrayLength = Math.floor( | ||
CHECK_NUMBER_OF_BUCKETS_SLIDING_WINDOW / CHECK_NUMBER_OF_BUCKETS_IN_SAVE_QUEUE_INTERVAL, | ||
); | ||
yield* call( | ||
setInterval, | ||
() => { | ||
const sumOfBuckets = _.sum(currentBuckets); | ||
console.log( | ||
"buckets in last interval: ", | ||
bucketsForCurrentInterval, | ||
"currentBucketsArray: ", | ||
currentBuckets, | ||
"sumOfBuckets: ", | ||
sumOfBuckets, | ||
Comment on lines
+59
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
); | ||
if (sumOfBuckets > bucketSaveWarningThreshold) { | ||
Store.dispatch(showManyBucketUpdatesWarningAction()); | ||
} | ||
currentBuckets.push(bucketsForCurrentInterval); | ||
if (currentBuckets.length > bucketCountArrayLength) { | ||
currentBuckets.shift(); | ||
} | ||
bucketsForCurrentInterval = 0; | ||
}, | ||
CHECK_NUMBER_OF_BUCKETS_IN_SAVE_QUEUE_INTERVAL, | ||
); | ||
yield* takeEvery("NOTIFY_ABOUT_UPDATED_BUCKETS", (action: NotifyAboutUpdatedBucketsAction) => { | ||
bucketsForCurrentInterval += action.count; | ||
}); | ||
} | ||
Comment on lines
+48
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove dev logging before merge. The sliding-window bucket tracking logic is sound, but the console.log statements (Lines 59-66) are dev artifacts and should be removed. Apply this diff: yield* call(
setInterval,
() => {
const sumOfBuckets = _.sum(currentBuckets);
- console.log(
- "buckets in last interval: ",
- bucketsForCurrentInterval,
- "currentBucketsArray: ",
- currentBuckets,
- "sumOfBuckets: ",
- sumOfBuckets,
- );
if (sumOfBuckets > bucketSaveWarningThreshold) {
Store.dispatch(showManyBucketUpdatesWarningAction());
}
🤖 Prompt for AI Agents
|
||
|
||
function* watchForSaveConflicts(): Saga<void> { | ||
function* checkForNewVersion(): Saga<boolean> { | ||
|
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,99 @@ | ||||||||||
import { Button, Checkbox, type CheckboxChangeEvent, Space } from "antd"; | ||||||||||
import { useInterval } from "libs/react_helpers"; | ||||||||||
import Toast from "libs/toast"; | ||||||||||
import UserLocalStorage from "libs/user_local_storage"; | ||||||||||
import { useCallback, useEffect, useRef } from "react"; | ||||||||||
import { useReduxActionListener } from "viewer/model/helpers/listener_helpers"; | ||||||||||
|
||||||||||
const TOO_MANY_BUCKETS_TOAST_KEY = "manyBucketUpdatesWarningToast"; | ||||||||||
const WARNING_SUPPRESSION_USER_STORAGE_KEY = "suppressBucketWarning"; | ||||||||||
|
||||||||||
export function ManyBucketUpdatesWarning(): React.ReactNode { | ||||||||||
const notificationAPIRef = useRef(Toast.notificationAPI); | ||||||||||
const neverShowAgainRef = useRef(false); | ||||||||||
const dontShowAgainInThisSessionRef = useRef(false); | ||||||||||
|
||||||||||
useEffect(() => { | ||||||||||
if (Toast.notificationAPI != null) { | ||||||||||
notificationAPIRef.current = Toast.notificationAPI; | ||||||||||
} | ||||||||||
}, []); | ||||||||||
useInterval(() => { | ||||||||||
UserLocalStorage.setItem("suppressBucketWarning", "false"); | ||||||||||
console.log("resetting suppressBucketWarning to false every 120s for dev purposes"); | ||||||||||
}, 120 * 1000); //TODO_C dev | ||||||||||
Comment on lines
+21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove dev-only interval before merge. The Apply this diff: - useInterval(() => {
- UserLocalStorage.setItem("suppressBucketWarning", "false");
- console.log("resetting suppressBucketWarning to false every 120s for dev purposes");
- }, 120 * 1000); //TODO_C dev
- 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
|
||||||||||
const onClose = useCallback(() => { | ||||||||||
notificationAPIRef.current?.destroy(TOO_MANY_BUCKETS_TOAST_KEY); | ||||||||||
UserLocalStorage.setItem("suppressBucketWarning", neverShowAgainRef.current.toString()); | ||||||||||
}, []); | ||||||||||
const handleCheckboxChange = (event: CheckboxChangeEvent) => { | ||||||||||
neverShowAgainRef.current = event.target.checked; | ||||||||||
}; | ||||||||||
|
||||||||||
const warningMessage = | ||||||||||
"You are annotating a large area with fine magnifications. This can significantly slow down WEBKNOSSOS. Consider creating an annotation or annotation layer with restricted magnifications."; | ||||||||||
const linkToDocs = | ||||||||||
"https://docs.webknossos.org/volume_annotation/import_export.html#restricting-magnifications"; | ||||||||||
const neverShowAgainCheckbox = ( | ||||||||||
<Checkbox onChange={handleCheckboxChange} style={{ marginTop: "8px", marginBottom: "5px" }}> | ||||||||||
Never show this again | ||||||||||
</Checkbox> | ||||||||||
); | ||||||||||
const closeButton = ( | ||||||||||
<Button | ||||||||||
onClick={() => { | ||||||||||
onClose(); | ||||||||||
}} | ||||||||||
> | ||||||||||
Close | ||||||||||
</Button> | ||||||||||
); | ||||||||||
const linkToDocsButton = ( | ||||||||||
<Button href={linkToDocs} target="_blank" rel="noopener noreferrer" type="primary"> | ||||||||||
Learn how | ||||||||||
</Button> | ||||||||||
); | ||||||||||
const footer = ( | ||||||||||
<div> | ||||||||||
<Space> | ||||||||||
{linkToDocsButton} | ||||||||||
{closeButton} | ||||||||||
</Space> | ||||||||||
</div> | ||||||||||
); | ||||||||||
|
||||||||||
const showWarningToast = () => { | ||||||||||
const suppressManyBucketUpdatesWarning = UserLocalStorage.getItem( | ||||||||||
WARNING_SUPPRESSION_USER_STORAGE_KEY, | ||||||||||
); | ||||||||||
if (notificationAPIRef.current == null) { | ||||||||||
return null; | ||||||||||
} | ||||||||||
if ( | ||||||||||
suppressManyBucketUpdatesWarning !== "true" && | ||||||||||
dontShowAgainInThisSessionRef.current !== true | ||||||||||
) { | ||||||||||
console.warn(warningMessage + " For more info, visit: " + linkToDocs); | ||||||||||
Toast.warning( | ||||||||||
<> | ||||||||||
{warningMessage} | ||||||||||
<br /> | ||||||||||
{neverShowAgainCheckbox} | ||||||||||
</>, | ||||||||||
{ | ||||||||||
customFooter: footer, | ||||||||||
key: TOO_MANY_BUCKETS_TOAST_KEY, | ||||||||||
sticky: true, | ||||||||||
onClose, | ||||||||||
className: "many-bucket-updates-warning", | ||||||||||
}, | ||||||||||
); | ||||||||||
dontShowAgainInThisSessionRef.current = true; | ||||||||||
} else { | ||||||||||
console.log("suppressing warning toast"); //TODO_C dev | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove dev logging before merge. The console.log at Line 94 is a dev artifact and should be removed. Apply this diff: dontShowAgainInThisSessionRef.current = true;
} else {
- console.log("suppressing warning toast"); //TODO_C dev
} 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||
} | ||||||||||
}; | ||||||||||
useReduxActionListener("SHOW_MANY_BUCKET_UPDATES_WARNING", () => showWarningToast()); | ||||||||||
return null; | ||||||||||
} |
Uh oh!
There was an error while loading. Please reload this page.