Repository navigation
Initial Workflow Shared-editing Implementation - #1392
Conversation
|
Group discussion 1/11: We'll create a github project to keep track of all PRs related to workflow collaboration changes |
zuozhiw
left a comment
There was a problem hiding this comment.
Left a few comments, please address them and I'll have another round of review.
|
@Xiao-zhen-Liu can you please modify the PR title and description? since the old PR you are referring to was never merged. we should still treat this PR as a new feature. it's better to describe its functionality, logic, and limitations. and you can give credit to the old PR by referring to it. |
|
@zuozhiw All the requested changes are addressed, some are to be made in the next PR. |
# Conflicts: # core/new-gui/src/app/workspace/service/undo-redo/undo-redo.service.ts
|
@Yicong-Huang I made all the changes per your requests, but I left few refactoring out because they involve other files not related to this PR which can be done later. Please check these changes. |
Yicong-Huang
left a comment
There was a problem hiding this comment.
The changes looks good to me. Please change the print to logger. After that we can merge this PR.
## Introduction This PR does several things, among which the key is introducing workflow-level locking and integration with user system to shared editing. #1392 only migrates #758 to our current codebase, but did not consider user system so any change from any client will be propagated to all other clients. This PR fixes this and ensures only workflows of the same id can propagate changes to each other. On top of that, this PR introduces a locking mechanism on the workflow graph so that at the same time only one client can "write" the frontend workflow graph and propagate changes to others. Other changes include redesigning the collab websocket messages to support more operations, and some refactoring work requested in #1392. ## Demos All the changes require `workflowCollabEnabled` in the environment to be true, otherwise the frontend behavior will not be affected. (Except one place - when `workflowModificationEnabled` is set to false, operator dragging will also be disabled, previously we allow it to be enabled. I'm not introducing another level of "disableModification" here for simplicity, but this is doable.) - Depending on `wId`, only sessions on the same workflow will have "collaboration" and "lock", so this images shows two different workflows will both have write access (indicated by a newly added button). <img width="1392" alt="image" src="https://user-images.githubusercontent.com/36582710/152084809-b9f15e67-cdd2-47c5-80b8-44018cce78bb.png"> - When more than two sessions are both on the same workflow, only one will have write privilege, all other session will see the button as "Readonly mode - click to request write access". - For now, to simplify matters and prevent deadlock, whichever session that clicks the button will get the lock, shown in the below gif:  - When a lock-holding session closes, the server will give the lock to other sessions still open, in particular, the first session in server's list. - I also implemented a simple function to allow a session to notify other sessions to reload the workflow, and in particular this is what will happen when a particular workflow version is loaded, so reverting version will be propagated. ## Limitations 1. For now only changes on the workflow graph will be propagated (and locked). Other elements, like workflow name, PythonUDF's "edit code" button, "Run" button, etc., cannot be **locked** or changed with `CommandMessages` (but PythonUDF's code changes can indeed be propagated), so will not be affected. 2. Enabling/Disabling operators will not be locked/propagated because somehow this is not included in `WorkflowActionService`, but directly in `WorkflowGraph`. 3. Since undo/redo stacks are local to each session, potential issues might arise. ## Code Explanation ### Collab WebSocket requests/events The "lock" is really a value in the server (see `wIdLockHolderIdMap`). I redesigned WebSocket messages to incorporate functionalities needed in this PR. In particular, I mostly followed `WorkflowWebSocket`, and below are the Request/Events added here: - `CommandRequest`: sent by lock-holding session to notify the server and propagate commands (changes) to other target sessions. - `CommandEvent`: Server sends commands to target sessions. - `WIdRequest`: similar to `WorkflowWebSocket`'s `RegisterWIdRequest`, but instead of registering, this just tells the server a sessions `wId`. - `TryLockRequest`: When a session first opens it sends this request to see if the lock is already held by this session, or if there are no other sessions of the same `wId`, and can be subsequently granted lock. - `AcquireLockRequest`: When the new button is clicked this request will be sent. - `LockGrantedEvent`: Server grants the lock. - `ReleaseLockEvent`: Server asks lock holder to give up the lock. - `LockRejectedEvent`: Response to `TryLockRequest` when the sender session is not the lock holder. - `RestoreVersionRequest` and `RestoreVersionEvent`: similar to `CommandRequest` and `CommandEvent`, but instead this pair simply propagates workflow reloading. - `WorkflowAccessEvent`: Server tells client whether the workflow is readonly (shared by others with read access). ### Refactoring For `WorkflowActionService`, 1. Types related to `command` and `commandMessage` are extracted. 2. Sending `commandMessage` is merged into `executeAndStoreCommand`. Other potentially confusing codes, especially those related in `WorkflowCollabService`, are documented. Co-authored-by: kerryqliu <[email protected]> Co-authored-by: zuozhiw <[email protected]>
* Added workflow collab service * Update other services and package.json * Additional changes * Added websocket to texera backend, and other changes to collab service * More changes to workflow collab * Clean up comments * More bug fixes and changed tests for initial attempt * Bug fix for save workflow service * Typo fix * Added missing command messages * Communicate link add between clients * Add commandMessage to more actions * Deleted frontend test * ESLint * Fix ESLint * Code cleanup * Code cleanup * Add changes to undo-redo * Taken care of minor issues. * Disable collab by default for now. * Disable collab by default for now. * Revert usersystem default * Minor changes per requests. * Add TODO and logging, change code to scala. * Revert change to proxy.config.json * Create URL util Co-authored-by: kerryqliu <[email protected]> Co-authored-by: zuozhiw <[email protected]>
) ## Introduction This PR does several things, among which the key is introducing workflow-level locking and integration with user system to shared editing. apache#1392 only migrates apache#758 to our current codebase, but did not consider user system so any change from any client will be propagated to all other clients. This PR fixes this and ensures only workflows of the same id can propagate changes to each other. On top of that, this PR introduces a locking mechanism on the workflow graph so that at the same time only one client can "write" the frontend workflow graph and propagate changes to others. Other changes include redesigning the collab websocket messages to support more operations, and some refactoring work requested in apache#1392. ## Demos All the changes require `workflowCollabEnabled` in the environment to be true, otherwise the frontend behavior will not be affected. (Except one place - when `workflowModificationEnabled` is set to false, operator dragging will also be disabled, previously we allow it to be enabled. I'm not introducing another level of "disableModification" here for simplicity, but this is doable.) - Depending on `wId`, only sessions on the same workflow will have "collaboration" and "lock", so this images shows two different workflows will both have write access (indicated by a newly added button). <img width="1392" alt="image" src="https://user-images.githubusercontent.com/36582710/152084809-b9f15e67-cdd2-47c5-80b8-44018cce78bb.png"> - When more than two sessions are both on the same workflow, only one will have write privilege, all other session will see the button as "Readonly mode - click to request write access". - For now, to simplify matters and prevent deadlock, whichever session that clicks the button will get the lock, shown in the below gif:  - When a lock-holding session closes, the server will give the lock to other sessions still open, in particular, the first session in server's list. - I also implemented a simple function to allow a session to notify other sessions to reload the workflow, and in particular this is what will happen when a particular workflow version is loaded, so reverting version will be propagated. ## Limitations 1. For now only changes on the workflow graph will be propagated (and locked). Other elements, like workflow name, PythonUDF's "edit code" button, "Run" button, etc., cannot be **locked** or changed with `CommandMessages` (but PythonUDF's code changes can indeed be propagated), so will not be affected. 2. Enabling/Disabling operators will not be locked/propagated because somehow this is not included in `WorkflowActionService`, but directly in `WorkflowGraph`. 3. Since undo/redo stacks are local to each session, potential issues might arise. ## Code Explanation ### Collab WebSocket requests/events The "lock" is really a value in the server (see `wIdLockHolderIdMap`). I redesigned WebSocket messages to incorporate functionalities needed in this PR. In particular, I mostly followed `WorkflowWebSocket`, and below are the Request/Events added here: - `CommandRequest`: sent by lock-holding session to notify the server and propagate commands (changes) to other target sessions. - `CommandEvent`: Server sends commands to target sessions. - `WIdRequest`: similar to `WorkflowWebSocket`'s `RegisterWIdRequest`, but instead of registering, this just tells the server a sessions `wId`. - `TryLockRequest`: When a session first opens it sends this request to see if the lock is already held by this session, or if there are no other sessions of the same `wId`, and can be subsequently granted lock. - `AcquireLockRequest`: When the new button is clicked this request will be sent. - `LockGrantedEvent`: Server grants the lock. - `ReleaseLockEvent`: Server asks lock holder to give up the lock. - `LockRejectedEvent`: Response to `TryLockRequest` when the sender session is not the lock holder. - `RestoreVersionRequest` and `RestoreVersionEvent`: similar to `CommandRequest` and `CommandEvent`, but instead this pair simply propagates workflow reloading. - `WorkflowAccessEvent`: Server tells client whether the workflow is readonly (shared by others with read access). ### Refactoring For `WorkflowActionService`, 1. Types related to `command` and `commandMessage` are extracted. 2. Sending `commandMessage` is merged into `executeAndStoreCommand`. Other potentially confusing codes, especially those related in `WorkflowCollabService`, are documented. Co-authored-by: kerryqliu <[email protected]> Co-authored-by: zuozhiw <[email protected]>
This PR updates #758 to the latest codebase. Some descriptions are copied here.
Introduction
This pull request includes an initial shared-editing implementation for being able to send commands between multiple clients. The gif above gives a brief demonstration behind how it looks, with each individual command being sent as soon as it's performed. Sending commands ensures that the workflows get synced between different clients after each action performed by different clients. This is still a naive implementation and leaves some concerns that need to be addressed.
Below is a demo:

Main file changes and implementation overview
CollaborationResource.javaLocated at web/src/main/java/edu/uci/ics/texera/web/resource/CollaborationResource.java. This is the websocket used to communicate between the different clients, with a command being sent to all other clients currently connected to the websocket.
workflow-action.service.tsEarlier, we had added the Command interface for undo/redo. Unfortunately, that interface kept track of each action as a set of functions, which we can't send between clients. We instead implemented the new CommandMessage interface which keeps track of an action's name, the parameters for that action, and the type for that action(e.g. normal action, undo, or redo). All of these things are able to be communicated between clients. Now, in addition to just performing the action on that client, we'll construct a command message after performing each action that we can send. An example looks like the following(this refers to WorkflowActionService):
workflow-collab.service.tsThis service is where the websocket connection gets established with the resource described above. It'll listen to the websocket and push new messages into a stream, notifying other services to perform the actions.
Minor changes were made in a handful of other files to make sure they interacted properly with the new features. Additionally, A parameter to currently disable the feature is added since it is still a work in progress, and is disabled by default so that its issues will not affect current system.
Changes from the old PR
resetAsNewWorkflowandautoLayoutWorkflow.Issues and next steps