Skip to content

Commit 8d066c3

Browse files
authored
Merge branch 'master' into objectid-tracingstore
2 parents d190849 + 3d93c5c commit 8d066c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1151
-642
lines changed

conf/messages

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ zarr.invalidFirstChunkCoord=First Channel must be 0
149149
zarr.chunkNotFound=Could not find the requested chunk
150150
zarr.notEnoughCoordinates=Invalid number of chunk coordinates. Expected to get at least 3 dimensions and channel 0.
151151
zarr.invalidAdditionalCoordinates=Invalid additional coordinates for this data layer.
152+
zarr.readShardIndex.failed=Failed to read shard information for zarr data. This may indicate missing data.
152153

153154
nml.file.uploadSuccess=Successfully uploaded file
154155
nml.file.notFound=Could not extract NML file

frontend/javascripts/admin/datastore_health_check.ts

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
import * as RestAPI from "admin/rest_api";
2-
import Request from "libs/request";
32
import Toast from "libs/toast";
43
import _ from "lodash";
54
import messages from "messages";
5+
import type { APIBuildInfoDatastore, APIBuildInfoWk } from "types/api_types";
66

77
// Create a throttled function which depends on its arguments.
88
// That way, each datastore is checked for health in a throttled and isolated manner
9-
// @ts-expect-error ts-migrate(7006) FIXME: Parameter 'func' implicitly has an 'any' type.
10-
const memoizedThrottle = (func, wait = 0, options = {}): ((...args: Array<any>) => any) => {
9+
const memoizedThrottle = <F extends (...args: Array<any>) => any>(func: F, wait = 0): F => {
1110
// Memoize the creation of a throttling function
12-
// @ts-expect-error ts-migrate(2339) FIXME: Property 'resolver' does not exist on type '{}'.
13-
const mem = _.memoize(() => _.throttle(func, wait, options), options.resolver);
11+
const mem = _.memoize((..._args: any[]) => _.throttle(func, wait));
1412

15-
return (...args: Array<any>) => {
13+
return ((...args: Parameters<F>) => {
1614
// look up (or create) the throttling function and invoke it
17-
// @ts-expect-error ts-migrate(2556) FIXME: Expected 0 arguments, but got 1 or more.
18-
mem(...args)(...args);
19-
};
15+
return mem(...args)(...args);
16+
}) as F;
2017
};
2118

2219
// Do not call this function directly, but call pingMentionedDataStores instead
@@ -34,10 +31,10 @@ const pingDataStoreIfAppropriate = memoizedThrottle(async (requestedUrl: string)
3431
return;
3532
}
3633

37-
const stores = [
34+
const stores: Array<{ url: string; path: "tracings" | "data" }> = [
3835
{ ...tracingstore, path: "tracings" },
39-
...datastores.map((datastore) => ({ ...datastore, path: "data" })),
40-
];
36+
...datastores.map((datastore) => ({ ...datastore, path: "data" as const })),
37+
] as const;
4138

4239
if (isInMaintenance) {
4340
Toast.warning(messages.planned_maintenance);
@@ -46,13 +43,14 @@ const pingDataStoreIfAppropriate = memoizedThrottle(async (requestedUrl: string)
4643

4744
if (usedStore != null) {
4845
const { url, path } = usedStore;
49-
const healthEndpoint = `${url}/${path}/health`;
50-
Request.triggerRequest(healthEndpoint, {
51-
doNotInvestigate: true,
52-
mode: "cors",
53-
timeout: 5000,
54-
}).then(
55-
() => checkVersionMismatch(url),
46+
RestAPI.pingHealthEndpoint(url, path).then(
47+
() => {
48+
if (usedStore.path === "data") {
49+
// Only check a version mismatch for the data store, because
50+
// the tracingstore doesn't serve a tracingstoreApiVersion field.
51+
checkVersionMismatchInDataStore(url);
52+
}
53+
},
5654
() =>
5755
Toast.warning(
5856
messages["datastore.health"]({
@@ -64,15 +62,13 @@ const pingDataStoreIfAppropriate = memoizedThrottle(async (requestedUrl: string)
6462
}
6563
}, 5000);
6664

67-
async function checkVersionMismatch(url: string) {
68-
const [buildinfoWebknossos, buildinfoDatastore] = await Promise.all([
65+
async function checkVersionMismatchInDataStore(datastoreUrl: string) {
66+
const [buildinfoWebknossos, buildinfoDatastore] = (await Promise.all([
6967
RestAPI.getBuildInfo(),
70-
RestAPI.getDataStoreBuildInfo(url),
71-
]);
68+
RestAPI.getDataOrTracingStoreBuildInfo(datastoreUrl),
69+
])) as [APIBuildInfoWk, APIBuildInfoDatastore];
7270
const expectedDatastoreApiVersion = buildinfoWebknossos.webknossos.datastoreApiVersion;
73-
const buildInfoWebknossosDatastore = buildinfoDatastore.webknossosDatastore
74-
? buildinfoDatastore.webknossosDatastore
75-
: buildinfoDatastore.webknossos;
71+
const buildInfoWebknossosDatastore = buildinfoDatastore.webknossosDatastore;
7672
const suppliedDatastoreApiVersion = buildInfoWebknossosDatastore.datastoreApiVersion;
7773

7874
if (
@@ -83,7 +79,7 @@ async function checkVersionMismatch(url: string) {
8379
messages["datastore.version.too_new"]({
8480
expectedDatastoreApiVersion,
8581
suppliedDatastoreApiVersion,
86-
url,
82+
datastoreUrl,
8783
}),
8884
);
8985
} else if (
@@ -94,7 +90,7 @@ async function checkVersionMismatch(url: string) {
9490
messages["datastore.version.too_old"]({
9591
expectedDatastoreApiVersion,
9692
suppliedDatastoreApiVersion,
97-
url,
93+
datastoreUrl,
9894
}),
9995
);
10096
}

frontend/javascripts/admin/rest_api.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import {
1515
type APIAnnotationType,
1616
type APIAnnotationVisibility,
1717
type APIAvailableTasksReport,
18-
type APIBuildInfo,
18+
type APIBuildInfoDatastore,
19+
type APIBuildInfoTracingstore,
20+
type APIBuildInfoWk,
1921
type APICompoundType,
2022
type APIConnectomeFile,
2123
type APIDataSource,
@@ -1789,17 +1791,31 @@ export async function getPricingPlanStatus(): Promise<APIPricingPlanStatus> {
17891791

17901792
export const cachedGetPricingPlanStatus = _.memoize(getPricingPlanStatus);
17911793

1794+
// ### Health
1795+
export function pingHealthEndpoint(url: string, path: "tracings" | "data"): Promise<void> {
1796+
const healthEndpoint = `${url}/${path}/health`;
1797+
return Request.triggerRequest(healthEndpoint, {
1798+
doNotInvestigate: true,
1799+
mode: "cors",
1800+
timeout: 5000,
1801+
});
1802+
}
1803+
17921804
// ### BuildInfo webknossos
1793-
export function getBuildInfo(): Promise<APIBuildInfo> {
1805+
export function getBuildInfo(): Promise<APIBuildInfoWk> {
17941806
return Request.receiveJSON("/api/buildinfo", {
17951807
doNotInvestigate: true,
1808+
mode: "cors",
17961809
});
17971810
}
17981811

1799-
// ### BuildInfo datastore
1800-
export function getDataStoreBuildInfo(dataStoreUrl: string): Promise<APIBuildInfo> {
1801-
return Request.receiveJSON(`${dataStoreUrl}/api/buildinfo`, {
1812+
// ### BuildInfo datastore/tracingstore
1813+
export function getDataOrTracingStoreBuildInfo(
1814+
dataOrTracingStoreUrl: string,
1815+
): Promise<APIBuildInfoDatastore | APIBuildInfoTracingstore> {
1816+
return Request.receiveJSON(`${dataOrTracingStoreUrl}/api/buildinfo`, {
18021817
doNotInvestigate: true,
1818+
mode: "cors",
18031819
});
18041820
}
18051821

frontend/javascripts/libs/request.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { pingMentionedDataStores } from "admin/datastore_health_check";
21
import handleStatus from "libs/handle_http_status";
32
import Toast from "libs/toast";
43
import _ from "lodash";
@@ -286,16 +285,17 @@ class Request {
286285
setTimeout(() => resolve("timeout"), timeout);
287286
});
288287

289-
handleError = (
288+
handleError = async (
290289
requestedUrl: string,
291290
showErrorToast: boolean,
292291
doInvestigate: boolean,
293292
error: Response | Error,
294293
): Promise<void> => {
295294
if (doInvestigate) {
295+
// Avoid circular imports via dynamic import
296+
const { pingMentionedDataStores } = await import("admin/datastore_health_check");
296297
// Check whether this request failed due to a problematic datastore
297298
pingMentionedDataStores(requestedUrl);
298-
299299
if (error instanceof Response) {
300300
return error.text().then(
301301
(text) => {

frontend/javascripts/test/fixtures/build_info.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import type { APIBuildInfo } from "types/api_types";
1+
import type { APIBuildInfoWk } from "types/api_types";
22

3-
export const buildInfo: APIBuildInfo = {
3+
export const buildInfo: APIBuildInfoWk = {
44
webknossos: {
55
name: "webknossos",
66
ciTag: "",
@@ -21,6 +21,7 @@ export const buildInfo: APIBuildInfo = {
2121
sbtVersion: "1.4.1",
2222
builtAtString: "2021-12-20 21:30:36.569",
2323
},
24+
httpApiVersioning: { currentApiVersion: 9, oldestSupportedApiVersion: 5 },
2425
schemaVersion: 101,
2526
localDataStoreEnabled: false,
2627
localTracingStoreEnabled: true,

frontend/javascripts/types/api_types.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ export type APIPricingPlanStatus = {
680680
readonly isAlmostExceeded: boolean; // stays true when isExceeded is true)
681681
};
682682

683-
export type APIBuildInfo = {
683+
export type APIBuildInfoWk = {
684684
webknossos: {
685685
name: string;
686686
commitHash: string;
@@ -702,7 +702,14 @@ export type APIBuildInfo = {
702702
sbtVersion: string;
703703
builtAtString: string;
704704
};
705-
webknossosDatastore?: {
705+
schemaVersion: number;
706+
httpApiVersioning: { currentApiVersion: number; oldestSupportedApiVersion: number };
707+
localDataStoreEnabled: boolean;
708+
localTracingStoreEnabled: boolean;
709+
};
710+
711+
export type APIBuildInfoDatastore = {
712+
webknossosDatastore: {
706713
name: string;
707714
commitHash: string;
708715
scalaVersion: string;
@@ -711,13 +718,25 @@ export type APIBuildInfo = {
711718
commitDate: string;
712719
ciTag: string;
713720
ciBuild: string;
714-
gitTag: string;
715721
datastoreApiVersion: string;
716722
};
717-
schemaVersion: number;
718-
localDataStoreEnabled: boolean;
719-
localTracingStoreEnabled: boolean;
720723
};
724+
725+
export type APIBuildInfoTracingstore = {
726+
webknossosTracingstore: {
727+
name: string;
728+
commitHash: string;
729+
scalaVersion: string;
730+
version: string;
731+
sbtVersion: string;
732+
commitDate: string;
733+
ciTag: string;
734+
ciBuild: string;
735+
};
736+
};
737+
738+
export type APIBuildInfo = APIBuildInfoWk | APIBuildInfoDatastore | APIBuildInfoTracingstore;
739+
721740
export type APIFeatureToggles = {
722741
readonly discussionBoard: string | false;
723742
readonly discussionBoardRequiresAdmin: boolean;

frontend/javascripts/viewer/model/helpers/nml_helpers.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { location } from "libs/window";
66
import _ from "lodash";
77
import messages from "messages";
88
import Saxophone from "saxophone";
9-
import type { APIBuildInfo, MetadataEntryProto } from "types/api_types";
9+
import type { APIBuildInfoWk, MetadataEntryProto } from "types/api_types";
1010
import type { AdditionalCoordinate } from "types/api_types";
1111
import {
1212
type BoundingBoxType,
@@ -136,7 +136,7 @@ export function serializeToNml(
136136
state: WebknossosState,
137137
annotation: StoreAnnotation,
138138
tracing: SkeletonTracing,
139-
buildInfo: APIBuildInfo,
139+
buildInfo: APIBuildInfoWk,
140140
applyTransform: boolean,
141141
): string {
142142
// Only visible trees will be serialized!
@@ -166,7 +166,7 @@ export function serializeToNml(
166166
function serializeMetaInformation(
167167
state: WebknossosState,
168168
annotation: StoreAnnotation,
169-
buildInfo: APIBuildInfo,
169+
buildInfo: APIBuildInfoWk,
170170
): string[] {
171171
return _.compact([
172172
serializeTag("meta", {

tools/check-cyclic-dependencies.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,17 @@ const { parseDependencyTree, parseCircular } = dpdm;
33

44
const KNOWN_CYCLES = [
55
[
6-
"frontend/javascripts/viewer/model/accessors/view_mode_accessor.ts",
76
"frontend/javascripts/viewer/model/accessors/flycam_accessor.ts",
7+
"frontend/javascripts/viewer/model/accessors/view_mode_accessor.ts",
88
],
99
[
1010
"frontend/javascripts/viewer/model/accessors/flycam_accessor.ts",
1111
"frontend/javascripts/viewer/model/reducers/flycam_reducer.ts",
1212
],
1313
[
14-
"frontend/javascripts/viewer/view/right-border-tabs/tree_hierarchy_view_helpers.ts",
14+
"frontend/javascripts/viewer/view/right-border-tabs/trees_tab/tree_hierarchy_view_helpers.ts",
1515
"frontend/javascripts/viewer/model/accessors/skeletontracing_accessor.ts",
1616
],
17-
["frontend/javascripts/libs/request.ts", "frontend/javascripts/admin/datastore_health_check.ts"],
18-
[
19-
"frontend/javascripts/admin/rest_api.ts",
20-
"frontend/javascripts/libs/request.ts",
21-
"frontend/javascripts/admin/datastore_health_check.ts",
22-
],
2317
[
2418
"frontend/javascripts/viewer/view/action-bar/download_modal_view.tsx",
2519
"frontend/javascripts/viewer/view/action-bar/starting_job_modals.tsx",
@@ -41,15 +35,16 @@ const KNOWN_CYCLES = [
4135
"frontend/javascripts/dashboard/folders/folder_tree.tsx",
4236
],
4337
[
44-
"frontend/javascripts/viewer/model_initialization.ts",
4538
"frontend/javascripts/viewer/controller/url_manager.ts",
39+
"frontend/javascripts/viewer/model_initialization.ts",
4640
],
4741
[
4842
"frontend/javascripts/viewer/geometries/plane.ts",
4943
"frontend/javascripts/viewer/geometries/materials/plane_material_factory.ts",
5044
"frontend/javascripts/viewer/shaders/main_data_shaders.glsl.ts",
5145
],
5246
];
47+
5348
parseDependencyTree("frontend/javascripts/main.tsx", {
5449
/* options, see below */
5550
extensions: [".ts", ".tsx"],

unreleased_changes/8633.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Added
2+
- Agglomerate Mappings can now also be read from the new zarr3-based format, and from remote object storage.

unreleased_changes/8683.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Fixed
2+
- Fixed that the healthcheck for a dedicated tracing store would fail sometimes.

0 commit comments

Comments
 (0)