Skip to content

Revert "In Data Loading, Clip to Layer BoundingBox (#8551)" #8572

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 3 commits into from
Apr 28, 2025

Conversation

MichaelBuessemeyer
Copy link
Contributor

This reverts #8551 (commit 7275b8b) due to an introduced bug. See report https://scm.slack.com/archives/C02H5T8Q08P/p1745845348102239


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

  • Needs datastore update after deployment

Copy link
Contributor

coderabbitai bot commented Apr 28, 2025

Warning

Rate limit exceeded

@MichaelBuessemeyer has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 15 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between ad12865 and 5627da7.

📒 Files selected for processing (1)
  • CHANGELOG.unreleased.md (0 hunks)
📝 Walkthrough

Walkthrough

This change set removes several geometry-related methods and properties across multiple files. In the geometry utility package, methods for bounding box containment, movement, and vector negation via unary operator are deleted or replaced with explicit alternatives. In the data model and service layers, methods for converting cuboids to bounding boxes and for extracting magnification vectors are removed. The binary data service's logic for clipping data to a layer bounding box is eliminated, and adjustments are made to how voxel data is indexed during cutout operations.

Changes

Files/Paths Change Summary
util/src/main/scala/com/scalableminds/util/geometry/BoundingBox.scala Removed isFullyContainedIn and move methods; changed bottomRight from lazy to strict val.
util/src/main/scala/com/scalableminds/util/geometry/Vec3Int.scala Removed unary negation operator; added explicit negate method.
webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/requests/Cuboid.scala Removed import of BoundingBox; deleted toBoundingBoxInMag and toMag1BoundingBox methods.
webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/requests/DataServiceRequests.scala Removed import of Vec3Int; deleted mag method from DataServiceDataRequest.
webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/BinaryDataService.scala Removed clipToLayerBoundingBox method and its usage; changed voxel indexing logic in cutOutCuboid.

Possibly related PRs

Suggested reviewers

  • frcroth

Poem

In the warren of code, some boxes are gone,
Bounding and moving, their duties withdrawn.
Clipping and negating, now clearer in view,
With methods retired, the old makes way for the new.
🐇 The data hops forward, less boxed in its way,
As rabbits refactor and nibble away!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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: 0

🧹 Nitpick comments (5)
util/src/main/scala/com/scalableminds/util/geometry/BoundingBox.scala (1)

9-9: Consider reverting bottomRight back to lazy val

bottomRight is now evaluated eagerly for every BoundingBox instantiation, even when it is never accessed.
For tight-loop geometry code (e.g. iterating over millions of cuboids) this can introduce measurable overhead.

-  val bottomRight: Vec3Int = topLeft.move(width, height, depth)
+  lazy val bottomRight: Vec3Int = topLeft.move(width, height, depth)

If you intentionally switched to strict evaluation for correctness (e.g. mutation trouble) please document the reason in a comment.
Otherwise a lazy val keeps the previous allocation behaviour without side-effects.

util/src/main/scala/com/scalableminds/util/geometry/Vec3Int.scala (1)

56-56: Preserve the convenient unary negation operator

negate works, but removing unary_- breaks client code that relied on -vec.
You can keep both with a one-liner alias to maintain backwards compatibility and developer ergonomics:

   def negate: Vec3Int = Vec3Int(-x, -y, -z)
+
+  /** Backwards-compat convenience – allows `-vec` in addition to `vec.negate` */
+  def unary_- : Vec3Int = negate

No runtime cost, and existing call-sites compile unchanged.

webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/requests/Cuboid.scala (1)

3-3: Unused import check

Vec3Int is imported but only referenced indirectly through topLeft.mag and mag return type – both are valid.
If later refactors remove the mag method, remember to drop this import to avoid warnings.

webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/BinaryDataService.scala (2)

171-172: subsamplingStrides is hard-coded to 1-1-1

Right now this adds indirection and three integer divisions per inner loop iteration without changing the result.

If true subsampling support is planned later, consider guarding the optimisation behind an if (subsamplingStrides != Vec3Int.ones) block, or calculate the division only when strides ≠ 1 to avoid the extra cost.

-    val subsamplingStrides = Vec3Int.ones
+    // Placeholder for future subsampling support – currently no-op (all ones)
+    val subsamplingStrides = Vec3Int.ones

197-199: Redundant division by 1 – micro-optimise or document

The divisions by subsamplingStrides.{x,y,z} are effectively … / 1. If perf-critical, inline:

-          val rx = (xMin - cuboid.topLeft.voxelXInMag) / subsamplingStrides.x
-          val ry = (y - cuboid.topLeft.voxelYInMag) / subsamplingStrides.y
-          val rz = (z - cuboid.topLeft.voxelZInMag) / subsamplingStrides.z
+          val rx = xMin - cuboid.topLeft.voxelXInMag
+          val ry = y    - cuboid.topLeft.voxelYInMag
+          val rz = z    - cuboid.topLeft.voxelZInMag

If you expect non-unit strides soon, add a comment so future maintainers understand the current overhead.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0acb96f and ad12865.

📒 Files selected for processing (5)
  • util/src/main/scala/com/scalableminds/util/geometry/BoundingBox.scala (1 hunks)
  • util/src/main/scala/com/scalableminds/util/geometry/Vec3Int.scala (1 hunks)
  • webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/requests/Cuboid.scala (1 hunks)
  • webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/requests/DataServiceRequests.scala (0 hunks)
  • webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/BinaryDataService.scala (3 hunks)
💤 Files with no reviewable changes (1)
  • webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/requests/DataServiceRequests.scala
🧰 Additional context used
🧬 Code Graph Analysis (2)
webknossos-datastore/app/com/scalableminds/webknossos/datastore/models/requests/Cuboid.scala (1)
util/src/main/scala/com/scalableminds/util/geometry/Vec3Int.scala (2)
  • Vec3Int (7-88)
  • Vec3Int (90-156)
util/src/main/scala/com/scalableminds/util/geometry/Vec3Int.scala (1)
frontend/javascripts/libs/mjs.ts (1)
  • negate (384-386)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: build-smoketest-push
  • GitHub Check: backend-tests
🔇 Additional comments (1)
webknossos-datastore/app/com/scalableminds/webknossos/datastore/services/BinaryDataService.scala (1)

112-124: Removal of layer-bounding-box clipping – verify downstream assumptions

convertAccordingToRequest no longer zeros voxels outside the layer bounding box.
While earlier validation skips buckets outside the range, individual voxels that lie outside the layer bounding box but inside a partially overlapping bucket will now be returned untouched.

If any consumers (rendering, quantification, analytics) relied on the previous zero-fill behaviour, this could re-introduce the very bug that PR #8551 tried to solve.

Please double-check:

  1. cutOutCuboid always keeps the cuboid fully inside the layer bounding box, or
  2. downstream code can cope with out-of-range voxel values.

A quick run of the existing integration test‐suite that originally motivated #8551 would provide confidence.

@MichaelBuessemeyer MichaelBuessemeyer enabled auto-merge (squash) April 28, 2025 14:10
@MichaelBuessemeyer MichaelBuessemeyer merged commit d30f8d8 into master Apr 28, 2025
5 checks passed
@MichaelBuessemeyer MichaelBuessemeyer deleted the revert-clip-to-bbox branch April 28, 2025 14:19
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