Skip to content
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

Feature/async support on pi run #1161

Merged
merged 7 commits into from
Mar 5, 2024
Merged

Conversation

jasquat
Copy link
Contributor

@jasquat jasquat commented Mar 4, 2024

This adds the ability to pass an execution_mode query param into the api calls for task_submit and process_instance_run.

API calls:

  • /tasks/{process_instance_id}/{task_guid} [PUT]
  • /process-instances/{modified_process_model_identifier}/{process_instance_id}/run [POST]

Valid options are:

  • synchronous
  • asynchronous
  • null (the execution_mode query param can be omitted)

Summary by CodeRabbit

  • New Features
    • Added an execution_mode query parameter to API endpoints for process instances and tasks, allowing users to specify "synchronous" or "asynchronous" execution modes.
  • Refactor
    • Updated various backend components to support the new execution_mode parameter, enhancing control over task and process instance execution.
  • Documentation
    • Added comments and documentation related to the new execution modes and backend configurations.

Copy link
Contributor

coderabbitai bot commented Mar 4, 2024

Walkthrough

Walkthrough

The recent updates enhance the system by introducing an execution_mode parameter, offering the flexibility to execute process instances and tasks in either synchronous or asynchronous mode. This change impacts various components such as API endpoints, backend processing, and service logic. A new enum class is integrated to differentiate between execution modes, alongside configuration adjustments and method refactoring to seamlessly support the new parameter.

Changes

File Path Change Summary
.../api.yml Added execution_mode query parameter for process instances and tasks API endpoints.
.../background_processing/celery_tasks/process_instance_task_producer.py
.../routes/process_instances_controller.py
.../routes/tasks_controller.py
.../services/process_instance_service.py
Introduced execution_mode parameter handling in functions related to process instance and task processing.
.../helpers/spiff_enum.py Added ProcessInstanceExecutionMode enum with asynchronous and synchronous values.
.../services/process_instance_processor.py Configured KKVDataStore and TypeaheadDataStore in SPIFF_CONFIG; added a comment about circular imports.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 8

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between 1167187 and dbc9aac.
Files selected for processing (7)
  • spiffworkflow-backend/src/spiffworkflow_backend/api.yml (2 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/background_processing/celery_tasks/process_instance_task_producer.py (2 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/helpers/spiff_enum.py (1 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py (4 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py (3 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py (1 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_service.py (4 hunks)
Additional comments: 7
spiffworkflow-backend/src/spiffworkflow_backend/helpers/spiff_enum.py (1)
  • 10-12: The addition of the ProcessInstanceExecutionMode enum class is correctly implemented and follows Python's enum conventions. This will facilitate clear differentiation between execution modes in the system.
spiffworkflow-backend/src/spiffworkflow_backend/background_processing/celery_tasks/process_instance_task_producer.py (1)
  • 40-52: The modifications to handle different execution_mode values in queue_process_instance_if_appropriate are well-implemented, ensuring that asynchronous execution is only attempted when Celery is enabled. This is crucial for maintaining system integrity and providing clear error messages to users.

Consider adding a brief comment above the check for execution_mode == ProcessInstanceExecutionMode.asynchronous.value explaining why this check is necessary, for future maintainability.

spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py (2)
  • 79-79: The introduction of the execution_mode parameter in the process_instance_run function aligns with the PR's objective to support asynchronous execution. Ensure that the handling of this parameter is thoroughly tested, especially in scenarios where the execution mode impacts the process instance's behavior.
  • 658-672: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [650-669]

The handling of the execution_mode parameter in the _process_instance_run function is well-implemented, with logic to adjust the execution strategy based on the specified mode. Consider adding explicit error handling for invalid execution_mode values to improve robustness. Ensure comprehensive testing, especially for edge cases and error scenarios.

spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py (3)
  • 563-563: The delegation of task submission logic to _task_submit_shared with the inclusion of the execution_mode parameter is a good practice, promoting code reuse and maintainability. This change aligns with the PR's objective to introduce asynchronous execution support.
  • 879-879: The _task_submit_shared function now accepts the execution_mode parameter, which is crucial for handling the task submission based on the execution mode specified. It's important to ensure that the logic within this function correctly handles both synchronous and asynchronous modes as intended.

Verify that the downstream logic within _task_submit_shared, especially in the ProcessInstanceService.complete_form_task call, properly utilizes the execution_mode parameter to differentiate between synchronous and asynchronous task execution.

  • 930-930: The execution_mode parameter is passed to the ProcessInstanceService.complete_form_task method. This is a critical integration point for the asynchronous execution feature. It's essential to ensure that the complete_form_task method is updated to handle this parameter appropriately, managing task completion based on the specified execution mode.

Confirm that the ProcessInstanceService.complete_form_task method has been updated to support the execution_mode parameter, effectively handling both synchronous and asynchronous execution modes.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: .coderabbit.yaml

Commits Files that changed from the base of the PR and between dbc9aac and 057b0f1.
Files selected for processing (2)
  • spiffworkflow-backend/src/spiffworkflow_backend/api.yml (2 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/background_processing/celery_tasks/process_instance_task_producer.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • spiffworkflow-backend/src/spiffworkflow_backend/api.yml
Additional comments: 1
spiffworkflow-backend/src/spiffworkflow_backend/background_processing/celery_tasks/process_instance_task_producer.py (1)
  • 7-8: The import statements for ApiError and ProcessInstanceExecutionMode have been added to support the new functionality related to asynchronous execution. These changes are necessary for the implementation of the new feature and do not introduce any issues.

@burnettk burnettk merged commit 2be7db7 into main Mar 5, 2024
23 checks passed
@burnettk burnettk deleted the feature/async-support-on-pi-run branch March 5, 2024 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants