Skip to content

Commit ee2070b

Browse files
🎨 Exclude Conversations Annotation UI info when copying projects (#8029)
1 parent 61a124a commit ee2070b

File tree

5 files changed

+151
-5
lines changed

5 files changed

+151
-5
lines changed

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

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class SlideshowUI(TypedDict):
4040

4141

4242
class AnnotationUI(BaseModel):
43-
type: Literal["note", "rect", "text"]
44-
color: Annotated[Color, PlainSerializer(Color.as_hex)]
43+
type: Literal["note", "rect", "text", "conversation"]
44+
color: Annotated[Color | None, PlainSerializer(Color.as_hex)] = None
4545
attributes: Annotated[dict, Field(description="svg attributes")]
4646

4747
@staticmethod
@@ -71,6 +71,15 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
7171
"color": "#0000FF",
7272
"attributes": {"x": 415, "y": 100, "text": "Hey!"},
7373
},
74+
{
75+
"type": "conversation",
76+
"attributes": {
77+
"conversationId": 2,
78+
"x": 415,
79+
"y": 100,
80+
"title": "My chat",
81+
},
82+
},
7483
]
7584
},
7685
)
@@ -169,6 +178,15 @@ def _update_json_schema_extra(schema: JsonDict) -> None:
169178
"fontSize": 12,
170179
},
171180
},
181+
"cf94f068-259c-4192-89f9-b2a56d51249d": {
182+
"type": "conversation",
183+
"attributes": {
184+
"conversationId": 2,
185+
"x": 119,
186+
"y": 223,
187+
"title": "My chat",
188+
},
189+
},
172190
},
173191
"current_node_id": "4b3345e5-861f-47b0-8b52-a4508449be79",
174192
"template_type": "hypertool",

services/web/server/src/simcore_service_webserver/api/v0/openapi.yaml

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8458,18 +8458,44 @@ components:
84588458
- stats
84598459
- limits
84608460
title: Activity
8461-
AnnotationUI:
8461+
AnnotationUI-Input:
84628462
properties:
84638463
type:
84648464
type: string
84658465
enum:
84668466
- note
84678467
- rect
84688468
- text
8469+
- conversation
8470+
title: Type
8471+
color:
8472+
anyOf:
8473+
- type: string
8474+
format: color
8475+
- type: 'null'
8476+
title: Color
8477+
attributes:
8478+
type: object
8479+
title: Attributes
8480+
description: svg attributes
8481+
additionalProperties: false
8482+
type: object
8483+
required:
8484+
- type
8485+
- attributes
8486+
title: AnnotationUI
8487+
AnnotationUI-Output:
8488+
properties:
8489+
type:
8490+
type: string
8491+
enum:
8492+
- note
8493+
- rect
8494+
- text
8495+
- conversation
84698496
title: Type
84708497
color:
84718498
type: string
8472-
format: color
84738499
title: Color
84748500
attributes:
84758501
type: object
@@ -8479,7 +8505,6 @@ components:
84798505
type: object
84808506
required:
84818507
- type
8482-
- color
84838508
- attributes
84848509
title: AnnotationUI
84858510
Announcement:

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ def _replace_uuids(node: str | list | dict) -> str | list | dict:
9393
project_copy["ui"].get("slideshow", {})
9494
)
9595

