Skip to content
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

Fix expected node type from server by renaming resolution to mag #8187

Merged
merged 2 commits into from
Nov 12, 2024

Conversation

MichaelBuessemeyer
Copy link
Contributor

@MichaelBuessemeyer MichaelBuessemeyer commented Nov 12, 2024

Fixes changes introduced by #8111. The server sends nodes with the field called mag and not resolution. This pr changes the frontend type to expect the name as now called mag.

URL of deployed dev instance (used for testing):

Steps to test:

  • Create a tracing and add at least one tree with nodes.
  • hard reload the tracing and download the nml. The inMag field should not be empty.
  • Check on master: the inMag field should be empty

Issues:


(Please delete unneeded items, merge only when none are left open)

Summary by CodeRabbit

Release Notes

  • New Features

    • Added metadata support for annotations on Trees and Segments.
    • Introduced a summary row in the time tracking overview.
    • Enhanced search capabilities for unnamed segments.
    • Improved loading speed for precomputed meshes.
    • Unified terminology in the UI from "Resolution" to "Magnification" (mag).
    • Added a button in the search popover for selecting all matching non-group results.
    • Support for remote OME-Zarr NGFF version 0.5 datasets.
  • Bug Fixes

    • Resolved issues with dataset uploads, annotation saving, and scrolling in the trees and segments tab.
    • Fixed layout persistence bugs and ensured S3-compliant object storages are accessible via HTTPS.
  • Chores

    • Migrated nightly screenshot tests from CircleCI to GitHub Actions.

Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

Walkthrough

The pull request introduces several updates to the WEBKNOSSOS project, primarily focusing on enhancing metadata handling for Trees and Segments, improving UI elements, and fixing various bugs. Key changes include the renaming of the "Resolution" property to "Magnification" (or "mag") across multiple components, improved loading speeds for precomputed meshes, and the addition of new functionalities in the search interface. Additionally, several bug fixes address issues related to dataset uploads, annotation management, and layout persistence.

Changes

File Path Change Summary
CHANGELOG.unreleased.md Updated to document unreleased changes including metadata handling, UI improvements, and bug fixes.
frontend/javascripts/oxalis/model/helpers/generate_dummy_trees.ts Renamed resolution property to mag in generateDummyTree function.
frontend/javascripts/oxalis/model/reducers/skeletontracing_reducer_helpers.ts Updated resolution property to mag in serverNodeToMutableNode function.
frontend/javascripts/test/fixtures/skeletontracing_server_objects.ts Replaced resolution with mag in tracing object node definitions.
frontend/javascripts/test/fixtures/tasktracing_server_objects.ts Updated tracing object to replace resolution with mag in node definitions.
frontend/javascripts/types/api_flow_types.ts Changed resolution property to mag in ServerNode type definition.

Possibly related PRs

🐇 In the meadow where changes bloom,
A new term brings light to the room.
"Mag" replaces "Res," oh what a sight,
As bugs are fixed and features take flight.
With every hop, we celebrate cheer,
For WEBKNOSSOS shines bright this year! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (1)
CHANGELOG.unreleased.md (1)

48-48: LGTM with minor wording suggestions

The changelog entry accurately documents the fix. Consider this minor rewording for improved clarity:

- Fixed the expected type of a tree node received from the server. Fixes nml export to include the `inMag` field correctly. [#8187](https://github.com/scalableminds/webknossos/pull/8187)
+ Fixed the server node type mismatch to ensure correct `inMag` field in NML exports. [#8187](https://github.com/scalableminds/webknossos/pull/8187)
🧰 Tools
🪛 LanguageTool

[grammar] ~48-~48: If ‘type’ is a classification term, ‘a’ is not necessary. Use “type of”. (The phrases ‘kind of’ and ‘sort of’ are informal if they mean ‘to some extent’.)
Context: ...knossos/pull/8185) - Fixed the expected type of a tree node received from the server. Fix...

(KIND_OF_A)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8dec578 and de63a3a.

📒 Files selected for processing (6)
  • CHANGELOG.unreleased.md (1 hunks)
  • frontend/javascripts/oxalis/model/helpers/generate_dummy_trees.ts (1 hunks)
  • frontend/javascripts/oxalis/model/reducers/skeletontracing_reducer_helpers.ts (1 hunks)
  • frontend/javascripts/test/fixtures/skeletontracing_server_objects.ts (3 hunks)
  • frontend/javascripts/test/fixtures/tasktracing_server_objects.ts (1 hunks)
  • frontend/javascripts/types/api_flow_types.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • frontend/javascripts/oxalis/model/reducers/skeletontracing_reducer_helpers.ts
🧰 Additional context used
🪛 LanguageTool
CHANGELOG.unreleased.md

[grammar] ~48-~48: If ‘type’ is a classification term, ‘a’ is not necessary. Use “type of”. (The phrases ‘kind of’ and ‘sort of’ are informal if they mean ‘to some extent’.)
Context: ...knossos/pull/8185) - Fixed the expected type of a tree node received from the server. Fix...

