Skip to content

Commit

Permalink
Boverhof.user plugins backend.2023.03.09 (#1137)
Browse files Browse the repository at this point in the history
* Replace time.process_time() with time.time()

* Exception handling

* Backend updates for user plugins

* If setttings bad throw runtime error

* code improvements

* foqus-user-plugin app support

* user plugin support

* catch foqusException from run_foqus

* Ran Black

* Lower base the application names for comparison

(cherry picked from commit a022cd9)
  • Loading branch information
boverhof authored and lbianchi-lbl committed Apr 28, 2023
1 parent 56a3300 commit 5038da8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
10 changes: 9 additions & 1 deletion cloud/aws/node/put-simulation-input/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ exports.handler = function(event, context, callback) {
return;
}
if (obj.filetype == "sinterconfig" && obj.aspenfile != undefined) {
log(`configuration - sinterconfig v0.1: model=${obj.aspenfile}`);
if (obj.aspenfile.endsWith('.acmf'))
params.Key = user_name + "/" + name + "/acm_sinter.json";
else if (obj.aspenfile.endsWith('.bkp'))
Expand All @@ -132,6 +133,7 @@ exports.handler = function(event, context, callback) {
}
}
else if (obj.filetype == "sinterconfig" && obj["config-version"] == "0.2") {
log(`configuration - sinterconfig v0.2: model=${obj.model.file} application=${app_name}`);
if (obj.model.file.endsWith('.acmf'))
params.Key = user_name + "/" + name + "/acm_sinter.json";
else if (obj.model.file.endsWith('.bkp'))
Expand All @@ -143,7 +145,12 @@ exports.handler = function(event, context, callback) {
}
}
else if (obj.filetype == "sinterconfig" && obj["filetype-version"] == "0.3") {
if (obj.model.file.endsWith('.acmf') && obj.application.name == "Aspen Custom Modeler")
var app_name = obj.application.name;
app_name = app_name.toLowerCase();
log(`configuration - sinterconfig v0.3: model=${obj.model.file} application=${app_name}`);
if (obj.model.file.endsWith('.py') && app_name == "foqus-user-plugin")
params.Key = user_name + "/" + name + "/" + app_name + ".json";
else if (obj.model.file.endsWith('.acmf') && app_name == "aspen custom modeler")
params.Key = user_name + "/" + name + "/acm_sinter.json";
else if (obj.model.file.endsWith('.bkp'))
params.Key = user_name + "/" + name + "/aspenplus_sinter.json";
Expand All @@ -154,6 +161,7 @@ exports.handler = function(event, context, callback) {
}
}
else if (obj.filetype == "FOQUS_Session" || obj.Type == "FOQUS_Session") {
log(`configuration - foqus session: filetype=${obj.filetype} application=${obj.Type}`);
params.Key = user_name + "/" + name + "/session.foqus";
}
else {
Expand Down
4 changes: 3 additions & 1 deletion cloud/aws/node/put-simulation-name/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ exports.handler = function(event, context, callback) {
config_filename = "aspenplus_sinter.json";
} else if (app == "fake-job") {
config_filename = "fake-job.json";
}else {
} else if (app == "foqus-user-plugin") {
config_filename = "foqus-user-plugin.json";
} else {
done(new Error(`Unsupported application "${event.body}"`));
return;
}
Expand Down
10 changes: 10 additions & 0 deletions foqus_lib/service/flowsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,16 @@ def _run(self):
self._delete_sqs_job()
try:
self.run_foqus(db, job_desc)
except foqusException as ex:
_log.exception("run_foqus foqusException")
self.increment_metric_job_finished(event="error.job.run")
msg = traceback.format_exc()
db.job_change_status(job_desc, "error", message=msg)
db.add_message(
"job failed in setup: %r" % (ex), job_desc["Id"], exception=msg
)
self.close()
raise
except Exception as ex:
_log.exception("run_foqus Exception")
self.increment_metric_job_finished(event="error.job.run")
Expand Down

0 comments on commit 5038da8

Please sign in to comment.