Skip to content
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
2ebf1b7
initial commit
giancarloromeo Apr 16, 2025
347e323
fix keys generation
giancarloromeo Apr 16, 2025
792de64
update signature
giancarloromeo Apr 16, 2025
bf3e5b7
continue
giancarloromeo Apr 16, 2025
c390a3e
return task name
giancarloromeo Apr 16, 2025
0c10248
fix methods
giancarloromeo Apr 16, 2025
9bfad29
add task_name
giancarloromeo Apr 16, 2025
17a896d
fix test
giancarloromeo Apr 16, 2025
d02fe75
update name
giancarloromeo Apr 16, 2025
2416227
fix tests
giancarloromeo Apr 16, 2025
7ce6297
Merge branch 'master' into is7528/add-name-when-listing-tasks
giancarloromeo Apr 16, 2025
5bbcefc
typecheck
giancarloromeo Apr 16, 2025
eda9e7f
Merge branch 'is7528/add-name-when-listing-tasks' of github.com:gianc…
giancarloromeo Apr 16, 2025
bf6af2d
move forget
giancarloromeo Apr 16, 2025
5e70c09
legacy
giancarloromeo Apr 16, 2025
e612858
Merge branch 'master' into is7528/add-name-when-listing-tasks
giancarloromeo Apr 16, 2025
96cdf2a
fix test
giancarloromeo Apr 16, 2025
c1ec12b
Merge branch 'is7528/add-name-when-listing-tasks' of github.com:gianc…
giancarloromeo Apr 16, 2025
726f4ce
fix test
giancarloromeo Apr 16, 2025
417876f
fix async routine
giancarloromeo Apr 16, 2025
0cbec0d
rename
giancarloromeo Apr 16, 2025
53187d3
add legacy name
giancarloromeo Apr 16, 2025
2e96147
add check
giancarloromeo Apr 16, 2025
f941163
add exception handling
giancarloromeo Apr 16, 2025
939279d
update logger level
giancarloromeo Apr 16, 2025
2243c57
add validators
giancarloromeo Apr 17, 2025
584395c
Merge branch 'master' into is7528/add-name-when-listing-tasks
giancarloromeo Apr 17, 2025
0cccc5b
Merge branch 'master' into is7528/add-name-when-listing-tasks
giancarloromeo Apr 17, 2025
0dfceab
fix start
odeimaiz Apr 17, 2025
7cfd1a2
Merge branch 'is7528/add-name-when-listing-tasks' of github.com:gianc…
odeimaiz Apr 21, 2025
928fec3
taskName property
odeimaiz Apr 21, 2025
9ad0969
__attachTasks
odeimaiz Apr 21, 2025
feb24cd
refactor
odeimaiz Apr 21, 2025
e03b40e
getExportDataTasks
odeimaiz Apr 21, 2025
d16886c
refactor
odeimaiz Apr 21, 2025
ee1dea5
minor
odeimaiz Apr 21, 2025
88e679a
Merge branch 'master' into tasks-persist
giancarloromeo Apr 22, 2025
e492635
bad merge
odeimaiz Apr 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
from typing import Any, TypeAlias
from typing import Annotated, Any, TypeAlias
from uuid import UUID

from models_library.users import UserID
from pydantic import BaseModel
from pydantic import BaseModel, StringConstraints

from ..products import ProductName
from ..progress_bar import ProgressReport
from ..users import UserID

AsyncJobId: TypeAlias = UUID
AsyncJobName: TypeAlias = Annotated[
str, StringConstraints(strip_whitespace=True, min_length=1)
]


class AsyncJobStatus(BaseModel):
Expand All @@ -21,6 +25,7 @@ class AsyncJobResult(BaseModel):

class AsyncJobGet(BaseModel):
job_id: AsyncJobId
job_name: AsyncJobName


class AsyncJobAbort(BaseModel):
Expand All @@ -31,5 +36,5 @@ class AsyncJobAbort(BaseModel):
class AsyncJobNameData(BaseModel):
"""Data for controlling access to an async job"""

