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

Dispatches dependency #222

Merged
merged 3 commits into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dependencies.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<dependencies>
<main>
<dill/>
<dispatches source='pip'>1.0</dispatches>
<dill>0.3.5</dill>
<dispatches source='pip' optional='True'>1.0</dispatches>
<pyomo source='forge'/>
<pyutilib source='forge'/>
<glpk source='forge' skip_check='True'/>
Expand Down
19 changes: 11 additions & 8 deletions src/Herd.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,18 @@
from ravenframework.utils import xmlUtils
from ravenframework.ROMExternal import ROMLoader

# Nuclear flowsheet function imports
# NOTE: these paths will change for next DISPATCHES release
from dispatches.models.nuclear_case.flowsheets.nuclear_flowsheet import build_ne_flowsheet
from dispatches.models.nuclear_case.flowsheets.nuclear_flowsheet import fix_dof_and_initialize

# Import function for the construction of the multiperiod model
from dispatches.models.nuclear_case.flowsheets.multiperiod import build_multiperiod_design

from idaes.core.solvers import get_solver
# NOTE: these paths will change for next DISPATCHES release
try:
# Nuclear flowsheet function imports
from dispatches.models.nuclear_case.flowsheets.nuclear_flowsheet import (build_ne_flowsheet,
fix_dof_and_initialize)
# Import function for the construction of the multiperiod model
from dispatches.models.nuclear_case.flowsheets.multiperiod import build_multiperiod_design
from idaes.core.solvers import get_solver
except ModuleNotFoundError:
print("DISPATCHES has not been found in current conda environment. This is only needed when "+
"running the DISPATCHES workflow through HERD.")

# append path with RAVEN location
path_to_raven = hutils.get_raven_loc()
Expand Down
16 changes: 12 additions & 4 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from HERON.src import input_loader
from HERON.src.base import Base
from HERON.src.Moped import MOPED
from HERON.src import Herd
from HERON.src.Herd import HERD

from ravenframework.MessageHandler import MessageHandler

Expand Down Expand Up @@ -122,16 +122,24 @@ def run_dispatches_workflow(self):
@ In, None
@ Out, None
"""
# checking to see if DISPATCHES is properly installed
try:
import dispatches.models as tmp_lib
del tmp_lib
except ModuleNotFoundError as mnferr:
raise IOError('DISPATCHES has not been found in current conda environment.' +
'Please re-install the conda environment from RAVEN using the ' +
'--optional flag.') from mnferr
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen this from keyword before in relation to handling exceptions? It looks cool, what is it doing?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that the printouts with "while processing this error, another error occurred" or whatever? I like that a lot.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, py-lint recommended it from PEP 3134. It enables exception-chaining, re-raising the first exception and noting if the second exception is directly caused or happens during the error processing ("The above exception was the direct cause of the following exception:" versus "During handling of the above exception, another exception occurred:")

case = self._case
components = self._components
sources = self._sources
assert case is not None and components is not None and sources is not None
dispatches = Herd.HERD()
herd = HERD()
print("*******************************************************************************")
print("HERON is Running DISPATCHES")
print("*******************************************************************************")
dispatches.setInitialParams(case, components, sources)
dispatches.run()
herd.setInitialParams(case, components, sources)
herd.run()

def main():
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[./NuclearCaseSine]
type = HeronMoped
input = dispatches_sine_input.xml
required_libraries = 'dispatches'
# prereq = arma
[./csv]
type = OrderedCSV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
type = HeronMoped
input = dispatches_input.xml
max_time = 600
required_libraries = 'dispatches'
heavy = true
[./csv]
type = OrderedCSV
output = 'opt_solution__nuclearCase_notebook_match.csv'
Expand Down