-
Notifications
You must be signed in to change notification settings - Fork 1
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
More strict nexus structure validation and tests. #234
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.
You don't have to pay attention to this file too much since it'll be updated with the latest version of file along with compatible nexus file.
) | ||
|
||
|
||
def _validate_ev44_module_values( |
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.
Wouldn't it be good to merge these functions into one?
Something like
def _validate_module_values(
key_value_dict: dict[StreamModuleKey, StreamModuleValue],
) -> None:
for key, value in key_value_dict.items():
if key.module_type == "f144":
_validate_f144_module_spec(value)
if key.module_type == "ev44":
_validate_ev44_module_spec(value)
# etc
@@ -222,7 +264,10 @@ def collect_streaming_modules( | |||
) |
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.
Why first create a tuple of pairs and then make it into a dict?
Why not just make the dict directly?
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.
Because if you make a dict directly, duplicating key can overwrite the existing one.
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.
Aha okay 👍
@@ -258,8 +303,7 @@ def _is_monitor(group: NexusGroup) -> bool: | |||
|
|||
def _initialize_ev44(module_spec: StreamModuleValue) -> NexusGroup: | |||
parent = module_spec.parent | |||
if len(parent['children']) != 1: | |||
raise ValueError('Group containing ev44 module should have exactly one child') | |||
_validate_ev44_module_spec(module_spec) |
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.
It seems excessive to validate the spec every time we are using it. Can't we make sure to validate the specs when they are constructed, then we don't have to sprinkle validation code here and there?
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.
Yeah... that's true. It's already checking in the collect_streaming_modules
.
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.
@jokasimr Done...!
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.
Looks good overall. Left a couple of comments/questions.
a893cec
to
8bf0615
Compare
Related to #227
This is for integration tests between json template and beamlime.