Skip to content

Commit 3147837

Browse files
authored
✨ Study from Template: Show messages and progress (ITISFoundation#3354)
1 parent 181170b commit 3147837

File tree

9 files changed

+55
-26
lines changed

9 files changed

+55
-26
lines changed

services/storage/src/simcore_service_storage/simcore_s3_dsm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ async def deep_copy_project_simcore_s3(
416416
src_project_uuid: ProjectID = ProjectID(src_project["uuid"])
417417
dst_project_uuid: ProjectID = ProjectID(dst_project["uuid"])
418418
# Step 1: check access rights (read of src and write of dst)
419-
update_task_progress(task_progress, "Checking project access rights...")
419+
update_task_progress(task_progress, "Checking study access rights...")
420420
async with self.engine.acquire() as conn:
421421
for prj_uuid in [src_project_uuid, dst_project_uuid]:
422422
if not await db_projects.project_exists(conn, prj_uuid):
@@ -438,7 +438,7 @@ async def deep_copy_project_simcore_s3(
438438

439439
# Step 2: start copying by listing what to copy
440440
update_task_progress(
441-
task_progress, f"Getting all files of project '{src_project_uuid}'..."
441+
task_progress, f"Collecting files of '{src_project['name']}'..."
442442
)
443443
async with self.engine.acquire() as conn:
444444
src_project_files: list[
@@ -455,7 +455,7 @@ async def deep_copy_project_simcore_s3(
455455
s3_transfered_data_cb = S3TransferDataCB(
456456
task_progress,
457457
src_project_total_data_size,
458-
task_progress_message_prefix=f"Copying {len(src_project_files)} files of project '{src_project_uuid}'",
458+
task_progress_message_prefix=f"Copying {len(src_project_files)} files to '{dst_project['name']}'",
459459
)
460460
for src_fmd in src_project_files:
461461
if not src_fmd.node_id or (src_fmd.location_id != self.location_id):

services/web/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
379379
const title = osparc.utils.Utils.getUniqueStudyName(templateData.name, this.__studies);
380380
templateData.name = title;
381381
this._showLoadingPage(this.tr("Creating ") + (templateData.name || this.tr("Study")));
382-
osparc.utils.Study.createStudyFromTemplate(templateData)
382+
osparc.utils.Study.createStudyFromTemplate(templateData, this._loadingPage)
383383
.then(studyId => {
384384
this._hideLoadingPage();
385385
this.__getStudyAndStart(studyId);

services/web/client/source/class/osparc/dashboard/TemplateBrowser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ qx.Class.define("osparc.dashboard.TemplateBrowser", {
227227
}
228228

229229
this._showLoadingPage(this.tr("Creating ") + (templateData.name || this.tr("Study")));
230-
osparc.utils.Study.createStudyFromTemplate(templateData)
230+
osparc.utils.Study.createStudyFromTemplate(templateData, this._loadingPage)
231231
.then(studyId => {
232232
this._hideLoadingPage();
233233
this.__startStudy(studyId, templateData);

services/web/client/source/class/osparc/data/PollTask.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ qx.Class.define("osparc.data.PollTask", {
3939
},
4040

4141
events: {
42+
"updateReceived": "qx.event.type.Data",
4243
"resultReceived": "qx.event.type.Data",
4344
"pollingError": "qx.event.type.Data"
4445
},
@@ -92,6 +93,7 @@ qx.Class.define("osparc.data.PollTask", {
9293
const done = response["done"];
9394
this.setDone(done);
9495
if (done === false) {
96+
this.fireDataEvent("updateReceived", response);
9597
// keep polling
9698
setTimeout(() => this.__pollTaskState(), this.getPollInterval());
9799
}

services/web/client/source/class/osparc/data/model/Node.js

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,6 +1155,7 @@ qx.Class.define("osparc.data.model.Node", {
11551155
break;
11561156
}
11571157
},
1158+
11581159
__nodeState: function() {
11591160
// Check if study is still there
11601161
if (this.getStudy() === null || this.__stopRequestingStatus === true) {
@@ -1174,24 +1175,31 @@ qx.Class.define("osparc.data.model.Node", {
11741175
osparc.data.Resources.fetch("studies", "getNode", params)
11751176
.then(data => this.__onNodeState(data))
11761177
.catch(err => {
1177-
if ("status" in err && err.status === 503 && this.__unresponsiveRetries > 0) {
1178-
this.__unresponsiveRetries--;
1179-
const interval = Math.floor(Math.random() * 5000) + 3000;
1180-
console.log(this.getNodeId(), "node unresponive, trying again in", interval, this.__unresponsiveRetries);
1181-
setTimeout(() => this.__nodeState(), interval);
1182-
return;
1183-
}
1184-
const errorMsg = "Error when retrieving " + this.getKey() + ":" + this.getVersion() + " status: " + err;
1178+
const errorMsg = `Error retrieving ${this.getLabel()} status: ${err}`;
11851179
const errorMsgData = {
11861180
nodeId: this.getNodeId(),
11871181
msg: errorMsg,
11881182
level: "ERROR"
11891183
};
11901184
this.fireDataEvent("showInLogger", errorMsgData);
1191-
this.getStatus().setInteractive("failed");
1192-
osparc.component.message.FlashMessenger.getInstance().logAs(this.tr("There was an error while starting the node."), "ERROR");
1185+
if (this.__unresponsiveRetries > 0) {
1186+
const retryMsg = `Retrying (${this.__unresponsiveRetries})`;
1187+
const retryMsgData = {
1188+
nodeId: this.getNodeId(),
1189+
msg: retryMsg,
1190+
level: "ERROR"
1191+
};
1192+
this.fireDataEvent("showInLogger", retryMsgData);
1193+
this.__unresponsiveRetries--;
1194+
const interval = Math.floor(Math.random() * 5000) + 3000;
1195+
setTimeout(() => this.__nodeState(), interval);
1196+
} else {
1197+
this.getStatus().setInteractive("failed");
1198+
osparc.component.message.FlashMessenger.getInstance().logAs(this.tr("There was an error while starting the node."), "ERROR");
1199+
}
11931200
});
11941201
},
1202+
11951203
__onInteractiveNodeStarted: function(e) {
11961204
let req = e.getTarget();
11971205
const {

services/web/client/source/class/osparc/ui/basic/LoadingPageHandler.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,28 @@ qx.Class.define("osparc.ui.basic.LoadingPageHandler", {
2323
type: "abstract",
2424

2525
members: {
26-
__loadingIFrame: null,
26+
_loadingPage: null,
2727

2828
_showLoadingPage: function(label) {
2929
this._hideLoadingPage();
3030

3131
this._showMainLayout(false);
3232

33-
if (this.__loadingIFrame === null) {
34-
this.__loadingIFrame = new osparc.ui.message.Loading(label);
33+
if (this._loadingPage === null) {
34+
this._loadingPage = new osparc.ui.message.Loading(label);
3535
} else {
36-
this.__loadingIFrame.setHeader(label);
36+
this._loadingPage.setHeader(label);
3737
}
38-
this._add(this.__loadingIFrame, {
38+
this._add(this._loadingPage, {
3939
flex: 1
4040
});
4141
},
4242

4343
_hideLoadingPage: function() {
44-
if (this.__loadingIFrame) {
45-
const idx = this._indexOf(this.__loadingIFrame);
44+
if (this._loadingPage) {
45+
const idx = this._indexOf(this._loadingPage);
4646
if (idx !== -1) {
47-
this._remove(this.__loadingIFrame);
47+
this._remove(this._loadingPage);
4848
}
4949
}
5050

services/web/client/source/class/osparc/ui/message/Loading.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ qx.Class.define("osparc.ui.message.Loading", {
7575
"maximize" : "qx.event.type.Event"
7676
},
7777

78+
statics: {
79+
LOGO_WIDTH: 260
80+
},
81+
7882
members: {
7983
__header: null,
8084
__messages: null,
@@ -83,7 +87,7 @@ qx.Class.define("osparc.ui.message.Loading", {
8387

8488
__buildLayout: function(showMaximize) {
8589
const image = new osparc.ui.basic.Logo().set({
86-
width: 260,
90+
width: this.self().LOGO_WIDTH,
8791
height: 110
8892
});
8993

@@ -153,6 +157,9 @@ qx.Class.define("osparc.ui.message.Loading", {
153157
});
154158
},
155159

160+
addWidgetToMessages: function(widget) {
161+
this.__messages.add(widget);
162+
},
156163

157164

158165
// from osparc.component.widget.PersistentIframe

services/web/client/source/class/osparc/utils/Study.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ qx.Class.define("osparc.utils.Study", {
178178
});
179179
},
180180

181-
createStudyFromTemplate: function(templateData) {
181+
createStudyFromTemplate: function(templateData, loadingPage) {
182182
return new Promise((resolve, reject) => {
183183
const store = osparc.store.Store.getInstance();
184184
store.getInaccessibleServices(templateData)
@@ -205,6 +205,18 @@ qx.Class.define("osparc.utils.Study", {
205205
const interval = 1000;
206206
pollTasks.createPollingTask(fetchPromise, interval)
207207
.then(task => {
208+
task.addListener("updateReceived", e => {
209+
const updateData = e.getData();
210+
if ("task_progress" in updateData && loadingPage) {
211+
const progress = updateData["task_progress"];
212+
loadingPage.setMessages([progress["message"]]);
213+
const pBar = new qx.ui.indicator.ProgressBar(progress["percent"], 1).set({
214+
width: osparc.ui.message.Loading.LOGO_WIDTH,
215+
maxWidth: osparc.ui.message.Loading.LOGO_WIDTH
216+
});
217+
loadingPage.addWidgetToMessages(pBar);
218+
}
219+
}, this);
208220
task.addListener("resultReceived", e => {
209221
const studyData = e.getData();
210222
resolve(studyData["uuid"]);

services/web/server/src/simcore_service_webserver/projects/projects_handlers_crud.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ async def _create_projects(
251251
new_project = {}
252252
copy_file_coro = None
253253
try:
254-
task_progress.update(message="creating project document")
254+
task_progress.update(message="creating new study...")
255255
new_project_was_hidden_before_data_was_copied = query_params.hidden
256256
if query_params.from_study:
257257
# 1. prepare copy

0 commit comments

Comments
 (0)