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

New plugin hook for before reactor construction #1945

Merged
merged 7 commits into from
Oct 15, 2024
Merged

Conversation

opotowsky
Copy link
Member

@opotowsky opotowsky commented Oct 10, 2024

What is the change?

This adds a new plugin hook beforeReactorConstruction. Then some code (material namespace order setting) is pulled out of the reactor factory and into the hook call for the reactor plugin.

Why is the change being made?

This cleans up the reactor construction and sets the stage for plugins to fancify the beforeReactorConstruction hook should they be interested in fancification.


Checklist

  • The release notes have been updated if necessary.
  • The documentation is still up-to-date in the doc folder.
  • The dependencies are still up-to-date in pyproject.toml.

@opotowsky opotowsky added the architecture Issues related to big picture system architecture label Oct 10, 2024
armi/plugins.py Outdated Show resolved Hide resolved
@ntouran
Copy link
Member

ntouran commented Oct 11, 2024

Here's a patch that will get at least some test coverage. It's not easy to confirm positively that the reactor doesn't exist because the plugin hook has no knowledge of that. I think just showing that it's run during init is probably sufficient.

diff --git a/armi/tests/test_user_plugins.py b/armi/tests/test_user_plugins.py
index 0840afd5..0cc19f0d 100644
--- a/armi/tests/test_user_plugins.py
+++ b/armi/tests/test_user_plugins.py
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 """Tests for the UserPlugin class."""
+
 import copy
 import os
 import unittest
@@ -106,6 +107,11 @@ class UserPluginOnProcessCoreLoading(plugins.UserPlugin):
         for b in blocks:
             b.p.height += 1.0

+    @staticmethod
+    @plugins.HOOKIMPL
+    def beforeReactorConstruction(cs) -> None:
+        cs._beforeReactorConstructionFlag = True
+

 class UpInterface(interfaces.Interface):
     """
@@ -248,6 +254,7 @@ class TestUserPlugins(unittest.TestCase):
             TEST_ROOT, inputFileName="smallestTestReactor/armiRunSmallest.yaml"
         )
         fuels = r.core.getBlocks(Flags.FUEL)
+        self.assertTrue(o.cs._beforeReactorConstructionFlag)

         # prove that our plugin affects the core in the desired way
         heights = [float(f.p.height) for f in fuels]

opotowsky and others added 3 commits October 14, 2024 17:28
Co-authored-by: John Stilley <1831479+john-science@users.noreply.github.com>
@opotowsky opotowsky merged commit 01b0ade into main Oct 15, 2024
19 checks passed
@opotowsky opotowsky deleted the new-plugin-hook branch October 15, 2024 21:00
drewj-tp added a commit that referenced this pull request Oct 15, 2024
* origin/main:
  New plugin hook for before reactor construction (#1945)
drewj-tp added a commit that referenced this pull request Oct 16, 2024
…xial-linkage

* origin/main:
  New plugin hook for before reactor construction (#1945)
  Removing DoseResultsMapper (#1952)
  Adding logic so HexAssemblies are hexagonal (#1935)
  Adding Block.getInputHeight (#1927)
  Removing Assembly.doubleResolution (#1951)
  Adding DeprecationWarning for HistoryTrackerInterface (#1950)
  Removing tabulate as a dependency (#1948)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
architecture Issues related to big picture system architecture
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants