-
Notifications
You must be signed in to change notification settings - Fork 39
Refactoring template driver to dynamically create RAVEN workflows #391
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
Merged
Merged
Changes from 50 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
31d4dc7
flat RAVEN for static history
j-bryan 949da7f
feature driver approach to template driver refactor
j-bryan f5c8d54
some feature drivers
j-bryan a848112
move feature logic to template from template driver
j-bryan b6c3749
build workflow for bilevel outer
j-bryan 816f5d4
bilevel inner template
j-bryan b40ed92
remove redundant code
j-bryan f5ad122
dynamic creation of distributions from RAVEN input spec
j-bryan aa3209b
change getters and setters to dynamic properties
j-bryan 2cf21ce
naming conventions, housekeeping, other fixes
j-bryan 26d51bf
WIP debug mode template
j-bryan 078d788
a few debug template fixes
j-bryan d69ae7c
bilevel xml files
j-bryan 2abc8a2
fixes inner file pathing
j-bryan 4d91ea0
outer parallel batch size
j-bryan 61572de
unit testing for snippet classes
j-bryan e6874bd
better snippet property implementation
j-bryan a118b66
regolds two XML check tests to remove extraneous nodes
j-bryan 69662fb
fix missing econ UQ vargroup
j-bryan 43e4356
fix ROM file path
j-bryan 67d6924
unit testing for snippets
j-bryan 517f029
file assembler node type fix
j-bryan d2fc750
add case labels to sweep output
j-bryan 8f26fdf
final bilevel fixes
j-bryan cf0ff44
debug mode for synthetic history models
j-bryan f99aa4c
flattened debug mode writes prefixes differently
j-bryan 58f2408
fixes MonteCarlo default init, debug mode sampled variables
j-bryan 0c8d39f
adds missing items to database due to typo
j-bryan d4df1ca
one more prefix diff
j-bryan 698b85a
static histories in debug mode
j-bryan 4a5c637
method to check if sampler has variable
j-bryan c16603b
regold to add additional probability weight columns appearing due to …
j-bryan 91aff99
splits templates by case mode to condense template logic
j-bryan 6bf8f71
flat workflow only for single static history
j-bryan d310322
multiple histories in static csv
j-bryan ffddf4d
flat multi config template file
j-bryan d5d4f26
Working on docstrings
j-bryan e3e14cd
completes docstrings
j-bryan 600e9a1
removing unused files
j-bryan 26bd9d2
fix: missed some docstrings and type hints
j-bryan 4897a04
WIP Merge branch 'devel' into additive_templating
j-bryan 3983392
integrate implementation of parallel settings files
j-bryan 9b28c87
developer guide for the template driver
j-bryan a9118da
file pathing
j-bryan 6fa9d35
fix: modifies RampFreq test to make solution unique
j-bryan 6c48352
fix: adjust rel_err threshold for new gold file
j-bryan fb59267
dbg: archive CapacityFactors test results with Github action
j-bryan 2720cba
dbg: revert change to github action
j-bryan bfd45c6
fix(tests): adjust zero threshold for capacity factors test
j-bryan 3a29161
fix: parallel settings for clusters are correctly identified
j-bryan 6a22714
fix: typos, calculation reuse, source combination assertion
j-bryan 3ad53df
fix: typos and linting warnings
j-bryan b785ed3
fix: some fixes for Gabe's review comments
j-bryan 55aea34
fix(tests): adds docstrings to unit tests
j-bryan fccf760
fix(docs): missing docstrings for decorator classes
j-bryan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# The HERON Template Driver: A Guide for the HERON Developer | ||
|
||
The HERON template driver is the portion of HERON which constructs RAVEN workflows given the information provided in the HERON input file. | ||
In HERON, a template consists of an XML file which outlines a RAVEN workflow and a Python class which configures that workflow with the provided case information. | ||
The template driver determines which template is most appropriate for each case. | ||
The goal of this guide to explain the design philosophy of the template driver and give guidance on how it should be modified when adding features to HERON. | ||
An illustrative diagram of the major object types and their interactions is given in the figure below. | ||
 | ||