(KIND_OF_A)

🔇 Additional comments (3)
frontend/javascripts/oxalis/model/helpers/generate_dummy_trees.ts (2)

37-37: LGTM! Change aligns with PR objectives.

The switch from resolution to mag in the node properties matches the server's expected field name, addressing the core issue described in the PR.


37-37: Verify consistent property naming across the codebase.

Let's ensure this naming change has been applied consistently across all relevant files.

✅ Verification successful

Property naming is consistent with codebase conventions

The change from 'resolution' to 'mag' for this single magnification value property follows the established pattern where 'mag' is used for individual magnification values, while 'resolutions' is used for collections/arrays of magnifications.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Search for any remaining instances of 'resolution' that might need to be changed to 'mag'
# in the context of node properties or similar data structures

# Look for resolution in type definitions and interfaces
ast-grep --pattern 'interface $_ {
  $$$
  resolution: $_
  $$$
}'

# Look for resolution in object literals that might be node-related
ast-grep --pattern '{
  $$$
  resolution: $_
  $$$
}'

# Search for resolution in relevant contexts
rg 'resolution' --type ts --type tsx -C 3 | grep -v 'Resolution' | grep -v 'resolution:'

Length of output: 237


Script:

#!/bin/bash
# Description: Search for any remaining instances of 'resolution' that might need to be changed to 'mag'
# in the context of node properties or similar data structures

# Look for resolution in type definitions and interfaces
ast-grep --pattern 'interface $_ {
  $$$
  resolution: $_
  $$$
}'

# Look for resolution in object literals that might be node-related
ast-grep --pattern '{
  $$$
  resolution: $_
  $$$
}'

# Search for resolution in relevant contexts within .ts and .tsx files
rg 'resolution' -g '*.ts' -g '*.tsx' -C 3 | grep -v 'Resolution' | grep -v 'resolution:'

Length of output: 202992


Script:

#!/bin/bash
# Description: Search for any remaining instances of 'resolution' that might need to be changed to 'mag'
# in the context of node properties or similar data structures

# Look for resolution in type definitions and interfaces
ast-grep --pattern 'interface $_ {
  $$$
  resolution: $_
  $$$
}'

# Look for resolution in object literals that might be node-related
ast-grep --pattern '{
  $$$
  resolution: $_
  $$$
}'

# Search for resolution in relevant contexts within .ts and .tsx files
rg 'resolution' -g '*.ts' -g '*.tsx' -C 3 | grep -v 'Resolution' | grep -v 'resolution:'

Length of output: 202992

frontend/javascripts/types/api_flow_types.ts (1)

759-759: LGTM! Type definition aligned with server behavior.

The change from resolution to mag correctly reflects the server's behavior of sending nodes with the "mag" field, fixing the type mismatch.

Let's verify that this change is consistently applied across the codebase:

@@ -20,7 +20,7 @@ export const tracing: ServerSkeletonTracing = {
},
radius: 120,
viewport: 1,
resolution: 1,
mag: 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Incomplete renaming of resolution to mag in test fixtures.

Please update the following test fixtures to replace resolution with mag:

  • frontend/javascripts/test/fixtures/volumetracing_object.ts
  • frontend/javascripts/test/fixtures/dataset_server_object.ts
🔗 Analysis chain

LGTM! Property name change aligns with server response format.

The change from resolution to mag correctly reflects the server's node field naming, ensuring test fixtures match the actual API response structure.

Let's verify if similar changes were made in all test fixtures:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for any remaining instances of 'resolution' in test fixtures
# and confirm consistent use of 'mag' property in node definitions

# Search for any remaining 'resolution' properties in test fixtures
echo "Checking for remaining 'resolution' properties in test fixtures:"
rg -l "resolution.*:" "frontend/javascripts/test/fixtures/"

# Search for node definitions to verify 'mag' property usage
echo "Verifying 'mag' property usage in node definitions:"
rg -A 5 "nodes.*:.*\[" "frontend/javascripts/test/fixtures/"

Length of output: 2032

