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

Group index step validators #1143

Closed
dbochkov-flexcompute opened this issue Sep 4, 2023 · 1 comment
Closed

Group index step validators #1143

dbochkov-flexcompute opened this issue Sep 4, 2023 · 1 comment
Assignees

Comments

@dbochkov-flexcompute
Copy link
Contributor

Current group index validator doesn't error on ModeSpec(group_index_step=1) https://github.com/flexcompute/tidy3d/blob/develop/tidy3d/components/mode.py#L133-L140. From what I understand, this happens because 1 is automatically converted into True given the field definition group_index_step: Union[bool, pd.PositiveFloat]. I tried changing it to group_index_step: Union[pd.PositiveFloat, bool] but in this case True gets converted into 1. Not sure what would be the best way to resolve this issue. I guess one option is to just split this field into two :

  • group_index_step: pd.PositiveFloat = pd.Field(GROUP_INDEX_STEP, ...)
  • compute_group_index: bool = pd.Field(False, ...)

What do you think, @lucas-flexcompute?

Also, root validator https://github.com/flexcompute/tidy3d/blob/develop/tidy3d/components/mode.py#L142 probably needs skip_on_failure=True. Otherwise, even if previous validators fail, it still gets executed and fails itself when trying to get values["group_index_step"]. So, instead of desired

           ERROR: Parameter 'group_index_step' must be less than 1.  mode.py:140

what gets displayed is:

>       if values["group_index_step"] > 0:
E       KeyError: 'group_index_step'

tidy3d/components/mode.py:146: KeyError
lucas-flexcompute added a commit that referenced this issue Sep 11, 2023
Signed-off-by: Lucas Heitzmann Gabrielli <lucas@flexcompute.com>
lucas-flexcompute added a commit that referenced this issue Sep 11, 2023
Signed-off-by: Lucas Heitzmann Gabrielli <lucas@flexcompute.com>
lucas-flexcompute added a commit that referenced this issue Sep 11, 2023
Signed-off-by: Lucas Heitzmann Gabrielli <lucas@flexcompute.com>
lucas-flexcompute added a commit that referenced this issue Sep 11, 2023
Signed-off-by: Lucas Heitzmann Gabrielli <lucas@flexcompute.com>
momchil-flex pushed a commit that referenced this issue Sep 11, 2023
Signed-off-by: Lucas Heitzmann Gabrielli <lucas@flexcompute.com>
@lucas-flexcompute
Copy link
Collaborator

Fixed in #1152

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants