Skip to content

Commit

Permalink
undo 5408e5a srw cancel is clearer now; more fixes and error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
robnagler committed Dec 24, 2024
1 parent 4ce6f0f commit c69c033
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
14 changes: 9 additions & 5 deletions sirepo/job_driver/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,23 +281,27 @@ async def _agent_ready(self, op):
return True

def _agent_receive(self, msg):
def _error(content):
if "error" in content:
pkdlog("{} agent error msg={}", self, c)
return "internal error in job_agent"
pkdlog("{} no 'reply' in msg={}", self, c)
return "invalid message from job_agent"

c = msg.content
i = c.get("opId")
if (
"opName" not in c
or c.opName == job.OP_ERROR
or ("reply" in c and c.reply.get("state") == job.ERROR)
):
# Log allerror message
# Log all errors
pkdlog("{} error msg={}", self, c)
else:
pkdlog("{} opName={} o={:.4}", self, c.opName, i)
if i:
if "reply" not in c:
pkdlog("{} no reply in msg={}", self, c)
c.reply = PKDict(
state=job.ERROR, error="invalid message from job_agent"
)
c.reply = PKDict(state=job.ERROR, error=_error(c))
if i in self._prepared_sends:
# SECURITY: only ops known to this driver can be replied to
self._prepared_sends[i].reply_put(c.opName, c.reply)
Expand Down
2 changes: 1 addition & 1 deletion sirepo/job_supervisor.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ def _update_db():

async def _valid_or_reply(force_run):
if self._is_running_pending():
if self._req_is_valid(req):
if not self._req_is_valid(req):
return PKDict(
state=job.ERROR,
error="another browser is running the simulation",
Expand Down
4 changes: 2 additions & 2 deletions sirepo/package_data/static/js/sirepo.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ SIREPO.srlog = (...args) => {console.log(
...args,
);};
SIREPO.srdbg = SIREPO.srlog;
SIREPO.traceWS = false;
SIREPO.traceWS = true;

// No timeout for now (https://github.com/radiasoft/sirepo/issues/317)
SIREPO.http_timeout = 0;
Expand Down Expand Up @@ -1288,7 +1288,7 @@ SIREPO.app.service('sbatchLoginService', function($rootScope, appState, authStat
}

transition() {
// DEBUG (`${this._oldState} ${this._event} => ${this._newState}`, this._arg);
srdbg(`${this._oldState} ${this._event} => ${this._newState}`, this._arg);
_state = this._newState;
$rootScope.$broadcast('sbatchLoginEvent', this);
}
Expand Down
18 changes: 4 additions & 14 deletions sirepo/package_data/static/js/srw.js
Original file line number Diff line number Diff line change
Expand Up @@ -2575,11 +2575,10 @@ SIREPO.app.directive('simulationStatusPanel', function(appState, beamlineService
</div>
</div>
<div data-ng-show="simState.isStopped() && ! isFluxWithApproximateMethod()">
<div data-ng-if="normalCompletion()" data-simulation-stopped-status="simState"></div>
<div class="col-sm-12" data-ng-if="! normalCompletion()">Simulation Cancelled</div>
<div class="col-sm-12" data-ng-show="showFrameCount()">
Completed {{ runStepName }}: {{ particleNumber }} / {{ particleCount}}
</div>
<div data-simulation-stopped-status="simState"></div>
<div class="col-sm-12" data-ng-show="showFrameCount()">
Completed {{ runStepName }}: {{ particleNumber }} / {{ particleCount}}
</div>
<div class="col-sm-12" data-simulation-status-timer="simState"></div>
<div data-job-settings-sbatch-login-and-start-simulation data-sim-state="simState" data-start-simulation="startSimulation()"></div>
</div>
Expand Down Expand Up @@ -2623,12 +2622,6 @@ SIREPO.app.directive('simulationStatusPanel', function(appState, beamlineService
}
}

$scope.normalCompletion = () => {
var d = Math.abs($scope.particleCount - $scope.particleNumber);
var a = appState.models.multiElectronAnimation;
return d < a.numberOfMacroElectronsAvg * a.savingPeriodicity;
};

$scope.logFileURL = () => {
if (! appState.isLoaded()) {
return '';
Expand Down Expand Up @@ -2657,9 +2650,6 @@ SIREPO.app.directive('simulationStatusPanel', function(appState, beamlineService
? 'mode' : 'macro-electrons';
}
$scope.particleCount = data.particleCount;
if ($scope.simState.isStateCompleted() && $scope.normalCompletion()){
$scope.particleNumber = $scope.particleCount;
}
}
if (data.frameCount) {
if (data.frameCount != frameCache.getFrameCount($scope.model)) {
Expand Down

0 comments on commit c69c033

Please sign in to comment.