-
Notifications
You must be signed in to change notification settings - Fork 32
🎨 Adds client session ID to ProjectDocument + Leave Project Room
#8176
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
matusdrobuliak66
merged 14 commits into
ITISFoundation:master
from
matusdrobuliak66:is1647/collaboration-features-2
Jul 30, 2025
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b2d3396
Adds client session ID propagation for user actions
matusdrobuliak66 92cb19f
Merge branch 'master' into is1647/collaboration-features-2
matusdrobuliak66 8c5b95d
Removes unused frontend outputs update logic
matusdrobuliak66 a68c91e
fix tests
matusdrobuliak66 4d3d978
Refactors project document update for clarity and atomicity
matusdrobuliak66 503ef0f
fix tests
matusdrobuliak66 f58843c
Merge branch 'master' into is1647/collaboration-features-2
matusdrobuliak66 ae5be6f
review @sanderegg
matusdrobuliak66 0d5a6c3
review @sanderegg @pcrespov
matusdrobuliak66 89a9394
review @pcrespov
matusdrobuliak66 ac80fed
fix
matusdrobuliak66 26ac23b
fix
matusdrobuliak66 0b8c698
fix
matusdrobuliak66 e4b4a0b
additional tests
matusdrobuliak66 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
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
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
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
83 changes: 83 additions & 0 deletions
83
services/web/server/src/simcore_service_webserver/projects/_project_document_utils.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,83 @@ | ||
| """Utility functions for project document management. | ||
matusdrobuliak66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| This module contains common utilities for building and versioning project documents. | ||
| """ | ||
|
|
||
| from typing import cast | ||
|
|
||
| from aiohttp import web | ||
| from models_library.api_schemas_webserver.projects import ProjectDocument | ||
| from models_library.projects import ProjectID, ProjectTemplateType | ||
| from models_library.projects import ProjectType as ProjectTypeAPI | ||
| from servicelib.redis import ( | ||
| PROJECT_DB_UPDATE_REDIS_LOCK_KEY, | ||
| exclusive, | ||
| increment_and_return_project_document_version, | ||
| ) | ||
|
|
||
| from ..redis import ( | ||
| get_redis_document_manager_client_sdk, | ||
| get_redis_lock_manager_client_sdk, | ||
| ) | ||
| from . import _projects_repository | ||
matusdrobuliak66 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| async def build_project_document_and_increment_version( | ||
matusdrobuliak66 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| app: web.Application, project_uuid: ProjectID | ||
| ) -> tuple[ProjectDocument, int]: | ||
matusdrobuliak66 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| """Build project document and increment version with Redis lock protection. | ||
| This function is protected by Redis exclusive lock because: | ||
| - the project document and its version must be kept in sync | ||
| Args: | ||
| app: The web application instance | ||
| project_uuid: UUID of the project | ||
| Returns: | ||
| Tuple containing the project document and its version number | ||
| """ | ||
|
|
||
| @exclusive( | ||
| get_redis_lock_manager_client_sdk(app), | ||
| lock_key=PROJECT_DB_UPDATE_REDIS_LOCK_KEY.format(project_uuid), | ||
| blocking=True, | ||
| blocking_timeout=None, # NOTE: this is a blocking call, a timeout has undefined effects | ||
| ) | ||
| async def _build_project_document_and_increment_version() -> ( | ||
| tuple[ProjectDocument, int] | ||
| ): | ||
| """This function is protected because | ||
| - the project document and its version must be kept in sync | ||
| """ | ||
| # Get the full project with workbench for document creation | ||
| project_with_workbench = await _projects_repository.get_project_with_workbench( | ||
| app=app, project_uuid=project_uuid | ||
| ) | ||
| # Create project document | ||
| project_document = ProjectDocument( | ||
| uuid=project_with_workbench.uuid, | ||
| workspace_id=project_with_workbench.workspace_id, | ||
| name=project_with_workbench.name, | ||
| description=project_with_workbench.description, | ||
| thumbnail=project_with_workbench.thumbnail, | ||
| last_change_date=project_with_workbench.last_change_date, | ||
| classifiers=project_with_workbench.classifiers, | ||
| dev=project_with_workbench.dev, | ||
| quality=project_with_workbench.quality, | ||
| workbench=project_with_workbench.workbench, | ||
| ui=project_with_workbench.ui, | ||
| type=cast(ProjectTypeAPI, project_with_workbench.type), | ||
| template_type=cast( | ||
| ProjectTemplateType, project_with_workbench.template_type | ||
| ), | ||
| ) | ||
| # Increment document version | ||
| redis_client_sdk = get_redis_document_manager_client_sdk(app) | ||
| document_version = await increment_and_return_project_document_version( | ||
| redis_client=redis_client_sdk, project_uuid=project_uuid | ||
| ) | ||
|
|
||
| return project_document, document_version | ||
|
|
||
| return await _build_project_document_and_increment_version() | ||
Oops, something went wrong.
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.