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

More strict nexus structure validation and tests. #234

Merged
merged 3 commits into from
Sep 27, 2024
Merged

Conversation

YooSunYoung
Copy link
Member

@YooSunYoung YooSunYoung commented Sep 26, 2024

Related to #227

This is for integration tests between json template and beamlime.

Copy link
Member Author

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(
Copy link
Contributor

@jokasimr jokasimr Sep 26, 2024

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(
)
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jokasimr Done...!

Copy link
Contributor

@jokasimr jokasimr left a 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.

Base automatically changed from fix-data-assembler to main September 26, 2024 14:48
@YooSunYoung YooSunYoung merged commit c16643a into main Sep 27, 2024
4 checks passed
@YooSunYoung YooSunYoung deleted the validation branch September 27, 2024 08:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants