-
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
Draft
knollengewaechs
wants to merge
37
commits into
master
Choose a base branch
from
encourage-coarser-mags-for-large-volume-annotations
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+185
−7
Draft
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
c4ba568
WIP: add logging for number of updated buckets
knollengewaechs f6074a1
include more logging
knollengewaechs 98d45b2
update auto save time
knollengewaechs cfae01d
revert some changes
knollengewaechs 425959b
add toast when more than 4k buckets are in pushqueeue
knollengewaechs 5819d92
Merge branch 'master' into encourage-coarser-mags-for-large-volume-an…
knollengewaechs 683849c
fix typo
knollengewaechs fa10734
add docs for mag restrictions
knollengewaechs 461fc7a
revert dev changes
knollengewaechs a5fbb91
move code to save_queue
knollengewaechs 18fc591
undo rename
knollengewaechs 977f391
remove console.log
knollengewaechs 2012b1b
save intermediate result before moving stuff to data_cube
knollengewaechs 63c6332
to be reverted: check total number of buckets
knollengewaechs c956a5b
move code from data_cube to save_queue_draining
knollengewaechs 38df61b
dispatch actions in pushqueue and consume in save_saga
knollengewaechs 63129bb
Merge branch 'master' into encourage-coarser-mags-for-large-volume-an…
knollengewaechs 9e916a2
WIP: start to implement modal
knollengewaechs fd7e73c
extract toast
knollengewaechs a9aa7ad
turn toast into modal and dispatch action to open it
knollengewaechs a9165c5
move warning value to application.conf
knollengewaechs c6af70d
make warning toast a react component, fix functionality within toast
knollengewaechs f8bf436
Merge branch 'master' into encourage-coarser-mags-for-large-volume-an…
knollengewaechs 613f58b
add styling to toast
knollengewaechs 9f22533
refresh snapshot
knollengewaechs 1696a6b
fix tests
knollengewaechs b68663f
change time interval for bucket check to 120s
knollengewaechs 3a1463f
fix time intervals and remove some dev changes
knollengewaechs dc774c1
improve time intervals
knollengewaechs 1edc7e8
remember closing modal in session
knollengewaechs 64093d5
fix time interval
knollengewaechs b00c9c9
fix checkbox
knollengewaechs 5a7d667
Merge branch 'master' into encourage-coarser-mags-for-large-volume-an…
knollengewaechs 401e815
re-add activeUser to e2e snapshots
fm3 87e68b5
update text
knollengewaechs 3f61c1a
update button test
knollengewaechs 658c788
Merge branch 'master' into encourage-coarser-mags-for-large-volume-an…
knollengewaechs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { showTooManyBucketsWarningToastAction } from "viewer/model/actions/annotation_actions"; | ||
import { | ||
type NotifyAboutUpdateBucketAction, | ||
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,45 @@ 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; | ||
|
||
function* watchForNumberOfBucketsInSaveQueue(): Saga<void> { | ||
const bucketSaveWarningThreshold = features().bucketSaveWarningThreshold; | ||
let bucketsForCurrentInterval = 0; | ||
let currentBuckets: Array<number> = []; | ||
yield* call( | ||
setInterval, | ||
() => { | ||
const sumOfBuckets = _.sum(currentBuckets); | ||
console.log( | ||
"buckets in last interval: ", | ||
bucketsForCurrentInterval, | ||
"currentBucketsArray: ", | ||
currentBuckets, | ||
"sumOfBuckets: ", | ||
sumOfBuckets, | ||
Comment on lines
+55
to
+61
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(showTooManyBucketsWarningToastAction()); | ||
} | ||
currentBuckets.push(bucketsForCurrentInterval); | ||
if (currentBuckets.length > 12) { | ||
currentBuckets.shift(); | ||
} | ||
bucketsForCurrentInterval = 0; | ||
}, | ||
CHECK_NUMBER_OF_BUCKETS_IN_SAVE_QUEUE_INTERVAL, | ||
); | ||
yield* takeEvery("NOTIFY_ABOUT_UPDATE_BUCKET_ACTION", (action: NotifyAboutUpdateBucketAction) => { | ||
bucketsForCurrentInterval += action.count; | ||
}); | ||
} | ||
|
||
function* watchForSaveConflicts(): Saga<void> { | ||
function* checkForNewVersion(): Saga<boolean> { | ||
|
93 changes: 93 additions & 0 deletions
93
frontend/javascripts/viewer/view/components/many_buckets_warning.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
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 = "tooManyBucketsWarningModal"; | ||
|
||
export function TooManyBucketsWarning(): 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 | ||
|
||
const onClose = useCallback(() => { | ||
notificationAPIRef.current?.destroy(TOO_MANY_BUCKETS_TOAST_KEY); | ||
dontShowAgainInThisSessionRef.current = true; | ||
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 supressTooManyBucketsWarning = UserLocalStorage.getItem("suppressBucketWarning"); | ||
if (notificationAPIRef.current == null) { | ||
return null; | ||
} | ||
if (supressTooManyBucketsWarning !== "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-buckets-warning", | ||
}, | ||
); | ||
} else { | ||
console.log("suppressing warning toast"); | ||
} | ||
}; | ||
useReduxActionListener("SHOW_TOO_MANY_BUCKETS_WARNING_TOAST", () => showWarningToast()); | ||
return null; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove