-
Couldn't load subscription status.
- Fork 32
🎨 Allows guest users to run a project form a template with outputs pushing enabled 🗃️ #8555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GitHK
merged 20 commits into
ITISFoundation:master
from
GitHK:pr-osparc-overwite-can-save-templates
Oct 27, 2025
Merged
Changes from 13 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f75b69a
added code in postgres
1b9ebdd
refactoed
b5cc9e8
rename
f5d29fe
refactored
2184e6a
guests can save ports and state
7eb489a
fixed feature working as expected
36115e1
typo
952afa4
Merge remote-tracking branch 'upstream/master' into pr-osparc-overwit…
e49f75f
mypy
b2fdef8
Merge branch 'master' into pr-osparc-overwite-can-save-templates
GitHK 5f93549
correct one
d86bde0
massive renaming
2442e60
Merge remote-tracking branch 'upstream/master' into pr-osparc-overwit…
54b0bf1
GC no longer saves for GUEST
1c7cdce
renamed
91da37d
Merge remote-tracking branch 'upstream/master' into pr-osparc-overwit…
69901dd
refactor
f92a9fd
unify functions
8be4c42
removed unused
c84793a
refacotred moved aorund modules
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
.../src/simcore_postgres_database/migration/versions/a85557c02d71_add_projects_extentions.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| """add_projects_extentions | ||
| Revision ID: a85557c02d71 | ||
| Revises: 5756d9282a0a | ||
| Create Date: 2025-10-24 15:03:32.846288+00:00 | ||
| """ | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "a85557c02d71" | ||
| down_revision = "5756d9282a0a" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.create_table( | ||
| "projects_extentions", | ||
| sa.Column("project_uuid", sa.String(), nullable=False), | ||
| sa.Column( | ||
| "allow_guests_to_push_states_and_output_ports", | ||
| sa.Boolean(), | ||
| server_default=sa.text("false"), | ||
| nullable=False, | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["project_uuid"], | ||
| ["projects.uuid"], | ||
| name="fk_projects_extentions_project_uuid_projects", | ||
| onupdate="CASCADE", | ||
| ondelete="CASCADE", | ||
| ), | ||
| sa.PrimaryKeyConstraint("project_uuid"), | ||
| ) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_table("projects_extentions") | ||
| # ### end Alembic commands ### | ||
32 changes: 32 additions & 0 deletions
32
packages/postgres-database/src/simcore_postgres_database/models/projects_extentions.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import sqlalchemy as sa | ||
|
|
||
| from ._common import RefActions | ||
| from .base import metadata | ||
| from .projects import projects | ||
|
|
||
| projects_extentions = sa.Table( | ||
| "projects_extentions", | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| metadata, | ||
| sa.Column( | ||
| "project_uuid", | ||
| sa.String, | ||
| sa.ForeignKey( | ||
| projects.c.uuid, | ||
| name="fk_projects_extentions_project_uuid_projects", | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ondelete=RefActions.CASCADE, | ||
| onupdate=RefActions.CASCADE, | ||
| ), | ||
| primary_key=True, | ||
| doc="project reference and primary key for this table", | ||
| ), | ||
| sa.Column( | ||
| "allow_guests_to_push_states_and_output_ports", | ||
| sa.Boolean(), | ||
| nullable=False, | ||
| server_default=sa.sql.expression.false(), | ||
| doc=( | ||
| "When True, guest will save the state of a service " | ||
| "and also push the data to the output ports" | ||
| ), | ||
| ), | ||
| ) | ||
39 changes: 39 additions & 0 deletions
39
packages/postgres-database/src/simcore_postgres_database/utils_projects_extentions.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import sqlalchemy as sa | ||
| from simcore_postgres_database.utils_repos import ( | ||
| pass_or_acquire_connection, | ||
| transaction_context, | ||
| ) | ||
| from sqlalchemy.ext.asyncio import AsyncEngine | ||
|
|
||
| from .models.projects_extentions import projects_extentions | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| class CouldNotCreateOrUpdateUserPreferenceError(Exception): ... | ||
|
|
||
|
|
||
| class ProjectsExtensionsRepo: | ||
| model: sa.Table = projects_extentions | ||
|
|
||
| @classmethod | ||
| async def allows_guests_to_push_states_and_output_ports( | ||
| cls, async_engine: AsyncEngine, *, project_uuid: str | ||
| ) -> bool: | ||
| async with pass_or_acquire_connection(async_engine) as connection: | ||
| result: bool | None = await connection.scalar( | ||
| sa.select( | ||
| cls.model.c.allow_guests_to_push_states_and_output_ports | ||
| ).where(cls.model.c.project_uuid == project_uuid) | ||
| ) | ||
| return result if result is not None else False | ||
|
|
||
| @classmethod | ||
| async def set_allow_guests_to_push_states_and_output_ports( | ||
| cls, async_engine: AsyncEngine, *, project_uuid: str | ||
| ) -> None: | ||
| async with transaction_context(async_engine) as connection: | ||
| await connection.execute( | ||
| sa.insert(projects_extentions).values( | ||
| project_uuid=project_uuid, | ||
| allow_guests_to_push_states_and_output_ports=True, | ||
| ) | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ) | ||
59 changes: 59 additions & 0 deletions
59
packages/postgres-database/tests/test_utils_projects_extentions.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # pylint: disable=redefined-outer-name | ||
|
|
||
| from collections.abc import Awaitable, Callable | ||
|
|
||
| import pytest | ||
| from aiopg.sa.connection import SAConnection | ||
| from aiopg.sa.result import RowProxy | ||
| from simcore_postgres_database.utils_projects_extentions import ProjectsExtensionsRepo | ||
| from sqlalchemy.ext.asyncio import AsyncEngine | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def fake_user( | ||
| connection: SAConnection, | ||
| create_fake_user: Callable[..., Awaitable[RowProxy]], | ||
| ) -> RowProxy: | ||
| user: RowProxy = await create_fake_user(connection, name=f"user.{__name__}") | ||
| return user | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| async def fake_project( | ||
| connection: SAConnection, | ||
| fake_user: RowProxy, | ||
| create_fake_project: Callable[..., Awaitable[RowProxy]], | ||
| create_fake_nodes: Callable[..., Awaitable[RowProxy]], | ||
| ) -> RowProxy: | ||
| project: RowProxy = await create_fake_project(connection, fake_user, hidden=True) | ||
| await create_fake_nodes(project) | ||
| return project | ||
|
|
||
|
|
||
| async def test_workflow( | ||
| asyncpg_engine: AsyncEngine, | ||
| connection: SAConnection, | ||
| create_fake_user: Callable[..., Awaitable[RowProxy]], | ||
| create_fake_project: Callable[..., Awaitable[RowProxy]], | ||
| ): | ||
| user: RowProxy = await create_fake_user(connection) | ||
| project: RowProxy = await create_fake_project(connection, user, hidden=True) | ||
|
|
||
| assert ( | ||
| await ProjectsExtensionsRepo.allows_guests_to_push_states_and_output_ports( | ||
| asyncpg_engine, project_uuid=project["uuid"] | ||
| ) | ||
| is False | ||
| ) | ||
|
|
||
| # add the entry in the table | ||
| await ProjectsExtensionsRepo.set_allow_guests_to_push_states_and_output_ports( | ||
| asyncpg_engine, project_uuid=project["uuid"] | ||
| ) | ||
|
|
||
| assert ( | ||
| await ProjectsExtensionsRepo.allows_guests_to_push_states_and_output_ports( | ||
| asyncpg_engine, project_uuid=project["uuid"] | ||
| ) | ||
| is True | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.