-
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
Open
knollengewaechs
wants to merge
51
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.
Open
Changes from all commits
Commits
Show all changes
51 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 7411227
improve naming and remove magic numbers
knollengewaechs 2fcf0b9
Merge branch 'master' into encourage-coarser-mags-for-large-volume-an…
knollengewaechs 8425875
fix typo
knollengewaechs 62f6537
WIP: address review
knollengewaechs b1d5b8b
WIP: make react component saga
knollengewaechs df150ca
Merge branch 'master' into encourage-coarser-mags-for-large-volume-an…
knollengewaechs f5bc27f
Merge branch 'master' into encourage-coarser-mags-for-large-volume-an…
knollengewaechs 91ce0e0
clean up interval on saga termination
knollengewaechs 7797555
fix boolean handling
knollengewaechs a1c09f8
improve var naming
knollengewaechs 0fb2b1b
move dev reset method
knollengewaechs d99173d
improve code in new saga
knollengewaechs a236ebe
only update userlocalstorage if toast should NOT be shown again
knollengewaechs 44fcad1
improve boolean handling in warning saga and add util function
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
Some comments aren't visible on the classic Files Changed page.
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
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 |
|---|---|---|
|
|
@@ -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. | ||
|
|
||
87 changes: 87 additions & 0 deletions
87
frontend/javascripts/viewer/model/sagas/many_bucket_updates_warning_saga.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,87 @@ | ||
| import { Button, Checkbox, type CheckboxChangeEvent, Space } from "antd"; | ||
| import Toast from "libs/toast"; | ||
| import UserLocalStorage from "libs/user_local_storage"; | ||
| import { stringToBoolean } from "libs/utils"; | ||
| import { takeEvery } from "typed-redux-saga"; | ||
| import type { Saga } from "viewer/model/sagas/effect-generators"; | ||
|
|
||
| const TOO_MANY_BUCKETS_TOAST_KEY = "manyBucketUpdatesWarningToast"; | ||
| const WARNING_SUPPRESSION_USER_STORAGE_KEY = "suppressManyBucketUpdatesWarning"; | ||
|
|
||
| function* manyBucketUpdatesWarning(): Saga<void> { | ||
| let showWarningToastInThisSession = true; | ||
| const setShowWarningToastInThisSession = (value: boolean) => { | ||
| showWarningToastInThisSession = value; | ||
| }; | ||
| setInterval(() => { | ||
| UserLocalStorage.setItem(WARNING_SUPPRESSION_USER_STORAGE_KEY, "false"); | ||
| console.log("resetting suppressBucketWarning to false every 120s for dev purposes"); | ||
| }, 120 * 1000); | ||
| //TODO_C dev | ||
|
|
||
| function* showWarningToast(): Saga<void> { | ||
| let neverShowAgain = false; | ||
|
|
||
| const onClose = () => { | ||
| Toast.notificationAPI?.destroy(TOO_MANY_BUCKETS_TOAST_KEY); | ||
| if (neverShowAgain) { | ||
| UserLocalStorage.setItem(WARNING_SUPPRESSION_USER_STORAGE_KEY, neverShowAgain.toString()); | ||
| } | ||
| }; | ||
| const handleCheckboxChange = (event: CheckboxChangeEvent) => { | ||
| neverShowAgain = 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 = ( | ||
| <Space> | ||
| {linkToDocsButton} | ||
| {closeButton} | ||
| </Space> | ||
| ); | ||
|
|
||
| const suppressManyBucketUpdatesWarning = stringToBoolean( | ||
| UserLocalStorage.getItem(WARNING_SUPPRESSION_USER_STORAGE_KEY) || "false", | ||
| ); | ||
|
|
||
| if (showWarningToastInThisSession && !suppressManyBucketUpdatesWarning) { | ||
| 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", | ||
| }, | ||
| ); | ||
| setShowWarningToastInThisSession(false); | ||
| } else { | ||
| console.log("suppressing warning toast"); //TODO_C dev | ||
| } | ||
| } | ||
| yield takeEvery("SHOW_MANY_BUCKET_UPDATES_WARNING", showWarningToast); | ||
| } | ||
|
|
||
| export default function* manyBucketUpdatesWarningSaga(): Saga<void> { | ||
| yield takeEvery("WK_READY", manyBucketUpdatesWarning); | ||
| } |
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 { call, delay, 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,48 @@ 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; | ||
| // interval at which the number of buckets in save queue is checked | ||
| const CHECK_NUMBER_OF_BUCKETS_IN_SAVE_QUEUE_INTERVAL_MS = 10 * 1000; | ||
| // sliding time window for which the number of buckets in save queue is summed up | ||
| const CHECK_NUMBER_OF_BUCKETS_SLIDING_WINDOW_MS = 120 * 1000; | ||
|
|
||
| function* watchForNumberOfBucketsInSaveQueue(): Saga<void> { | ||
| const bucketSaveWarningThreshold = features().bucketSaveWarningThreshold; | ||
| let bucketsForCurrentInterval = 0; | ||
| let currentBucketCounts: Array<number> = []; | ||
| const bucketCountArrayLength = Math.floor( | ||
| CHECK_NUMBER_OF_BUCKETS_SLIDING_WINDOW_MS / CHECK_NUMBER_OF_BUCKETS_IN_SAVE_QUEUE_INTERVAL_MS, | ||
| ); | ||
| yield* takeEvery("NOTIFY_ABOUT_UPDATED_BUCKETS", (action: NotifyAboutUpdatedBucketsAction) => { | ||
| bucketsForCurrentInterval += action.count; | ||
| }); | ||
| while (true) { | ||
| yield* delay(CHECK_NUMBER_OF_BUCKETS_IN_SAVE_QUEUE_INTERVAL_MS); | ||
| const sumOfBuckets = _.sum(currentBucketCounts); | ||
| console.log( | ||
|
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. reminder to remove |
||
| "buckets in last interval: ", | ||
| bucketsForCurrentInterval, | ||
| "currentBucketsArray: ", | ||
| currentBucketCounts, | ||
| "sumOfBuckets: ", | ||
| sumOfBuckets, | ||
| ); | ||
| if (sumOfBuckets > bucketSaveWarningThreshold) { | ||
| Store.dispatch(showManyBucketUpdatesWarningAction()); | ||
| } | ||
| currentBucketCounts.push(bucketsForCurrentInterval); | ||
| if (currentBucketCounts.length > bucketCountArrayLength) { | ||
| currentBucketCounts.shift(); | ||
| } | ||
| bucketsForCurrentInterval = 0; | ||
| } | ||
| } | ||
|
|
||
| function* watchForSaveConflicts(): Saga<void> { | ||
| function* checkForNewVersion(): Saga<boolean> { | ||
|
|
||
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.
Uh oh!
There was an error while loading. Please reload this page.