Skip to content

Commit

Permalink
fixed parallel execution
Browse files Browse the repository at this point in the history
  • Loading branch information
alfoa committed May 9, 2024
1 parent af23869 commit ee2f53f
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 531 deletions.
2 changes: 1 addition & 1 deletion plugins/HERON
Submodule HERON updated 107 files
19 changes: 13 additions & 6 deletions ravenframework/Models/EnsembleModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,7 @@ def submit(self,myInput,samplerType,jobHandler,**kwargs):
for index in range(nRuns):
if batchMode:
kw = kwargs['batchInfo']['batchRealizations'][index]
kw['batchRun'] = index + 1
else:
kw = kwargs

Expand Down Expand Up @@ -667,8 +668,11 @@ def _externalRun(self,inRun, jobHandler = None):#, jobHandler):
else:
self.raiseAnError(IOError,"No initial conditions provided for variable "+ initialConditionToSet)
# set new identifiers
inputKwargs[modelIn]['prefix'] = modelIn+utils.returnIdSeparator()+identifier
inputKwargs[modelIn]['uniqueHandler'] = self.name+identifier
suffix = ''
if 'batchRun' in inputKwargs[modelIn]:
suffix = f"{utils.returnIdSeparator()}{inputKwargs[modelIn]['batchRun']}"
inputKwargs[modelIn]['prefix'] = modelIn+utils.returnIdSeparator()+identifier + suffix
inputKwargs[modelIn]['uniqueHandler'] = self.name + identifier + suffix
if metadataToTransfer is not None:
inputKwargs[modelIn]['metadataToTransfer'] = metadataToTransfer

Expand Down Expand Up @@ -742,9 +746,11 @@ def __advanceModel(self, identifier, modelToExecute, origInputList, inputKwargs,
@ Out, evaluation, dict, the evaluation dictionary with the "unprojected" data
"""
returnDict = {}

suffix = ''
if 'batchRun' in inputKwargs:
suffix = f"{utils.returnIdSeparator()}{inputKwargs['batchRun']}"
self.raiseADebug('Submitting model',modelToExecute['Instance'].name)
localIdentifier = modelToExecute['Instance'].name+utils.returnIdSeparator()+identifier
localIdentifier = f"{modelToExecute['Instance'].name}{utils.returnIdSeparator()}{identifier}{suffix}"
if self.parallelStrategy == 1:
# we evaluate the model directly
try:
Expand All @@ -763,7 +769,7 @@ def __advanceModel(self, identifier, modelToExecute, origInputList, inputKwargs,
time.sleep(1.e-3)
moveOn = True
# get job that just finished to gather the results
finishedRun = jobHandler.getFinished(jobIdentifier = localIdentifier, uniqueHandler=self.name+identifier)
finishedRun = jobHandler.getFinished(jobIdentifier = localIdentifier, uniqueHandler=f"{self.name}{identifier}{suffix}")
evaluation = finishedRun[0].getEvaluation()
if isinstance(evaluation, rerror):
if finishedRun[0].exceptionTrace is not None:
Expand All @@ -774,7 +780,8 @@ def __advanceModel(self, identifier, modelToExecute, origInputList, inputKwargs,
evaluation = None
# the model failed
for modelToRemove in list(set(self.orderList) - set([modelToExecute['Instance'].name])):
jobHandler.getFinished(jobIdentifier = modelToRemove + utils.returnIdSeparator() + identifier, uniqueHandler = self.name + identifier)
jobHandler.getFinished(jobIdentifier = f"{modelToRemove}{utils.returnIdSeparator()}{identifier}{suffix}", uniqueHandler = f"{self.name}{identifier}{suffix}")

else:
# collect the target evaluation
modelToExecute['Instance'].collectOutput(finishedRun[0],inRunTargetEvaluations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
optimize
</Sequence>
<WorkingDir>metaModelWithCodeAndFunctionsAndGenetic</WorkingDir>
<batchSize>1</batchSize>
<batchSize>2</batchSize>
</RunInfo>

<Files>
Expand Down

This file was deleted.

Loading

0 comments on commit ee2f53f

Please sign in to comment.