96+
# exclude annotations UI info for conversations done in the source project
97+
annotations = project_copy.get("ui", {}).get("annotations", {}).copy()
98+
for ann_id, ann in annotations.items():
99+
if ann["type"] == "conversation":
100+
project_copy["ui"]["annotations"].pop(ann_id)
101+
96102
if clean_output_data:
97103
for node_data in project_copy.get("workbench", {}).values():
98104
for field in _FIELDS_TO_DELETE:
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{
2+
"accessRights": {},
3+
"uuid": "de2578c5-431e-6257-a462-d7bf73b76c0c",
4+
"name": "fake-project-name",
5+
"description": "anim sint pariatur do dolore",
6+
"prjOwner": "[email protected]",
7+
"creationDate": "1865-11-30T04:00:14.000Z",
8+
"lastChangeDate": "7364-11-30T10:04:52.000Z",
9+
"thumbnail": "https://some_fake_project_thumbnail.com/fake",
10+
"tags": [],
11+
"classifiers": [],
12+
"workbench": {
13+
"b4b20476-e7c0-47c2-8cc4-f66ac21a13bf": {
14+
"key": "simcore/services/frontend/file-picker",
15+
"version": "1.0.0",
16+
"label": "File Picker 0D",
17+
"inputs": {},
18+
"inputNodes": [],
19+
"outputs": {},
20+
"position": {
21+
"x": 50,
22+
"y": 150
23+
}
24+
},
25+
"5739e377-17f7-4f09-a6ad-62659fb7fdec": {
26+
"key": "simcore/services/comp/ucdavis-singlecell-cardiac-model",
27+
"version": "1.0.0",
28+
"label": "DBP-Clancy-Rabbit-Single-Cell solver",
29+
"inputAccess": {
30+
"Na": "ReadAndWrite",
31+
"Kr": "ReadOnly",
32+
"BCL": "ReadAndWrite",
33+
"NBeats": "ReadOnly",
34+
"Ligand": "Invisible",
35+
"cAMKII": "Invisible"
36+
},
37+
"inputs": {
38+
"Na": 0,
39+
"Kr": 0,
40+
"BCL": 200,
41+
"NBeats": 5,
42+
"Ligand": 0,
43+
"cAMKII": "WT",
44+
"initfile": {
45+
"nodeUuid": "b4b20476-e7c0-47c2-8cc4-f66ac21a13bf",
46+
"output": "outFile"
47+
}
48+
},
49+
"inputNodes": [
50+
"b4b20476-e7c0-47c2-8cc4-f66ac21a13bf"
51+
],
52+
"outputs": {},
53+
"position": {
54+
"x": 300,
55+
"y": 150
56+
}
57+
},
58+
"351fd505-1ee3-466d-ad6c-ea2915ffd364": {
59+
"key": "simcore/services/dynamic/raw-graphs",
60+
"version": "2.10.4",
61+
"label": "2D plot",
62+
"inputs": {},
63+
"outputs": {},
64+
"position": {
65+
"x": 1073,
66+
"y": 307
67+
},
68+
"progress": 100
69+
}
70+
},
71+
"ui": {
72+
"annotations": {
73+
"b8a7e8e2-1c2d-4f3a-9c5e-123456789abc": {
74+
"type": "conversation",
75+
"attributes": {
76+
"conversationId": 2,
77+
"x": 415,
78+
"y": 100,
79+
"title": "My chat"
80+
}
81+
}
82+
}
83+
},
84+
"quality": {},
85+
"dev": {},
86+
"workspaceId": null,
87+
"type": "STANDARD",
88+
"templateType": null
89+
}

services/web/server/tests/unit/isolated/test_projects_utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"test_data_file_name",
2323
[
2424
"fake-project.json",
25+
"fake-project-with-conversation.json",
2526
"fake-template-projects.hack08.notebooks.json",
2627
"fake-template-projects.isan.2dplot.json",
2728
"fake-template-projects.isan.matward.json",
@@ -51,6 +52,13 @@ def test_clone_project_document(
5152
for clone_node_id in clone["workbench"]:
5253
assert clone_node_id not in node_ids
5354

55+
# checks no conversation have been copied
56+
if "ui" in clone and "annotations" in clone["ui"]:
57+
assert not any(
58+
annotation["type"] == "conversation"
59+
for annotation in clone["ui"]["annotations"].values()
60+
)
61+
5462
# Here we do not use anymore jsonschema.validator since ...
5563
#
5664
# "OpenAPI 3.0 does not have an explicit null type as in JSON Schema, but you can use nullable:

0 commit comments

Comments
 (0)