Skip to content

Make user bounding box updates more efficient #8492

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

Merged
merged 50 commits into from
May 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
7bcb4c7
add more supported update actions for user bounding box updates
MichaelBuessemeyer Apr 1, 2025
09de156
[frontend] add new updateActions to add, remove and update individual…
knollengewaechs Apr 3, 2025
7a187fd
WIP: adjust saga code to use new update actions and fixing typing in …
knollengewaechs Apr 3, 2025
cdf546f
[frontend] remove activeUser, timestamp and info from updateActions
knollengewaechs Apr 4, 2025
bfb8746
[frontend] make saga code more DRY and only update changed props
knollengewaechs Apr 4, 2025
78d8d18
[frontend] correctly call helper function
knollengewaechs Apr 4, 2025
6f20124
Merge branch 'master' of github.com:scalableminds/webknossos into mor…
MichaelBuessemeyer Apr 7, 2025
01323e2
Merge branch 'master' of github.com:scalableminds/webknossos into mor…
MichaelBuessemeyer Apr 8, 2025
c680cf2
have single update action for all user bounding box properties
MichaelBuessemeyer Apr 8, 2025
55fdf45
Don't make frontend return a single elemnt list of a user bbox for ne…
MichaelBuessemeyer Apr 8, 2025
d8dcfdd
[frontend] dont send empty update objects
knollengewaechs Apr 9, 2025
b8d0a71
[frontend] WIP: send right bbox object to server
knollengewaechs Apr 9, 2025
21e13e2
[frontend] clean up code
knollengewaechs Apr 9, 2025
374fe71
[frontend] remove unneccesary update actions sent to backend
knollengewaechs Apr 10, 2025
c6a9b0f
[frontend] remove old actions
knollengewaechs Apr 10, 2025
0ae286c
[frontend] use updateUserBoundingBoxVisibilityActions
knollengewaechs Apr 23, 2025
675ae35
[frontend] adjust new update actions name fields
knollengewaechs Apr 23, 2025
4d33b5c
[frontend] rename actions to ...In[Volume|Skeleton]TracingAction
knollengewaechs Apr 25, 2025
b28de89
Merge branch 'master' of github.com:scalableminds/webknossos into mor…
MichaelBuessemeyer May 7, 2025
3ed226f
fix merge
MichaelBuessemeyer May 7, 2025
ae851c3
re-add old UpdateUserBoundingBoxVisibility action & fix naming of act…
MichaelBuessemeyer May 7, 2025
ede8a9c
Merge branch 'master' of github.com:scalableminds/webknossos into mor…
philippotto May 14, 2025
003bcb7
format
philippotto May 14, 2025
b0b8f41
Merge branch 'master' of github.com:scalableminds/webknossos into mor…
MichaelBuessemeyer May 15, 2025
6043d95
add missing serialization of bbox visibility updates & fix bbox actio…
MichaelBuessemeyer May 15, 2025
589554c
format backend
MichaelBuessemeyer May 15, 2025
e4e6908
remove console.log
knollengewaechs May 15, 2025
78af268
WIP frontend: address review 1
knollengewaechs May 21, 2025
93a1955
frontend: add legacy actions back in
knollengewaechs May 22, 2025
df56334
send boolean list to backend
knollengewaechs May 22, 2025
1b9dbeb
[ci skip] WIP: add test and rewrite compact save function
knollengewaechs May 23, 2025
3a21f41
fix test
knollengewaechs May 23, 2025
be66e68
frontend: make types in test prettier
knollengewaechs May 23, 2025
6f10597
add unit tests for TristateJsonTestSuite
fm3 May 26, 2025
04b7d7f
change backend bbox update action to use new optional field parsing
MichaelBuessemeyer May 26, 2025
10816e2
Merge branch 'more-efficient-bbox-update-actions' of github.com:scala…
MichaelBuessemeyer May 26, 2025
dd55178
remove unused code
MichaelBuessemeyer May 26, 2025
5e3c3ce
Merge branch 'master' of github.com:scalableminds/webknossos into mor…
philippotto May 26, 2025
c5ddd56
fix tests
philippotto May 26, 2025
08932b0
reduce amount of checks in diffBoundingBoxes
philippotto May 26, 2025
2d0c543
update changelog
philippotto May 26, 2025
3ed790f
remove redundant check in spec
philippotto May 26, 2025
ac859f3
Apply suggestions from code review
philippotto May 26, 2025
ff5e196
change edit to eye icon
philippotto May 26, 2025
b0fba6f
Merge branch 'master' into more-efficient-bbox-update-actions
philippotto May 27, 2025
841dfd4
fix that bbox color update would not contain all three rgb values if …
philippotto May 27, 2025
81ed241
add test for bbox diffing and fix more
philippotto May 27, 2025
1f70227
rename and move bbox spec
philippotto May 27, 2025
a2979be
fix inversion in didDatasourceChange
philippotto May 27, 2025
002025e
Merge branch 'master' into more-efficient-bbox-update-actions
philippotto May 27, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ For upgrade instructions, please check the [migration guide](MIGRATIONS.released
- Fixed a bug where merging annotations with large tree IDs could lead to an error. [#8643](https://github.com/scalableminds/webknossos/pull/8643)
- Fixed that the segment stats were sometimes not displayed in the context menu. [#8645](https://github.com/scalableminds/webknossos/pull/8645)
- Fixed a bug in zarr streaming where directly after the datastore startup, chunk responses would have status 404 (leading zarr clients to fill with fill_value). Now it will yield status 503, so that clients can retry or escalate this as an error. [#8644](https://github.com/scalableminds/webknossos/pull/8644)
- Improved efficiency of saving bounding box related changes. [#8492](https://github.com/scalableminds/webknossos/pull/8492)
- Fixed regression which caused the import of trees (also of agglomerate skeletons) to crash if the annotation was not empty. [#8656](https://github.com/scalableminds/webknossos/pull/8656)
- Fixed that one could activate unavailable tools or toolkits in read-only mode. [#8658](https://github.com/scalableminds/webknossos/pull/8658)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
} from "history";
import { handleGenericError } from "libs/error_handling";
import Toast from "libs/toast";
import { diffObjects, jsonStringify } from "libs/utils";
import { jsonStringify } from "libs/utils";
import _ from "lodash";
import messages from "messages";
import * as React from "react";
Expand Down Expand Up @@ -313,7 +313,7 @@ class DatasetSettingsView extends React.PureComponent<PropsWithFormAndRouter, St
}

didDatasourceChange(dataSource: Record<string, any>) {
return _.size(diffObjects(dataSource, this.state.savedDataSourceOnServer || {})) > 0;
return !_.isEqual(dataSource, this.state.savedDataSourceOnServer || {});
}

didDatasourceIdChange(dataSource: Record<string, any>) {
Expand Down
47 changes: 21 additions & 26 deletions frontend/javascripts/libs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1084,32 +1084,27 @@ export function getWindowBounds(): [number, number] {
return [width, height];
}

/**
* Deep diff between two object, using lodash
* @param {Object} object Object compared
* @param {Object} base Object to compare with
* @return {Object} Return a new object who represent the diff
*
* Source: https://gist.github.com/Yimiprod/7ee176597fef230d1451#gistcomment-2699388
*/
export function diffObjects(
object: Record<string, any>,
base: Record<string, any>,
): Record<string, any> {
function changes(_object: Record<string, any>, _base: Record<string, any>) {
let arrayIndexCounter = 0;
return _.transform(_object, (result, value, key) => {
if (!_.isEqual(value, _base[key])) {
const resultKey = _.isArray(_base) ? arrayIndexCounter++ : key;
// @ts-expect-error ts-migrate(2571) FIXME: Object is of type 'unknown'.
result[resultKey] =
_.isObject(value) && _.isObject(_base[key]) ? changes(value, _base[key]) : value;
}
});
}

// @ts-expect-error ts-migrate(2322) FIXME: Type 'unknown' is not assignable to type 'Record<s... Remove this comment to see the full error message
return changes(object, base);
export function diffObjects<K extends string | number | symbol, V, Dict extends Record<K, V>>(
a: Dict,
b: Dict,
): Partial<Dict> {
/**
* Returns the difference between two objects as a partial object.
*
* Compares two objects `a` and `b` and returns a new object containing the key-value
* pairs that are present in `b` but not in `a`, using deep equality comparison.
* Note that keys that are not present in b but in a are *not* returned.
*
* @param {Dict} a - The "original" object to compare to as a base.
* @param {Dict} b - The "newer" object that will be used for the returned values.
* @returns {Partial<Dict>} - A partial object containing the key-value pairs that differ.
*
* @example
* const a = { x: 1, y: 2, z: 3 };
* const b = { x: 1, y: 3, q: 4 }; // y is different, z is missing, q was added
* diffObjects(a, b); // returns { y: 3, q: 4 }
*/
return _.fromPairs(_.differenceWith(_.toPairs(b), _.toPairs(a), _.isEqual)) as Partial<Dict>;
}

export function fastDiffSetAndMap<T>(setA: Set<T>, mapB: Map<T, T>) {
Expand Down
Loading