Skip to content

Commit 891685d

Browse files
Merge branch 'master' into fix-api-base-url-generation
2 parents 33765d5 + db71616 commit 891685d

File tree

61 files changed

+649
-561
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+649
-561
lines changed

packages/models-library/src/models_library/api_schemas_webserver/computations.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ class ComputationStarted(OutputSchemaWithoutCamelCase):
8181
class ComputationRunListQueryParams(
8282
PageQueryParameters,
8383
ComputationRunListOrderParams, # type: ignore[misc, valid-type]
84-
): ...
84+
):
85+
filter_only_running: bool = Field(
86+
default=False,
87+
description="If true, only running computations are returned",
88+
)
8589

8690

8791
class ComputationRunRestGet(OutputSchema):
@@ -92,6 +96,8 @@ class ComputationRunRestGet(OutputSchema):
9296
submitted_at: datetime
9397
started_at: datetime | None
9498
ended_at: datetime | None
99+
root_project_name: str
100+
project_custom_metadata: dict[str, Any]
95101

96102

97103
### Computation Task

packages/models-library/src/models_library/computations.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,17 @@ class ComputationTaskWithAttributes(BaseModel):
2222
# Attributes added by the webserver
2323
node_name: str
2424
osparc_credits: Decimal | None
25+
26+
27+
class ComputationRunWithAttributes(BaseModel):
28+
project_uuid: ProjectID
29+
iteration: int
30+
state: RunningState
31+
info: dict[str, Any]
32+
submitted_at: datetime
33+
started_at: datetime | None
34+
ended_at: datetime | None
35+
36+
# Attributes added by the webserver
37+
root_project_name: str
38+
project_custom_metadata: dict[str, Any]

packages/models-library/src/models_library/projects_state.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,18 @@ class RunningState(str, Enum):
3535
ABORTED = "ABORTED"
3636
WAITING_FOR_CLUSTER = "WAITING_FOR_CLUSTER"
3737

38-
def is_running(self) -> bool:
39-
return self in (
38+
@staticmethod
39+
def list_running_states() -> list["RunningState"]:
40+
return [
4041
RunningState.PUBLISHED,
4142
RunningState.PENDING,
4243
RunningState.WAITING_FOR_RESOURCES,
4344
RunningState.STARTED,
4445
RunningState.WAITING_FOR_CLUSTER,
45-
)
46+
]
47+
48+
def is_running(self) -> bool:
49+
return self in self.list_running_states()
4650

4751

4852
@unique

packages/service-library/src/servicelib/rabbitmq/rpc_interfaces/director_v2/computations.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ async def list_computations_latest_iteration_page(
3333
*,
3434
product_name: ProductName,
3535
user_id: UserID,
36+
# filters
37+
filter_only_running: bool = False,
3638
# pagination
3739
offset: int = 0,
3840
limit: int = 20,
@@ -46,6 +48,7 @@ async def list_computations_latest_iteration_page(
4648
),
4749
product_name=product_name,
4850
user_id=user_id,
51+
filter_only_running=filter_only_running,
4952
offset=offset,
5053
limit=limit,
5154
order_by=order_by,

services/director-v2/src/simcore_service_director_v2/api/rpc/_computations.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ async def list_computations_latest_iteration_page(
2828
*,
2929
product_name: ProductName,
3030
user_id: UserID,
31+
# filters
32+
filter_only_running: bool = False,
3133
# pagination
3234
offset: int = 0,
3335
limit: int = 20,
@@ -39,6 +41,7 @@ async def list_computations_latest_iteration_page(
3941
await comp_runs_repo.list_for_user__only_latest_iterations(
4042
product_name=product_name,
4143
user_id=user_id,
44+
filter_only_running=filter_only_running,
4245
offset=offset,
4346
limit=limit,
4447
order_by=order_by,

services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ async def list_for_user__only_latest_iterations(
195195
*,
196196
product_name: str,
197197
user_id: UserID,
198+
# filters
199+
filter_only_running: bool,
198200
# pagination
199201
offset: int,
200202
limit: int,
@@ -229,6 +231,16 @@ async def list_for_user__only_latest_iterations(
229231
& (
230232
comp_runs.c.metadata["product_name"].astext == product_name
231233
) # <-- NOTE: We might create a separate column for this for fast retrieval
234+
& (
235+
comp_runs.c.result.in_(
236+
[
237+
RUNNING_STATE_TO_DB[item]
238+
for item in RunningState.list_running_states()
239+
]
240+
)
241+
)
242+
if filter_only_running
243+
else True
232244
)
233245
.group_by(comp_runs.c.project_uuid)
234246
.subquery("latest_runs")

services/static-webserver/client/source/class/osparc/dashboard/ServiceBrowser.js renamed to services/static-webserver/client/source/class/osparc/dashboard/AppBrowser.js

Lines changed: 64 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @ignore(fetch)
2323
*/
2424

25-
qx.Class.define("osparc.dashboard.ServiceBrowser", {
25+
qx.Class.define("osparc.dashboard.AppBrowser", {
2626
extend: osparc.dashboard.ResourceBrowserBase,
2727

2828
construct: function() {
@@ -43,8 +43,12 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
4343
this._resourcesInitialized = true;
4444

4545
this._resourcesList = [];
46-
osparc.store.Services.getServicesLatest()
47-
.then(services => {
46+
Promise.all([
47+
osparc.store.Services.getServicesLatest(),
48+
osparc.store.Templates.getTemplatesHypertools(),
49+
])
50+
.then(resps => {
51+
const services = resps[0];
4852
// Show "Contact Us" message if services.length === 0
4953
// Most probably is a product-stranger user (it can also be that the catalog is down)
5054
if (Object.keys(services).length === 0) {
@@ -65,30 +69,52 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
6569

6670
reloadResources: function() {
6771
this.__loadServices();
72+
this.__loadHypertools();
6873
},
6974

7075
__loadServices: function() {
7176
const excludeFrontend = true;
7277
const excludeDeprecated = true
7378
osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
74-
.then(servicesList => this.__setServicesToList(servicesList.filter(service => service !== null)));
79+
.then(servicesList => {
80+
servicesList.forEach(service => service["resourceType"] = "service");
81+
this._resourcesList.push(...servicesList.filter(service => service !== null));
82+
this.__sortAndReload();
83+
});
84+
},
85+
86+
__loadHypertools: function() {
87+
osparc.store.Templates.getTemplatesHypertools()
88+
.then(hypertoolsList => {
89+
hypertoolsList.forEach(hypertool => hypertool["resourceType"] = "hypertool");
90+
this._resourcesList.push(...hypertoolsList.filter(hypertool => hypertool !== null));
91+
this.__sortAndReload();
92+
});
93+
},
94+
95+
__sortAndReload: function() {
96+
osparc.service.Utils.sortObjectsBasedOn(this._resourcesList, this.__sortBy);
97+
this._reloadCards();
7598
},
7699

77100
_updateServiceData: function(serviceData) {
78101
serviceData["resourceType"] = "service";
79-
const servicesList = this._resourcesList;
80-
const index = servicesList.findIndex(service => service["key"] === serviceData["key"] && service["version"] === serviceData["version"]);
102+
const appsList = this._resourcesList;
103+
const index = appsList.findIndex(service => service["key"] === serviceData["key"] && service["version"] === serviceData["version"]);
81104
if (index !== -1) {
82-
servicesList[index] = serviceData;
105+
appsList[index] = serviceData;
83106
this._reloadCards();
84107
}
85108
},
86109

87-
__setServicesToList: function(servicesList) {
88-
servicesList.forEach(service => service["resourceType"] = "service");
89-
osparc.service.Utils.sortObjectsBasedOn(servicesList, this.__sortBy);
90-
this._resourcesList = servicesList;
91-
this._reloadCards();
110+
_updateHypertoolData: function(hypertoolData) {
111+
hypertoolData["resourceType"] = "hypertool";
112+
const appsList = this._resourcesList;
113+
const index = appsList.findIndex(service => service["uuid"] === hypertoolData["uuid"]);
114+
if (index !== -1) {
115+
appsList[index] = hypertoolData;
116+
this._reloadCards();
117+
}
92118
},
93119

94120
_reloadCards: function() {
@@ -103,8 +129,8 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
103129
},
104130

105131
__itemClicked: function(card) {
106-
const serviceData = card.getResourceData();
107-
this._openResourceDetails(serviceData);
132+
const appData = card.getResourceData();
133+
this._openResourceDetails(appData);
108134
this.resetSelection();
109135
},
110136

@@ -126,6 +152,28 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
126152
return this._resourcesContainer;
127153
},
128154

155+
__addSortingButtons: function() {
156+
const containerSortButtons = new osparc.service.SortServicesButtons();
157+
containerSortButtons.set({
158+
appearance: "form-button-outlined"
159+
});
160+
containerSortButtons.addListener("sortBy", e => {
161+
this.__sortBy = e.getData();
162+
this.__sortAndReload();
163+
}, this);
164+
this._toolbar.add(containerSortButtons);
165+
},
166+
167+
_populateCardMenu: function(card) {
168+
const menu = card.getMenu();
169+
const appData = card.getResourceData();
170+
171+
const openButton = this._getOpenMenuButton(appData);
172+
if (openButton) {
173+
menu.add(openButton);
174+
}
175+
},
176+
129177
__addNewServiceButtons: function() {
130178
const platformName = osparc.store.StaticInfo.getInstance().getPlatformName();
131179
const hasRights = osparc.data.Permissions.getInstance().canDo("studies.template.create.productAll");
@@ -140,7 +188,7 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
140188
this._toolbar.add(testDataButton);
141189
}
142190

143-
const addServiceButton = new qx.ui.form.Button(this.tr("Submit new service"), "@FontAwesome5Solid/plus-circle/14");
191+
const addServiceButton = new qx.ui.form.Button(this.tr("Submit new app"), "@FontAwesome5Solid/plus-circle/14");
144192
addServiceButton.set({
145193
appearance: "form-button-outlined",
146194
visibility: hasRights ? "visible" : "excluded"
@@ -149,30 +197,8 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
149197
this._toolbar.add(addServiceButton);
150198
},
151199

152-
__addSortingButtons: function() {
153-
const containerSortButtons = new osparc.service.SortServicesButtons();
154-
containerSortButtons.set({
155-
appearance: "form-button-outlined"
156-
});
157-
containerSortButtons.addListener("sortBy", e => {
158-
this.__sortBy = e.getData();
159-
this.__setServicesToList(this._resourcesList);
160-
}, this);
161-
this._toolbar.add(containerSortButtons);
162-
},
163-
164-
_populateCardMenu: function(card) {
165-
const menu = card.getMenu();
166-
const serviceData = card.getResourceData();
167-
168-
const openButton = this._getOpenMenuButton(serviceData);
169-
if (openButton) {
170-
menu.add(openButton);
171-
}
172-
},
173-
174200
__displayServiceSubmissionForm: function(formData) {
175-
const addServiceWindow = new osparc.ui.window.Window(this.tr("Submit a new service")).set({
201+
const addServiceWindow = new osparc.ui.window.Window(this.tr("Submit a new app")).set({
176202
modal: true,
177203
autoDestroy: true,
178204
showMinimize: false,

0 commit comments

Comments
 (0)