Skip to content

Commit

Permalink
Improved Logging Output for node Failures: Bogus Steady State Error (#…
Browse files Browse the repository at this point in the history
…1028)

* Add properties for node module

* Update bool and add better error message to python node

* Escape quotes in python node
  • Loading branch information
boverhof authored May 12, 2022
1 parent 3689750 commit 0537a52
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 11 deletions.

Large diffs are not rendered by default.

36 changes: 26 additions & 10 deletions foqus_lib/framework/graph/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,22 @@ def __init__(self, x=0, y=0, z=0, parent=None, name=None):
self.running = False
self.synced = True

@property
def isModelTurbine(self) -> bool:
return self.modelType == nodeModelTypes.MODEL_TURBINE

@property
def isModelNone(self) -> bool:
return self.modelType == nodeModelTypes.MODEL_NONE

@property
def isModelPlugin(self) -> bool:
return self.modelType == nodeModelTypes.MODEL_PLUGIN

@property
def isModelML(self) -> bool:
return self.modelType == nodeModelTypes.MODEL_ML_AI

def setGraph(self, gr, name=None):
"""
Set the parent graph, node name, location of inputs and
Expand Down Expand Up @@ -472,7 +488,7 @@ def loadDict(self, sd):
o = sd.get("options", None)
if o:
self.options.loadDict(o)
if self.modelType == nodeModelTypes.MODEL_TURBINE:
if self.isModelTurbine:
self.addTurbineOptions()
# Below is just to maintain compatibility with older session files
# It may be deleted at some point in the future
Expand Down Expand Up @@ -543,10 +559,10 @@ def setSim(self, newType=None, newModel=None, force=False, ids=None):
# clear the pyModel since it may be old now
self.pyModel = None
# Now add stuff to the node depending on the model type
if self.modelType == nodeModelTypes.MODEL_NONE:
if self.isModelNone:
# no model don't add any variables and do nothing
return
elif self.modelType == nodeModelTypes.MODEL_PLUGIN:
elif self.isModelPlugin:
# python plugin worry about this later
inst = self.gr.pymodels.plugins[self.modelName].pymodel_pg()
# the node can have the pymodel instances variables since
Expand All @@ -557,7 +573,7 @@ def setSim(self, newType=None, newModel=None, force=False, ids=None):
self.gr.input[self.name][vkey] = v
for vkey, v in inst.outputs.items():
self.gr.output[self.name][vkey] = v
elif self.modelType == nodeModelTypes.MODEL_TURBINE:
elif self.isModelTurbine:
sc = self.gr.turbConfig.getSinterConfig(self.modelName)
modelTitle = str(sc.get("title", ""))
modelAuthor = str(sc.get("author", ""))
Expand Down Expand Up @@ -653,7 +669,7 @@ def setSim(self, newType=None, newModel=None, force=False, ids=None):
desc=item["description"],
optSet=NodeOptionSets.SINTER_OPTIONS,
)
elif self.modelType == nodeModelTypes.MODEL_ML_AI:
elif self.isModelML:
# link to pymodel class for ml/ai models
cwd = os.getcwd()
os.chdir(os.path.join(os.getcwd(), "user_ml_ai_models"))
Expand Down Expand Up @@ -756,13 +772,13 @@ def runModel(self):
Run the Model associated with the node.
"""
self.calcError = -1
if self.modelType == nodeModelTypes.MODEL_NONE:
if self.isModelNone:
pass
elif self.modelType == nodeModelTypes.MODEL_PLUGIN:
elif self.isModelPlugin:
self.runPymodelPlugin()
elif self.modelType == nodeModelTypes.MODEL_TURBINE:
elif self.isModelTurbine:
self.runTurbineCalc(retry=self.options["Retry"].value)
elif self.modelType == nodeModelTypes.MODEL_ML_AI:
elif self.isModelML:
self.runPymodelMLAI()
else:
# This shouldn't happen from the GUI there should
Expand Down Expand Up @@ -791,7 +807,7 @@ def resetModel(self):
Stop consumer, when the model is run next a new consumer
will start up for it. This is useful if a model fails.
"""
if self.modelType == nodeModelTypes.MODEL_TURBINE:
if self.isModelTurbine:
self.gr.turbConfig.stopConsumer(self.name)

def runPymodelPlugin(self):
Expand Down

0 comments on commit 0537a52

Please sign in to comment.