-
Notifications
You must be signed in to change notification settings - Fork 94
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
Adding a check on the grid/component consistency in the blueprints #2045
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: John Stilley <1831479+john-science@users.noreply.github.com>
Running integration tests, will update when they are done. |
The internal integration tests came back clean. I think this is ready for you to look at @john-science . |
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.
I only had one comment.
idsInGrid = list(gridDesign.gridContents.values()) | ||
if componentDesign.latticeIDs: | ||
for latticeID in componentDesign.latticeIDs: | ||
allLatticeIds.add(str(latticeID)) | ||
# the user has given this component latticeIDs. check that | ||
# each of the ids appears in the grid, otherwise | ||
# their blueprints are probably wrong | ||
if len([i for i in idsInGrid if i == str(latticeID)]) == 0: | ||
raise ValueError( | ||
f"latticeID {latticeID} in block blueprint '{self.name}' is expected " | ||
"to be present in the associated block grid. " | ||
"Check that the component's latticeIDs align with the block's grid." | ||
) |
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.
Just a thought.
This method is suddenly quite long.
Could we move this to a private helper method that just does the error handling? What do you think?
# for every id in grid, confirm that at least one component had it | ||
if gridDesign: | ||
idsInGrid = list(gridDesign.gridContents.values()) | ||
for idInGrid in idsInGrid: | ||
if str(idInGrid) not in allLatticeIds: | ||
raise ValueError( | ||
f"ID {idInGrid} in grid {gridDesign.name} is not in any components of block {self.name}. " | ||
"All IDs in the grid must appear in at least one component." | ||
) |
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.
Just a thought.
This method is suddenly quite long.
Could we move this to a private helper method that just does the error handling? What do you think?
What is the change?
Close #1400 .
This PR adds a check on the grids associated with a block to ensure that the components that are supposed to be in the grid (based on them having the
latticeIDs
attribute) actually are, and in the correct number.Specifically, this PR enforces the following conditions:
If the conditions above are not met, it is very likely that the user has a bug in their blueprints that would otherwise be silently skipped.
Why is the change being made?
#1400 pointed out that there can be inconsistency here by pretty simple user errors. This has come up in my own work, and having ARMI be more robust to this kind of error is desirable.
Checklist
doc
folder.pyproject.toml
.