@@ -22,7 +22,7 @@ export const tracing: ServerSkeletonTracing = {
},
radius: 112.39999389648438,
viewport: 0,
resolution: 1,
mag: 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Residual resolution fields found in type definitions.

Several type definitions still contain resolution fields. Please update these to maintain consistency.

  • frontend/javascripts/types/api_flow_types.ts: readonly resolutions: Array<Vector3>;
  • frontend/javascripts/test/reducers/skeletontracing_reducer.spec.ts: resolution: 10,
  • frontend/javascripts/oxalis/shaders/main_data_shaders.glsl.ts: resolutionsCount: number;
  • frontend/javascripts/router.tsx: const resolutionRestrictions: APIMagRestrictions = {};
  • frontend/javascripts/oxalis/view/left-border-tabs/layer_settings_tab.tsx: const getMaxDim = (resolution: Vector3) => Math.max(...resolution);
  • frontend/javascripts/oxalis/view/right-border-tabs/connectome_tab/connectome_view.tsx: resolution: 0,
  • frontend/javascripts/oxalis/view/right-border-tabs/segments_tab/segments_view.tsx: handleQualityChangeForPrecomputation = (resolutionIndex: number) =>
  • frontend/javascripts/oxalis/view/right-border-tabs/segments_tab/segments_view.tsx: handleQualityChangeForAdHocGeneration = (resolutionIndex: number) =>
  • frontend/javascripts/oxalis/view/jobs/train_ai_model.tsx: resolutions ? resolutions.map(Utils.point3ToVector3) : ([[1, 1, 1]] as Vector3[]),
  • frontend/javascripts/oxalis/workers/async_bucket_picker.worker.ts: resolutions: Array<Vector3>,
  • frontend/javascripts/test/model/model_resolutions.spec.ts: resolutions: [
  • frontend/javascripts/oxalis/model/accessors/volumetracing_accessor.ts: resolution: Vector3;
  • frontend/javascripts/oxalis/model/accessors/dataset_accessor.ts: const resolutionUnionDict: { [key: number]: Vector3[] } = {};
  • frontend/javascripts/oxalis/model/accessors/flycam_accessor.ts: resolutionIdentifier: number,
  • frontend/javascripts/test/fixtures/volumetracing_object.ts: // @ts-expect-error ts-migrate(2322) FIXME: Type '{ resolutions: [number, number, number][]; c...
  • frontend/javascripts/oxalis/model/helpers/position_converter.ts: const resolution = magIndex < mags.length ? mags[magIndex] : upsampleMag(mags, magIndex);
  • frontend/javascripts/types/schemas/datasource.schema.ts: resolution: {
  • frontend/javascripts/types/schemas/datasource.types.ts: resolution: number | Vector3;
  • frontend/javascripts/admin/admin_rest_api.ts: resolution: Vector3 | null | undefined;
🔗 Analysis chain

LGTM! Property rename aligns with server behavior.

The change from resolution to mag correctly reflects the server's behavior as mentioned in the PR objectives. The modification is consistent across all nodes and maintains the existing values.

Let's verify the type definitions to ensure consistency:

Also applies to: 73-73, 93-93

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the type definitions have been updated to use 'mag' instead of 'resolution'
# Expected: Should find type definitions using 'mag' and no occurrences of 'resolution' in node types

# Search for node type definitions
ast-grep --pattern 'type $_ = {
  $$$
  mag: $_
  $$$
}'

# Verify no lingering 'resolution' fields in type definitions
rg 'resolution.*:' -g '*.ts' -g '*.tsx' -g '*.d.ts'

Length of output: 11629

resolution: number;
mag: number;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is the root of the problem. The backend sends nodes with the field called mag and not resolution. See:

message Node {
required int32 id = 1;
required Vec3IntProto position = 2;
required Vec3DoubleProto rotation = 3;
required float radius = 4;
required int32 viewport = 5;
required int32 mag = 6;
required int32 bitDepth = 7;
required bool interpolation = 8;
required int64 createdTimestamp = 9;
repeated AdditionalCoordinateProto additionalCoordinates = 10;
}

By changing the type, TS should show all locations to change and the resulting code should be fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, that makes sense!

@MichaelBuessemeyer MichaelBuessemeyer changed the title Fix server node type by switching back to mag Fix expected node type from server by renaming resolution to mag Nov 12, 2024
Copy link
Member

@daniel-wer daniel-wer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing this, works as described 👍

@MichaelBuessemeyer MichaelBuessemeyer merged commit 015016b into master Nov 12, 2024
3 checks passed
@MichaelBuessemeyer MichaelBuessemeyer deleted the fix-server-node-type branch November 12, 2024 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants