Skip to content

Commit f769929

Browse files
Merge remote-tracking branch 'upstream/master' into add-notifications-service
2 parents efd3900 + 1fd4927 commit f769929

File tree

38 files changed

+1018
-259
lines changed

38 files changed

+1018
-259
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",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
"""Make func api access non-nullable
2+
3+
Revision ID: d159ac30983c
4+
Revises: 4f6fd2586491
5+
Create Date: 2025-07-01 08:50:29.095068+00:00
6+
7+
"""
8+
9+
import sqlalchemy as sa
10+
from alembic import op
11+
12+
# revision identifiers, used by Alembic.
13+
revision = "d159ac30983c"
14+
down_revision = "4f6fd2586491"
15+
branch_labels = None
16+
depends_on = None
17+
18+
19+
def upgrade():
20+
# ### commands auto generated by Alembic - please adjust! ###
21+
op.execute(
22+
"""
23+
UPDATE funcapi_group_api_access_rights
24+
SET read_functions = false
25+
WHERE read_functions IS NULL
26+
"""
27+
)
28+
op.execute(
29+
"""
30+
UPDATE funcapi_group_api_access_rights
31+
SET write_functions = false
32+
WHERE write_functions IS NULL
33+
"""
34+
)
35+
op.execute(
36+
"""
37+
UPDATE funcapi_group_api_access_rights
38+
SET execute_functions = false
39+
WHERE execute_functions IS NULL
40+
"""
41+
)
42+
op.execute(
43+
"""
44+
UPDATE funcapi_group_api_access_rights
45+
SET read_function_jobs = false
46+
WHERE read_function_jobs IS NULL
47+
"""
48+
)
49+
op.execute(
50+
"""
51+
UPDATE funcapi_group_api_access_rights
52+
SET write_function_jobs = false
53+
WHERE write_function_jobs IS NULL
54+
"""
55+
)
56+
op.execute(
57+
"""
58+
UPDATE funcapi_group_api_access_rights
59+
SET execute_function_jobs = false
60+
WHERE execute_function_jobs IS NULL
61+
"""
62+
)
63+
op.execute(
64+
"""
65+
UPDATE funcapi_group_api_access_rights
66+
SET read_function_job_collections = false
67+
WHERE read_function_job_collections IS NULL
68+
"""
69+
)
70+
op.execute(
71+
"""
72+
UPDATE funcapi_group_api_access_rights
73+
SET write_function_job_collections = false
74+
WHERE write_function_job_collections IS NULL
75+
"""
76+
)
77+
op.execute(
78+
"""
79+
UPDATE funcapi_group_api_access_rights
80+
SET execute_function_job_collections = false
81+
WHERE execute_function_job_collections IS NULL
82+
"""
83+
)
84+
op.alter_column(
85+
"funcapi_group_api_access_rights",
86+
"write_functions",
87+
existing_type=sa.BOOLEAN(),
88+
nullable=False,
89+
)
90+
op.alter_column(
91+
"funcapi_group_api_access_rights",
92+
"execute_functions",
93+
existing_type=sa.BOOLEAN(),
94+
nullable=False,
95+
)
96+
op.alter_column(
97+
"funcapi_group_api_access_rights",
98+
"read_function_jobs",
99+
existing_type=sa.BOOLEAN(),
100+
nullable=False,
101+
)
102+
op.alter_column(
103+
"funcapi_group_api_access_rights",
104+
"write_function_jobs",
105+
existing_type=sa.BOOLEAN(),
106+
nullable=False,
107+
)
108+
op.alter_column(
109+
"funcapi_group_api_access_rights",
110+
"execute_function_jobs",
111+
existing_type=sa.BOOLEAN(),
112+
nullable=False,
113+
)
114+
op.alter_column(
115+
"funcapi_group_api_access_rights",
116+
"read_function_job_collections",
117+
existing_type=sa.BOOLEAN(),
118+
nullable=False,
119+
)
120+
op.alter_column(
121+
"funcapi_group_api_access_rights",
122+
"write_function_job_collections",
123+
existing_type=sa.BOOLEAN(),
124+
nullable=False,
125+
)
126+
op.alter_column(
127+
"funcapi_group_api_access_rights",
128+
"execute_function_job_collections",
129+
existing_type=sa.BOOLEAN(),
130+
nullable=False,
131+
)
132+
# ### end Alembic commands ###
133+
134+
135+
def downgrade():
136+
# ### commands auto generated by Alembic - please adjust! ###
137+
op.alter_column(
138+
"funcapi_group_api_access_rights",
139+
"execute_function_job_collections",
140+
existing_type=sa.BOOLEAN(),
141+
nullable=True,
142+
)
143+
op.alter_column(
144+
"funcapi_group_api_access_rights",
145+
"write_function_job_collections",
146+
existing_type=sa.BOOLEAN(),
147+
nullable=True,
148+
)
149+
op.alter_column(
150+
"funcapi_group_api_access_rights",
151+
"read_function_job_collections",
152+
existing_type=sa.BOOLEAN(),
153+
nullable=True,
154+
)
155+
op.alter_column(
156+
"funcapi_group_api_access_rights",
157+
"execute_function_jobs",
158+
existing_type=sa.BOOLEAN(),
159+
nullable=True,
160+
)
161+
op.alter_column(
162+
"funcapi_group_api_access_rights",
163+
"write_function_jobs",
164+
existing_type=sa.BOOLEAN(),
165+
nullable=True,
166+
)
167+
op.alter_column(
168+
"funcapi_group_api_access_rights",
169+
"read_function_jobs",
170+
existing_type=sa.BOOLEAN(),
171+
nullable=True,
172+
)
173+
op.alter_column(
174+
"funcapi_group_api_access_rights",
175+
"execute_functions",
176+
existing_type=sa.BOOLEAN(),
177+
nullable=True,
178+
)
179+
op.alter_column(
180+
"funcapi_group_api_access_rights",
181+
"write_functions",
182+
existing_type=sa.BOOLEAN(),
183+
nullable=True,
184+
)
185+
op.alter_column(
186+
"funcapi_group_api_access_rights",
187+
"read_functions",
188+
existing_type=sa.BOOLEAN(),
189+
nullable=True,
190+
)
191+
# ### end Alembic commands ###

packages/postgres-database/src/simcore_postgres_database/models/funcapi_api_access_rights_table.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,46 +36,55 @@
3636
"read_functions",
3737
sa.Boolean,
3838
default=False,
39+
nullable=False,
3940
),
4041
sa.Column(
4142
"write_functions",
4243
sa.Boolean,
4344
default=False,
45+
nullable=False,
4446
),
4547
sa.Column(
4648
"execute_functions",
4749
sa.Boolean,
4850
default=False,
51+
nullable=False,
4952
),
5053
sa.Column(
5154
"read_function_jobs",
5255
sa.Boolean,
5356
default=False,
57+
nullable=False,
5458
),
5559
sa.Column(
5660
"write_function_jobs",
5761
sa.Boolean,
5862
default=False,
63+
nullable=False,
5964
),
6065
sa.Column(
6166
"execute_function_jobs",
6267
sa.Boolean,
6368
default=False,
69+
nullable=False,
6470
),
6571
sa.Column(
6672
"read_function_job_collections",
6773
sa.Boolean,
6874
default=False,
75+
nullable=False,
6976
),
7077
sa.Column(
7178
"write_function_job_collections",
7279
sa.Boolean,
7380
default=False,
81+
nullable=False,
7482
),
7583
sa.Column(
7684
"execute_function_job_collections",
7785
sa.Boolean,
7886
default=False,
87+
nullable=False,
7988
),
8089
column_created_datetime(),
8190
column_modified_datetime(),

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
from simcore_postgres_database.models.comp_pipeline import StateType, comp_pipeline
1616
from simcore_postgres_database.models.comp_tasks import comp_tasks
1717
from simcore_postgres_database.models.projects import ProjectType, projects
18+
from simcore_postgres_database.models.services import services_access_rights
1819
from simcore_postgres_database.models.users import UserRole, UserStatus, users
1920
from simcore_postgres_database.utils_projects_nodes import (
2021
ProjectNodeCreate,
@@ -183,3 +184,74 @@ def creator(project_id: ProjectID, **task_kwargs) -> dict[str, Any]:
183184
conn.execute(
184185
comp_tasks.delete().where(comp_tasks.c.task_id.in_(created_task_ids))
185186
)
187+
188+
189+
@pytest.fixture
190+
def grant_service_access_rights(
191+
postgres_db: sa.engine.Engine,
192+
) -> Iterator[Callable[..., dict[str, Any]]]:
193+
"""Fixture to grant access rights on a service for a given group.
194+
195+
Creates a row in the services_access_rights table with the provided parameters and cleans up after the test.
196+
"""
197+
created_entries: list[tuple[str, str, int, str]] = []
198+
199+
def creator(
200+
*,
201+
service_key: str,
202+
service_version: str,
203+
group_id: int = 1,
204+
product_name: str = "osparc",
205+
execute_access: bool = True,
206+
write_access: bool = False,
207+
) -> dict[str, Any]:
208+
values = {
209+
"key": service_key,
210+
"version": service_version,
211+
"gid": group_id,
212+
"product_name": product_name,
213+
"execute_access": execute_access,
214+
"write_access": write_access,
215+
}
216+
217+
# Directly use SQLAlchemy to insert and retrieve the row
218+
with postgres_db.begin() as conn:
219+
# Insert the row
220+
conn.execute(services_access_rights.insert().values(**values))
221+
222+
# Retrieve the inserted row
223+
result = conn.execute(
224+
sa.select(services_access_rights).where(
225+
sa.and_(
226+
services_access_rights.c.key == service_key,
227+
services_access_rights.c.version == service_version,
228+
services_access_rights.c.gid == group_id,
229+
services_access_rights.c.product_name == product_name,
230+
)
231+
)
232+
)
233+
row = result.one()
234+
235+
# Track the entry for cleanup
236+
created_entries.append(
237+
(service_key, service_version, group_id, product_name)
238+
)
239+
240+
# Convert row to dict
241+
return dict(row._asdict())
242+
243+
yield creator
244+
245+
# Cleanup all created entries
246+
with postgres_db.begin() as conn:
247+
for key, version, gid, product in created_entries:
248+
conn.execute(
249+
services_access_rights.delete().where(
250+
sa.and_(
251+
services_access_rights.c.key == key,
252+
services_access_rights.c.version == version,
253+
services_access_rights.c.gid == gid,
254+
services_access_rights.c.product_name == product,
255+
)
256+
)
257+
)

0 commit comments

Comments
 (0)