|
||
The current template system was developed with a few guiding principles in mind: | ||
1. XML nodes in the template XML should never be removed by the template's Python class. If a node is present in the XML, you can count in being able to access it anywhere in the template class. | ||
2. Subclasses of `RavenSnippet` should handle all XML operations within the block of XML described by the snippet class. Subclasses of `RavenTemplate` should handle orchestrating the connections among these snippets. | ||
3. Use a flat workflow whenever possible. While any valid HERON case can be run with the bilevel template, the overhead of starting a new instance of RAVEN for each inner workflow iteration can add significantly slow down analyses. | ||
|
||
Also, if you're editing anything in the template drivers: | ||
- Use type hints THOROUGHLY | ||
- Favor properties over getter/setter methods | ||
|
||
## Templates | ||
There are currently three main "flavors" of templates in the HERON templating system: | ||
- Bilevel templates: workflows with an outer workflow for varying system capacity and economic variables and an inner workflow for evaluating the system dispatch over multiple time histories. The bilevel templates are further broken down by case mode ("opt" or "sweep") and time history source (sythetic or static). | ||
- "Flat" templates: workflows which can be collapsed to either an inner or outer workflow. | ||
- Debug template: a special template for HERON's "debug" mode. | ||
|
||
## Flat Template Limitations | ||
Some cases which mathematically could be flat workflows cannot currently be implemented as such due to implementation issues in RAVEN or HERON. | ||
- "opt" mode workflows with a single time history. The limitation is the RAVEN MultiRun step accepts either an Optimizer or a Sampler, but not both. To sample the time history (static or synthetic) requires the use of a sampler in the MultiRun step. | ||
- Some workflows with uncertain economic parameters could be flat workflows, but the cashflows they describe are quantified in the HERON dispatch manager. There is currently no way to sample an uncertain economic parameter without running the dispatch optimization. | ||
|
||
## Should I make a new template? | ||
The templating system is designed to make creating new templates a somewhat easy task. | ||
However, a balance must be struct between configuring existing templates and creating new templates. | ||
When is it appropriate to make a new template? | ||
|
||
Don't make a new template if... | ||
- Substituting one algorithm for another (e.g. Bayesian optimization vs. gradient descent for optimization) | ||
- Exposing options for an algorithm or entity that is already used by one or more templates | ||
|
||
Make a new template if... | ||
- Adding significant new functionality, like new workflow types or new HERON case modes | ||
- There is little overlap between the desired workflow and existing templates | ||
- Adding a feature affects many parts of the template XML | ||
|
||
The final decision is left to the best judgement of the developer. | ||
However, creating a new template likely represents a signficant development effort and would benefit from consultation with the core HERON development team. | ||
|
||
## So you want to... | ||
An approximate guide on steps to take to implement new features. | ||
|
||
### Expose an existing RAVEN feature to the HERON user | ||
1. Create a new RavenSnippet subclass for the feature if one does not yet exist. Expose subelement and attribute options as class properties. | ||
2. Add unit tests for the snippet class. | ||
3. Determine which templates can make use of the feature. If using the feature would require removing a node from the template XML, the template node should be removed and the feature should be added to the workflow from the python class. | ||
|
||
### Add a new HERON case mode | ||
1. If the case mode will be run as a bilevel workflow, a new template file and class will likely need to be made for the bilevel outer template (currently split out by different modes). | ||
2. If some cases of the mode could be run as a flat template, implement that as appropriate. This could be modifying the existing `FlatMultiConfigTemplate` template or creating a new template. Add this new template to the `TemplateDriver` as appropriate. | ||
|
||
### Make new kind of workflow | ||
1. A new template very likely needs to be made. Create one or more template XML files and their corresponding `RavenTemplate` classes to configure them. | ||
2. Consider which features of the workflow are useful in the other templates. Refactor as necessary. | ||
3. Add these templates to the `TemplateDriver`. |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.