product_name: ProductName
user_id: UserID
product_name: str
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ qx.Class.define("osparc.dashboard.NewStudies", {
}
return templates.find(t => t.name === newButtonInfo.expectedTemplateLabel);
});
this.fireEvent("templatesLoaded");
},

properties: {
Expand All @@ -56,7 +55,6 @@ qx.Class.define("osparc.dashboard.NewStudies", {
},

events: {
"templatesLoaded": "qx.event.type.Event",
"newStudyClicked": "qx.event.type.Data",
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -978,23 +978,21 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
const templates = osparc.store.Templates.getInstance().getTemplates();
if (templates) {
const newStudies = new osparc.dashboard.NewStudies(newStudiesConfig);
newStudies.addListener("templatesLoaded", () => {
newStudies.setGroupBy("category");
const winTitle = this.tr("New Plan");
const win = osparc.ui.window.Window.popUpInWindow(newStudies, winTitle, osparc.dashboard.NewStudies.WIDTH+40, 300).set({
clickAwayClose: false,
resizable: true
});
newStudies.addListener("newStudyClicked", e => {
win.close();
const templateInfo = e.getData();
const templateData = templates.find(t => t.name === templateInfo.expectedTemplateLabel);
if (templateData) {
this.__newPlanBtnClicked(templateData, templateInfo.newStudyLabel);
}
});
osparc.utils.Utils.setIdToWidget(win, "newStudiesWindow");
newStudies.setGroupBy("category");
const winTitle = this.tr("New Plan");
const win = osparc.ui.window.Window.popUpInWindow(newStudies, winTitle, osparc.dashboard.NewStudies.WIDTH+40, 300).set({
clickAwayClose: false,
resizable: true
});
newStudies.addListener("newStudyClicked", e => {
win.close();
const templateInfo = e.getData();
const templateData = templates.find(t => t.name === templateInfo.expectedTemplateLabel);
if (templateData) {
this.__newPlanBtnClicked(templateData, templateInfo.newStudyLabel);
}
});
osparc.utils.Utils.setIdToWidget(win, "newStudiesWindow");
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ qx.Class.define("osparc.data.PollTask", {
if (taskData && "task_id" in taskData) {
this.set({
taskId: taskData["task_id"],
taskName: taskData["task_name"] || "",
statusHref: taskData["status_href"],
resultHref: taskData["result_href"]
resultHref: taskData["result_href"],
});

if ("abort_href" in taskData) {
Expand Down Expand Up @@ -64,6 +65,11 @@ qx.Class.define("osparc.data.PollTask", {
nullable: false
},

taskName: {
check: "String",
nullable: true
},

statusHref: {
check: "String",
nullable: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ qx.Class.define("osparc.desktop.MainPage", {
flex: 1
});

this.__attachTasks();
this.__listenToWalletSocket();
this.__attachHandlers();
});
Expand All @@ -90,6 +91,14 @@ qx.Class.define("osparc.desktop.MainPage", {
__loadingPage: null,
__studyEditor: null,

__attachTasks: function() {
const pollTasks = osparc.store.PollTasks.getInstance();
const exportDataTasks = pollTasks.getExportDataTasks();
exportDataTasks.forEach(task => {
osparc.task.ExportData.exportDataTaskReceived(task, false);
});
},

__listenToWalletSocket: function() {
const socket = osparc.wrapper.WebSocket.getInstance();
if (!socket.slotExists("walletOsparcCreditsUpdated")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
const fetchPromise = dataStore.exportData(paths);
const pollTasks = osparc.store.PollTasks.getInstance();
pollTasks.createPollingTask(fetchPromise)
.then(task => this.__exportDataTaskReceived(task))
.then(task => osparc.task.ExportData.exportDataTaskReceived(task))
.catch(err => osparc.FlashMessenger.logError(err, this.tr("Unsuccessful files download")));
},

Expand Down Expand Up @@ -245,71 +245,6 @@ qx.Class.define("osparc.file.FileLabelWithActions", {
}
},

__exportDataTaskReceived: function(task) {
const exportDataTaskUI = new osparc.task.ExportData();
exportDataTaskUI.setTask(task);
osparc.task.TasksContainer.getInstance().addTaskUI(exportDataTaskUI);

const progressWindow = new osparc.ui.window.Progress(
this.tr("Downloading files"),
"@FontAwesome5Solid/download/14",
this.tr("Downloading files..."),
);
if (task.getAbortHref()) {
const cancelButton = progressWindow.addCancelButton();
cancelButton.setLabel(this.tr("Ignore"));
const abortButton = new qx.ui.form.Button().set({
label: this.tr("Cancel"),
center: true,
minWidth: 100,
});
abortButton.addListener("execute", () => task.abortRequested());
progressWindow.addButton(abortButton);
abortButton.set({
appearance: "danger-button",
});
}
progressWindow.open();

task.addListener("updateReceived", e => {
const data = e.getData();
if (data["task_progress"]) {
if ("message" in data["task_progress"] && data["task_progress"]["message"]) {
progressWindow.setMessage(data["task_progress"]["message"]);
}
progressWindow.setProgress(osparc.data.PollTask.extractProgress(data) * 100);
}
}, this);
task.addListener("resultReceived", e => {
const taskData = e.getData();
if (taskData["result"]) {
const params = {
url: {
locationId: 0,
fileUuid: encodeURIComponent(taskData["result"]),
}
};
osparc.data.Resources.fetch("storageLink", "getOne", params)
.then(data => {
if (data && data.link) {
const fileName = taskData["result"].split("/").pop();
osparc.utils.Utils.downloadLink(data.link, "GET", fileName);
}
})
}
progressWindow.close();
});
task.addListener("taskAborted", () => {
osparc.FlashMessenger.logAs(this.tr("Download aborted"), "WARNING");
progressWindow.close();
});
task.addListener("pollingError", e => {
const err = e.getData();
osparc.FlashMessenger.logError(err);
progressWindow.close();
});
},

__deleteTaskReceived: function(task, paths) {
const taskUI = new osparc.task.TaskUI();
taskUI.setIcon("@FontAwesome5Solid/trash/14");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ qx.Class.define("osparc.store.PollTasks", {
return this.getTasks().filter(task => task.getTaskId().includes("from_study") && task.getTaskId().includes("as_template"));
},

getExportDataTasks: function() {
return this.getTasks().filter(task => task.getTaskName() && task.getTaskName() === "export_data");
},

removeTasks: function() {
const tasks = this.getTasks();
tasks.forEach(task => task.dispose());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,77 @@ qx.Class.define("osparc.task.ExportData", {
},

statics: {
ICON: "@FontAwesome5Solid/download"
ICON: "@FontAwesome5Solid/download",

exportDataTaskReceived: function(task, popUpProgressWindow = true) {
const exportDataTaskUI = new osparc.task.ExportData();
exportDataTaskUI.setTask(task);
osparc.task.TasksContainer.getInstance().addTaskUI(exportDataTaskUI);

if (popUpProgressWindow) {
const progressWindow = new osparc.ui.window.Progress(
qx.locale.Manager.tr("Downloading files"),
osparc.task.ExportData+"/14",
qx.locale.Manager.tr("Compressing files..."),
);

if (task.getAbortHref()) {
const cancelButton = progressWindow.addCancelButton();
cancelButton.setLabel(qx.locale.Manager.tr("Ignore"));
const abortButton = new qx.ui.form.Button().set({
label: qx.locale.Manager.tr("Cancel"),
center: true,
minWidth: 100,
});
abortButton.addListener("execute", () => task.abortRequested());
progressWindow.addButton(abortButton);
abortButton.set({
appearance: "danger-button",
});
}

task.addListener("updateReceived", e => {
const data = e.getData();
if (data["task_progress"]) {
if ("message" in data["task_progress"] && data["task_progress"]["message"]) {
progressWindow.setMessage(data["task_progress"]["message"]);
}
progressWindow.setProgress(osparc.data.PollTask.extractProgress(data) * 100);
}
});

task.addListener("resultReceived", () => progressWindow.close());
task.addListener("taskAborted", () => progressWindow.close());
task.addListener("pollingError", () => progressWindow.close());

progressWindow.open();
}

task.addListener("resultReceived", e => {
const taskData = e.getData();
if (taskData["result"]) {
const params = {
url: {
locationId: 0,
fileUuid: encodeURIComponent(taskData["result"]),
}
};
osparc.data.Resources.fetch("storageLink", "getOne", params)
.then(data => {
if (data && data.link) {
const fileName = taskData["result"].split("/").pop();
osparc.utils.Utils.downloadLink(data.link, "GET", fileName);
}
})
}
});
task.addListener("taskAborted", () => {
osparc.FlashMessenger.logAs(qx.locale.Manager.tr("Download aborted"), "WARNING");
});
task.addListener("pollingError", e => {
const err = e.getData();
osparc.FlashMessenger.logError(err);
});
}
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ qx.Class.define("osparc.ui.window.Progress", {
control.getChildControl("progress").set({
backgroundColor: "strong-main"
});
control.getContentElement().setStyles({
"border-radius": "4px"
});
this.addAt(control, 1);
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ qx.Class.define("osparc.utils.Utils", {
if (control && control.getContentElement()) {
control.getContentElement().setAttribute("autocomplete", "off");
control.getContentElement().setAttribute("type", "search");
control.getContentElement().setAttribute("name", "osparc-nope1234");
control.getContentElement().setAttribute("name", "osparcdontautomplete");
control.getContentElement().setAttribute("id", "osparcdontautomplete");
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async def _task_progress_cb(
) -> None:
worker = get_celery_worker(task.app)
assert task.name # nosec
await worker.set_progress(
await worker.set_task_progress(
task_id=task_id,
report=report,
)
Expand Down Expand Up @@ -87,7 +87,7 @@ async def export_data(

async def _progress_cb(report: ProgressReport) -> None:
assert task.name # nosec
await get_celery_worker(task.app).set_progress(task_id, report)
await get_celery_worker(task.app).set_task_progress(task_id, report)
_logger.debug("'%s' progress %s", task_id, report.percent_value)

async with ProgressBarData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
UploadLinks,
)
from ...modules.celery.client import CeleryTaskClient
from ...modules.celery.models import TaskUUID
from ...modules.celery.models import TaskMetadata, TaskUUID
from ...simcore_s3_dsm import SimcoreS3DataManager
from .._worker_tasks._files import complete_upload_file as remote_complete_upload_file
from .dependencies.celery import get_celery_client
Expand Down Expand Up @@ -284,8 +284,10 @@ async def complete_upload_file(
user_id=query_params.user_id,
product_name=_UNDEFINED_PRODUCT_NAME_FOR_WORKER_TASKS, # NOTE: I would need to change the API here
)
task_uuid = await celery_client.send_task(
remote_complete_upload_file.__name__,
task_uuid = await celery_client.submit_task(
TaskMetadata(
name=remote_complete_upload_file.__name__,
),
task_context=async_job_name_data.model_dump(),
user_id=async_job_name_data.user_id,
location_id=location_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,12 @@ async def list_jobs(
_ = filter_
assert app # nosec
try:
task_uuids = await get_celery_client(app).get_task_uuids(
tasks = await get_celery_client(app).list_tasks(
task_context=job_id_data.model_dump(),
)
except CeleryError as exc:
raise JobSchedulerError(exc=f"{exc}") from exc

return [AsyncJobGet(job_id=task_uuid) for task_uuid in task_uuids]
return [
AsyncJobGet(job_id=task.uuid, job_name=task.metadata.name) for task in tasks
]
Loading
Loading