-
Notifications
You must be signed in to change notification settings - Fork 24
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
improve the backend tree validator #2832
improve the backend tree validator #2832
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally very nice! But I think some refactoring would help here, left some comments.
@@ -9,6 +9,14 @@ import scala.collection.mutable | |||
|
|||
object TreeValidator { | |||
|
|||
def validateAdditionalInformation(trees: Seq[Tree], branchPoints: Seq[BranchPoint], comments: Seq[Comment], treeGroups: Seq[TreeGroup]): Box[Unit] = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tbh I think this function is a layer of indirection to much, as this is called exactly once. Please move those calls directly to the parse
function.
} | ||
} | ||
|
||
private def checkAllNodesUsedInBranchPointsExist(trees: Seq[Tree], branchPoints: Seq[BranchPoint]): Box[Unit] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this and similar functions a bit more DRY. There are multiple functions checking that some nodes exist in the trees.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The refactoring helped a lot! Only one more thing left, that makes it more DRY
} | ||
} | ||
|
||
private def checkAllNodesUsedExist(trees: Seq[Tree], usedNodes: Seq[Int]) = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is called check…
, please include the actual check with the Failure
message here. It justs needs the name of the nodes for the message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🚢
* [WIP] backend unit test for nml parser * [WIP] Unit Tests for Backend * [WIP] backend unit test now work for serializing and parsing #2826 * nml tests now work similar to the frontend tests * fix imports * mark test as working to enable ci build #2829 * fix compiler errors and add some tests #2829 * enhance the backend tree validator with some functions the frontend already uses #2830 * add docker-compose service backend-tests * CI: add backend tests * e2e tests: move invariant config to End2EndSpec.scala * implement pr advice #2829 * implement some of the pr advice #2832 * implement pr feedback #2832 * implement pr advice #2829 * fix merge errors and make code DRYer #2832 * Update CHANGELOG.md
namely:
invalid comments
invalid branchPoints
invalid and duplicated groupIds
measured performance impact: + 1,2 - 1,8 sec for this 200.000 node tracing (https://webknossos.brain.mpg.de/annotations/Explorational/5a2987f066000063056b88d1/readOnly#2632,1514,1387,0,2.23,14)
whole parsing process takes ca. 20 sec
old validation alone takes ca. 2,8 sec
all times measured locally with my machine (not the strongest)
URL of deployed dev instance (used for testing):
Steps to test:
Issues: