Skip to content

Commit d0b4dda

Browse files
committed
Merge branch 'master' into pr/giancarloromeo/8011
2 parents fb1cd83 + 35e7048 commit d0b4dda

File tree

23 files changed

+238
-100
lines changed

23 files changed

+238
-100
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from enum import Enum, unique
6-
from typing import Annotated, Self, TypeAlias
6+
from typing import Annotated, Final, Self, TypeAlias
77

88
from pydantic import (
99
BaseModel,
@@ -65,6 +65,13 @@ def is_running(self) -> bool:
6565
return self in self.list_running_states()
6666

6767

68+
RUNNING_STATE_COMPLETED_STATES: Final[tuple[RunningState, ...]] = (
69+
RunningState.ABORTED,
70+
RunningState.FAILED,
71+
RunningState.SUCCESS,
72+
)
73+
74+
6875
@unique
6976
class DataState(str, Enum):
7077
UP_TO_DATE = "UPTODATE"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,4 +325,4 @@ class ComputationalPipelineStatusMessage(RabbitMessageBase, ProjectMessageBase):
325325
run_result: RunningState
326326

327327
def routing_key(self) -> str | None:
328-
return f"{self.project_id}"
328+
return f"{self.project_id}.all_nodes"

packages/pytest-simcore/src/pytest_simcore/docker_registry.py

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import docker
1616
import jsonschema
1717
import pytest
18+
import pytest_asyncio
1819
import tenacity
1920
from pytest_simcore.helpers.logging_tools import log_context
2021
from pytest_simcore.helpers.typing_env import EnvVarsDict
@@ -146,7 +147,7 @@ def wait_till_registry_is_responsive(url: str) -> bool:
146147
# ********************************************************* Services ***************************************
147148

148149

149-
def _pull_push_service(
150+
async def _pull_push_service(
150151
pull_key: str,
151152
tag: str,
152153
new_registry: str,
@@ -213,11 +214,13 @@ def _pull_push_service(
213214
assert image.tag(new_image_tag)
214215

215216
# push the image to the new location
216-
with log_context(
217-
logging.INFO,
218-
msg=f"Pushing {pull_key}:{tag} -> {new_image_tag} ...",
219-
):
220-
client.images.push(new_image_tag)
217+
async with aiodocker.Docker() as client:
218+
await client.images.push(new_image_tag)
219+
# with log_context(
220+
# logging.INFO,
221+
# msg=f"Pushing {pull_key}:{tag} -> {new_image_tag} ...",
222+
# ):
223+
# client.images.push(new_image_tag)
221224

222225
# return image io.simcore.* labels
223226
image_labels = dict(image.labels)
@@ -230,10 +233,10 @@ def _pull_push_service(
230233
}
231234

232235

233-
@pytest.fixture(scope="session")
236+
@pytest_asyncio.fixture(scope="session", loop_scope="session")
234237
def docker_registry_image_injector(
235238
docker_registry: str, node_meta_schema: dict
236-
) -> Callable[..., dict[str, Any]]:
239+
) -> Callable[[str, str, str | None], Awaitable[dict[str, Any]]]:
237240
def inject_image(
238241
source_image_repo: str, source_image_tag: str, owner_email: str | None = None
239242
):
@@ -249,82 +252,86 @@ def inject_image(
249252

250253

251254
@pytest.fixture
252-
def osparc_service(
255+
async def osparc_service(
253256
docker_registry: str, node_meta_schema: dict, service_repo: str, service_tag: str
254257
) -> dict[str, Any]:
255258
"""pulls the service from service_repo:service_tag and pushes to docker_registry using the oSparc node meta schema
256259
NOTE: 'service_repo' and 'service_tag' defined as parametrization
257260
"""
258-
return _pull_push_service(
261+
return await _pull_push_service(
259262
service_repo, service_tag, docker_registry, node_meta_schema
260263
)
261264

262265

263-
@pytest.fixture(scope="session")
264-
def sleeper_service(docker_registry: str, node_meta_schema: dict) -> dict[str, Any]:
266+
@pytest_asyncio.fixture(scope="session", loop_scope="session")
267+
async def sleeper_service(
268+
docker_registry: str, node_meta_schema: dict
269+
) -> dict[str, Any]:
265270
"""Adds a itisfoundation/sleeper in docker registry"""
266-
return _pull_push_service(
271+
return await _pull_push_service(
267272
"itisfoundation/sleeper", "1.0.0", docker_registry, node_meta_schema
268273
)
269274

270275

271-
@pytest.fixture(scope="session")
272-
def jupyter_service(docker_registry: str, node_meta_schema: dict) -> dict[str, Any]:
276+
@pytest_asyncio.fixture(scope="session", loop_scope="session")
277+
async def jupyter_service(
278+
docker_registry: str, node_meta_schema: dict
279+
) -> dict[str, Any]:
273280
"""Adds a itisfoundation/jupyter-base-notebook in docker registry"""
274-
return _pull_push_service(
281+
return await _pull_push_service(
275282
"itisfoundation/jupyter-base-notebook",
276283
"2.13.0",
277284
docker_registry,
278285
node_meta_schema,
279286
)
280287

281288

282-
@pytest.fixture(scope="session", params=["2.0.7"])
289+
@pytest_asyncio.fixture(scope="session", loop_scope="session", params=["2.0.7"])
283290
def dy_static_file_server_version(request: pytest.FixtureRequest):
284291
return request.param
285292

286293

287-
@pytest.fixture(scope="session")
288-
def dy_static_file_server_service(
294+
@pytest_asyncio.fixture(scope="session", loop_scope="session")
295+
async def dy_static_file_server_service(
289296
docker_registry: str, node_meta_schema: dict, dy_static_file_server_version: str
290297
) -> dict[str, Any]:
291298
"""
292299
Adds the below service in docker registry
293300
itisfoundation/dy-static-file-server
294301
"""
295-
return _pull_push_service(
302+
return await _pull_push_service(
296303
"itisfoundation/dy-static-file-server",
297304
dy_static_file_server_version,
298305
docker_registry,
299306
node_meta_schema,
300307
)
301308

302309

303-
@pytest.fixture(scope="session")
304-
def dy_static_file_server_dynamic_sidecar_service(
310+
@pytest_asyncio.fixture(scope="session", loop_scope="session")
311+
async def dy_static_file_server_dynamic_sidecar_service(
305312
docker_registry: str, node_meta_schema: dict, dy_static_file_server_version: str
306313
) -> dict[str, Any]:
307314
"""
308315
Adds the below service in docker registry
309316
itisfoundation/dy-static-file-server-dynamic-sidecar
310317
"""
311-
return _pull_push_service(
318+
return await _pull_push_service(
312319
"itisfoundation/dy-static-file-server-dynamic-sidecar",
313320
dy_static_file_server_version,
314321
docker_registry,
315322
node_meta_schema,
316323
)
317324

318325

319-
@pytest.fixture(scope="session")
320-
def dy_static_file_server_dynamic_sidecar_compose_spec_service(
326+
@pytest_asyncio.fixture(scope="session", loop_scope="session")
327+
async def dy_static_file_server_dynamic_sidecar_compose_spec_service(
321328
docker_registry: str, node_meta_schema: dict, dy_static_file_server_version: str
322329
) -> dict[str, Any]:
323330
"""
324331
Adds the below service in docker registry
325332
itisfoundation/dy-static-file-server-dynamic-sidecar-compose-spec
326333
"""
327-
return _pull_push_service(
334+
return await _pull_push_service(
328335
"itisfoundation/dy-static-file-server-dynamic-sidecar-compose-spec",
329336
dy_static_file_server_version,
330337
docker_registry,

services/director-v2/src/simcore_service_director_v2/utils/computations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Any
44

55
import arrow
6-
from models_library.projects_state import RunningState
6+
from models_library.projects_state import RUNNING_STATE_COMPLETED_STATES, RunningState
77
from models_library.services import ServiceKeyVersion
88
from models_library.services_regex import SERVICE_KEY_RE
99
from models_library.users import UserID
@@ -15,7 +15,7 @@
1515

1616
_logger = logging.getLogger(__name__)
1717

18-
_COMPLETED_STATES = (RunningState.ABORTED, RunningState.FAILED, RunningState.SUCCESS)
18+
1919
_RUNNING_STATES = (RunningState.STARTED,)
2020
_TASK_TO_PIPELINE_CONVERSIONS = {
2121
# tasks are initially in NOT_STARTED state, then they transition to published
@@ -50,16 +50,16 @@
5050
RunningState.NOT_STARTED,
5151
): RunningState.NOT_STARTED,
5252
# if there are only completed states with FAILED --> FAILED
53-
(*_COMPLETED_STATES,): RunningState.FAILED,
53+
(*RUNNING_STATE_COMPLETED_STATES,): RunningState.FAILED,
5454
# if there are only completed states with FAILED and not started ones --> NOT_STARTED
5555
(
56-
*_COMPLETED_STATES,
56+
*RUNNING_STATE_COMPLETED_STATES,
5757
RunningState.NOT_STARTED,
5858
): RunningState.NOT_STARTED,
5959
# the generic case where we have a combination of completed states, running states,
6060
# or published/pending tasks, not_started is a started pipeline
6161
(
62-
*_COMPLETED_STATES,
62+
*RUNNING_STATE_COMPLETED_STATES,
6363
*_RUNNING_STATES,
6464
RunningState.PUBLISHED,
6565
RunningState.PENDING,

services/director-v2/tests/integration/02/test_dynamic_services_routes.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,11 +276,13 @@ async def _mocked_context_manger(*args, **kwargs) -> AsyncIterator[None]:
276276
async def key_version_expected(
277277
dy_static_file_server_dynamic_sidecar_service: dict,
278278
dy_static_file_server_service: dict,
279-
docker_registry_image_injector: Callable,
279+
docker_registry_image_injector: Callable[
280+
[str, str, str | None], Awaitable[dict[str, Any]]
281+
],
280282
) -> list[tuple[ServiceKeyVersion, bool]]:
281283
results: list[tuple[ServiceKeyVersion, bool]] = []
282284

283-
sleeper_service = docker_registry_image_injector(
285+
sleeper_service = await docker_registry_image_injector(
284286
"itisfoundation/sleeper", "2.1.1", "[email protected]"
285287
)
286288

services/static-webserver/client/source/class/osparc/dashboard/CardBase.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
148148
return false;
149149
}
150150
case "shared-with-everyone": {
151-
const everyoneGroupIds = [
152-
groupsStore.getEveryoneProductGroup().getGroupId(),
153-
groupsStore.getEveryoneGroup().getGroupId(),
154-
];
151+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
155152
const found = Object.keys(checks).some(gId => everyoneGroupIds.includes(parseInt(gId)));
156153
// show those that are shared with "1" or product everyone's groupId
157154
return !found;
@@ -190,13 +187,12 @@ qx.Class.define("osparc.dashboard.CardBase", {
190187

191188
// Icon
192189
const groupsStore = osparc.store.Groups.getInstance();
193-
const groupEveryone = groupsStore.getEveryoneGroup();
194-
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
190+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
195191
const organizations = groupsStore.getOrganizations();
196192
const myGroupId = groupsStore.getMyGroupId();
197193

198194
const organizationIds = Object.keys(organizations).map(key => parseInt(key));
199-
if (gids.includes(groupEveryone.getGroupId()) || gids.includes(groupProductEveryone.getGroupId())) {
195+
if (gids.some(gid => everyoneGroupIds.includes(gid))) {
200196
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ALL);
201197
} else if (organizationIds.filter(value => gids.includes(value)).length) { // find intersection
202198
shareIcon.setSource(osparc.dashboard.CardBase.SHARED_ORGS);
@@ -230,14 +226,11 @@ qx.Class.define("osparc.dashboard.CardBase", {
230226

231227
addHintFromGids: function(icon, gids) {
232228
const groupsStore = osparc.store.Groups.getInstance();
233-
const groupEveryone = groupsStore.getEveryoneGroup();
234-
const groupProductEveryone = groupsStore.getEveryoneProductGroup();
229+
const everyoneGroups = groupsStore.getEveryoneGroups();
235230
const organizations = groupsStore.getOrganizations();
236231
const myGroupId = groupsStore.getMyGroupId();
237232

238-
const groups = [];
239-
groups.push(groupEveryone);
240-
groups.push(groupProductEveryone);
233+
const groups = everyoneGroups.slice();
241234
groups.push(...Object.values(organizations));
242235
const sharedGrps = [];
243236
groups.forEach(group => {
@@ -275,7 +268,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
275268
break;
276269
}
277270
let sharedGrpLabel = sharedGrps[i].getLabel();
278-
if ([groupEveryone, groupProductEveryone].includes(sharedGrps[i])) {
271+
if (everyoneGroups.includes(sharedGrps[i])) {
279272
sharedGrpLabel = "Public";
280273
}
281274
if (!sharedGrpLabels.includes(sharedGrpLabel)) {

services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,10 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
323323
templates.forEach(template => template["resourceType"] = "template");
324324
// For now, filtered in the frontend
325325
const groupsStore = osparc.store.Groups.getInstance();
326-
const everyoneGid = groupsStore.getEveryoneGroup().getGroupId();
327-
const productEveryoneGid = groupsStore.getEveryoneProductGroup().getGroupId();
326+
const everyoneGroupIds = groupsStore.getEveryoneGroupIds();
328327
const filteredTemplates = templates.filter(template => {
329-
const publicAccess = everyoneGid in template["accessRights"] || productEveryoneGid in template["accessRights"];
328+
const templateGroupIds = Object.keys(template["accessRights"]);
329+
const publicAccess = templateGroupIds.some(gid => everyoneGroupIds.includes(parseInt(gid)));
330330
if ([
331331
osparc.dashboard.StudyBrowser.CONTEXT.PUBLIC_TEMPLATES,
332332
osparc.dashboard.StudyBrowser.CONTEXT.SEARCH_PUBLIC_TEMPLATES,

services/static-webserver/client/source/class/osparc/data/model/User.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ qx.Class.define("osparc.data.model.User", {
5959
firstName,
6060
lastName,
6161
email,
62+
phoneNumber: userData["phone"] || null,
6263
thumbnail,
6364
label: userData["userName"] || description,
6465
description,
@@ -122,6 +123,13 @@ qx.Class.define("osparc.data.model.User", {
122123
event: "changeEmail",
123124
},
124125

126+
phoneNumber: {
127+
check: "String",
128+
nullable: true,
129+
init: null,
130+
event: "changePhoneNumber"
131+
},
132+
125133
thumbnail: {
126134
check: "String",
127135
nullable: true,

services/static-webserver/client/source/class/osparc/desktop/account/ProfilePage.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
5454
__userPrivacyModel: null,
5555
__updatePrivacyBtn: null,
5656
__userProfileForm: null,
57+
__sms2FAItem: null,
5758

5859
__fetchProfile: function() {
5960
osparc.data.Resources.getOne("profile", {}, null, false)
@@ -72,10 +73,15 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
7273
"firstName": data["first_name"] || "",
7374
"lastName": data["last_name"] || "",
7475
"email": data["login"],
76+
"phone": data["phone"] || "-",
7577
"expirationDate": data["expirationDate"] || null,
7678
});
7779
}
7880
this.__updateProfileBtn.setEnabled(false);
81+
82+
if (this.__sms2FAItem) {
83+
this.__sms2FAItem.setEnabled(Boolean(data["phone"]));
84+
}
7985
},
8086

8187
__setDataToPrivacy: function(privacyData) {
@@ -124,11 +130,19 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
124130
readOnly: true
125131
});
126132

133+
const phoneNumber = new qx.ui.form.TextField().set({
134+
placeholder: this.tr("Phone Number"),
135+
readOnly: true
136+
});
137+
127138
const profileForm = this.__userProfileForm = new qx.ui.form.Form();
128139
profileForm.add(username, "Username", null, "username");
129140
profileForm.add(firstName, "First Name", null, "firstName");
130141
profileForm.add(lastName, "Last Name", null, "lastName");
131142
profileForm.add(email, "Email", null, "email");
143+
if (osparc.store.StaticInfo.getInstance().is2FARequired()) {
144+
profileForm.add(phoneNumber, "Phone Number", null, "phoneNumber");
145+
}
132146
const singleWithIcon = this.__userProfileRenderer = new osparc.ui.form.renderer.SingleWithIcon(profileForm);
133147
box.add(singleWithIcon);
134148

@@ -155,6 +169,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
155169
"firstName": "",
156170
"lastName": "",
157171
"email": "",
172+
"phone": "",
158173
"expirationDate": null,
159174
};
160175

@@ -169,6 +184,7 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
169184
}
170185
});
171186
controller.addTarget(lastName, "value", "lastName", true);
187+
controller.addTarget(phoneNumber, "value", "phone", true);
172188
controller.addTarget(expirationDate, "value", "expirationDate", false, {
173189
converter: expirationDay => {
174190
if (expirationDay) {
@@ -404,6 +420,9 @@ qx.Class.define("osparc.desktop.account.ProfilePage", {
404420
label: "Disabled"
405421
}].forEach(options => {
406422
const lItem = new qx.ui.form.ListItem(options.label, null, options.id);
423+
if (options.id === "SMS") {
424+
this.__sms2FAItem = lItem;
425+
}
407426
twoFAPreferenceSB.add(lItem);
408427
});
409428
const value = preferencesSettings.getTwoFAPreference();

0 commit comments

Comments
 (0)