-
Notifications
You must be signed in to change notification settings - Fork 92
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
Providing plugin hook getAxialExpansionChanger #1870
Conversation
Produce a class, not an instance thereof, that is responsible for performing thermal axial expansion. Marked with the `firstresult=True` such that the pluggy hook call will stop after the first hook produces a non-`None` result. https://pluggy.readthedocs.io/en/stable/index.html#first-result-only
Provides the "default" `armi.reactor.converters.axialExpansionChanger.AxialExpansionChanger` class. Marked with `trylast=True` to help make sure other hooks added to the application are called before this one, even if they are not marked with `tryfirst=True`. https://pluggy.readthedocs.io/en/stable/index.html#call-time-order
Was in the area so make a minor cleanup
…ExpansionChanger hook
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.
This looks great to me. Just some feedback on the comments for clarity and posterity/long-term maintenance.
Co-authored-by: Tony Alberti <aalberti@terrapower.com>
…843' into drewj/ax-exp-hook/1843
I only have two small things on this PR. Take a look. So... the purpose of this design is two-fold?
Do I have the goals right? IF I do, I guess I have some questions:
|
Co-authored-by: John Stilley <1831479+john-science@users.noreply.github.com>
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 have two small things on this PR. Take a look.
So... the purpose of this design is two-fold?
- Developers can now drop in their own
AxialExpansionChanger
subclasses.- Developers can now opt to not have an
AxialExpansionChanger
changer at all, by just not having this plugin hook in any of their plugins?Do I have the goals right?
Goal 1 is correct. Any application can drop in their own AxialExpansionChanger
subclass.
Goal 2 is slightly incorrect. The default ReactorPlugin
implements this hook that brings the current AxialExpansionChanger
. If an application does not register any plugin that implement this hook, the "default" state is to bring the existing expansion changer into the mix. To put it another way, this plugin hook is always implemented, but applications can circumvent the default expander by implementing the hook.
And, if somehow you do not register the ReactorPlugin
and find yourself in a situation where no plugin registered implements this hook, I have no idea what pluggy will do. It may return None
and then get some attribute errors trying to call None.expandColdDimsToHot
as if it were an expander class?
IF I do, I guess I have some questions:
What happens if you use this plugin hook in more than one plugin?
- I assume this has to fail, right?
- Have you tested that?
- How does it fail?
@albeanth had this same question. If multiple plugins implement this hook, the first non-None
result will be "selected" and used. The goal is there should be at most two plugins that implement this hook and registered with the application
- Default
ReactorPlugin.getAxialExpanderClass
- Some other plugin deemed responsible of owning axial expansion.
The ReactorPlugin.getAxialExpanderClass
hook implementation is marked with trylast=True
so, regardless of the plugin registration ordering, it should be the last such hook to be called.
The test I added covers two plugins implementing this hook and showing the behavior of the trylast
marker.
- No new plugin -> call plugin hooks -> default
AxialExpansionChanger
fetched fromReactorPlugin
- Register a different plugin that implements the hook -> call plugin hooks hooks -> expansion changer from second plugin is registered
armi/armi/tests/test_plugins.py
Lines 110 to 120 in b1270c9
def test_axialExpansionHook(self): | |
"""Test that plugins can override the axial expansion of assemblies via a hook.""" | |
pm = self.app.pluginManager | |
first = pm.hook.getAxialExpansionChanger() | |
# By default, make sure we get the armi-shipped expansion class | |
self.assertIs(first, AxialExpansionChanger) | |
pm.register(SillyAxialPlugin) | |
second = pm.hook.getAxialExpansionChanger() | |
# Registering a plugin that implements the hook means we get | |
# that plugin's axial expander | |
self.assertIs(second, SillyAxialExpansionChanger) |
Does ARMI run if zero plugins implement this hook?
- I want to make sure this change doesn't break for reactors with no assemblies.
One plugin already implements and registers this hook - ReactorPlugin.getAxialExpanderClass
. And that performs the current behavior. So reactors with no assemblies should not see any changes if they do not implement this hook.
However, such applications could implement this hook on a plugin that produces a do-nothing expander class. That is (potentially, untested) way to skip axial expansion beyond setting Tinput=Thot
Co-authored-by: John Stilley <1831479+john-science@users.noreply.github.com>
Can happen if no plugin implements the hook at all. This may involve unregistering the ReactorPlugin, but it's not impossible
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.
After CI passes, I think this is ready for show time, if you guys do.
This is apart of a larger downstream slough of changes, so let's hold tight till those are ready? |
…rams/1860 * origin/main: Adding ParameterCollection.where for conditional parameter iteration (#1899) Removing non-existent settings from test files (#1906) Removing reference to deprecated internal files (#1897) Fixing a problem with the latest release of h5py (#1907) Providing plugin hook getAxialExpansionChanger (#1870) Fixing typo in new settingsValidation imports (#1905) Startinf moving settingsValidation to the settings area (#1895)
What is the change?
Plugins are now able to implement the
getAxialExpansionChanger
hook to provide their own class responsible forperforming the initial thermal axial expansion of assemblies. The default implemented hook, brought by the
ReactorPlugin
, exposes thearmi.reactor.converters.axialExpansion.AxialExpansionChanger
class.Why is the change being made?
This allows plugins to bring their own machinery for thermal axial expansion during the blueprints construction stage. Plugins can even opt to make a subclass that does not perform axial expansion at all.
Closes #1843
Todo
Checklist
doc
folder.pyproject.toml
.