Add async ngen execution via new context manager class ForecastExecutionManager - #1
Merged
Merged
Conversation
…nd interruptable calls to ngen
Author
|
Note that the new class changes the type of exception raised during ngen execution. Previously it would raise a generic CalledProcessError. Now it will raise a |
…ate, improve docstrings.
Author
|
@peterkronenberg-rtx, these changes should not cause a change in default/existing behavior: when a forecast is executed via call to If CERF leverages that function, could you please confirm that behavior is unchanged from CERF usage perspective? |
peterkronenberg-rtx
approved these changes
Nov 25, 2025
peterkronenberg-rtx
left a comment
There was a problem hiding this comment.
Successfully ran a forecast from ngenCerf. No server changes were needed. Everything worked fine
…xit, move closure logic to new public method close() to allow clean closure outside of context manager interface.
…lt append, can optionally choose write)
Author
|
The 2 commits I added earlier today were to support a testing environment, which needed:
|
cmaynard-ngwpc
pushed a commit
that referenced
this pull request
Dec 5, 2025
Add async ngen execution via new context manager class `ForecastExecutionManager`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a new context manager class
ForecastExecutionManagerwith primary methodspreprocess,execute, andpostprocess, which allows asynchronous subprocess calls to the ngen binary, external polling of the ngen subprocess, and external stopping of the ngen subprocess.On exit, the context manager closes the log file and terminates ngen if it is still running. A
waitparameter is provided on theexecutemethod for cases where external polling is not desired, in which case theForecastExecutionManagerperforms its own polling.Function
run_fcststill exists, and it uses the new class by callingexecute(wait=True)such that its user interface is effectively unchanged.To stop ngen execution, the user calls method
schedule_ngen_stoppage().See here for example of async user call (wait=False) where the user intentionally quits execution after certain messages are found in the ngen log file: https://github.com/NGWPC/nwm-rte/blob/64f79860170c04983916be898ebddd5cac02247d/bin_mounted/example_workflow.py#L245-L250