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

Support non task data environment, step 1 #1745

Merged
merged 3 commits into from
Jun 20, 2024
Merged

Conversation

jbirddog
Copy link
Contributor

@jbirddog jbirddog commented Jun 17, 2024

Work on #1567

Starting to bring in some changes from the non_task_data_based_env branch that has been in progress for a while. Main changes are moving CustomScriptEngineEnvironment from a hardcoded choice to a factory method so the script engine environment can be selected at runtime. This allows running tests or deploying with the non task data based environment without code changes. Also added the ability to omit the non task data state when serializing, which is required to get the migrator tests to pass edit: when using the non task data based environment.

Summary by CodeRabbit

  • New Features

    • Added support for environment variables in the development setup with a new env_file configuration.
  • Enhancements

    • Introduced a new configuration option for script engine environments.
    • Improved script engine environment management with new class structures and dynamic creation methods.
  • Bug Fixes

    • Updated test cases to include a new argument for script engine state serialization.
  • Refactor

    • Refactored script engine environment classes for better modularity and maintainability.

Copy link
Contributor

coderabbitai bot commented Jun 17, 2024

Walkthrough

Walkthrough

The recent changes to the spiffworkflow-backend project focus on enhancing environment configuration support, refactoring script engine management, and updating test cases. Key updates include adding .env file handling in Docker for development, introducing flexible script engine environments, and refining method invocations for environment creation. These modifications aim to increase configuration flexibility, code maintainability, and streamline testing procedures.

Changes

File Path Change Summary
spiffworkflow-backend/dev.docker-compose.yml Added env_file to the services section, enabling optional use of environment variables from a .env file.
spiffworkflow-backend/src/spiffworkflow_backend/config/default.py Introduced SPIFFWORKFLOW_BACKEND_USE_NON_TASK_DATA_BASED_SCRIPT_ENGINE_ENVIRONMENT configuration option, defaulting to False.
spiffworkflow-backend/src/.../process_instance_processor.py Refactored script engine environments: split TaskDataBasedScriptEngineEnvironment into BaseCustomScriptEngineEnvironment and NonTaskDataBasedScriptEngineEnvironment. Added a new dynamic environment creation method with CustomScriptEngineEnvironment.
spiffworkflow-backend/src/.../process_model_test_runner_service.py Modified initialization to use CustomScriptEngineEnvironment.create for environment instantiation.
spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py Removed PYTHON_ENVIRONMENT_STATE_KEY constant from the TaskService class.
spiffworkflow-backend/tests/.../test_process_instance_migrator.py Updated test cases by adding serialize_script_engine_state argument to serialize method calls.

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 testing code 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 testing code 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 testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @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.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 2

Outside diff range and nitpick comments (2)
spiffworkflow-backend/src/spiffworkflow_backend/config/default.py (1)

Line range hint 150-150: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

Consider storing sensitive keys in environment variables or secure vaults to prevent potential security risks.

spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py (1)

Line range hint 211-274: The NonTaskDataBasedScriptEngineEnvironment class has been introduced to handle environments without task data. The implementation of execute and evaluate methods needs careful review to ensure they handle the script execution context correctly.

Consider adding more robust error handling and validation in the execute and evaluate methods to prevent potential security issues with eval and exec.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 57fe7cf and 9881559.

Files selected for processing (6)
  • spiffworkflow-backend/dev.docker-compose.yml (1 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/config/default.py (1 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py (8 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_test_runner_service.py (1 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py (1 hunks)
  • spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_migrator.py (2 hunks)
Files skipped from review due to trivial changes (2)
  • spiffworkflow-backend/dev.docker-compose.yml
  • spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py
Additional context used
Gitleaks
spiffworkflow-backend/src/spiffworkflow_backend/config/default.py

150-150: Detected a Generic API Key, potentially exposing access to various services and sensitive operations. (generic-api-key)

Additional comments not posted (7)
spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_migrator.py (2)

114-114: Added handling for serialization without script engine state.

This change aligns with the PR's objective to support environments without task data, ensuring script engine state is optional during serialization.


211-211: Added handling for serialization without script engine state in another context.

Consistent with changes in other parts of the codebase, this ensures uniform handling of script engine state across various serialization contexts.

spiffworkflow-backend/src/spiffworkflow_backend/config/default.py (1)

237-237: Introduced configuration for using non-task data based script engine environments.

This new configuration setting allows toggling the use of non-task data based environments, which supports the PR's goal of making the script engine environment selectable at runtime.

spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_test_runner_service.py (1)

152-152: Refactored to use the new CustomScriptEngineEnvironment.create() method when initializing the script engine.

This change ensures that the script engine environment is dynamically determined at runtime, aligning with the PR's objectives to support selectable environments.

spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py (3)

302-308: The CustomScriptEngineEnvironment.create method has been modified to support dynamic selection of the script engine environment based on an environment variable. This is a critical change that affects the system's configurability and flexibility.

Ensure that the environment variable SPIFFWORKFLOW_BACKEND_USE_NON_TASK_DATA_BASED_SCRIPT_ENGINE_ENVIRONMENT is documented and included in deployment configurations.


351-351: The CustomBpmnScriptEngine constructor now uses the CustomScriptEngineEnvironment.create method to instantiate the script engine environment. This change integrates the new dynamic environment selection logic into the script engine.

Verify that all instances of CustomBpmnScriptEngine across the system are updated to accommodate this change.


1533-1544: The serialize method in ProcessInstanceProcessor now conditionally preserves or pops the script engine state based on the serialize_script_engine_state parameter. This modification is crucial for ensuring that the state is correctly managed during serialization.

It's recommended to add integration tests to ensure that the serialization behavior works as expected with different configurations of the serialize_script_engine_state parameter.

@@ -111,7 +111,7 @@ def test_can_run_version_4_migration(
processor = ProcessInstanceProcessor(
process_instance, include_task_data_for_completed_tasks=True, include_completed_subprocesses=True
)
bpmn_process_dict_version_4 = processor.serialize()
bpmn_process_dict_version_4 = processor.serialize(serialize_script_engine_state=False)
Copy link
Contributor

@jasquat jasquat Jun 17, 2024

Choose a reason for hiding this comment

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

Tests are passing for me fine with default settings. Is this actually necessary? I don't think the current changes should require this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I edited the description, which upon a re-read wasn't very clear, but these changes are to get the migrator tests passing with the non task data based environment. This was part of the work on the non_task_data_env branch to get the unit tests passing.

@jbirddog jbirddog merged commit ad0cf83 into main Jun 20, 2024
24 checks passed
@jbirddog jbirddog deleted the non_task_data_step1 branch June 20, 2024 11:56
@dinithihj
Copy link

@jbirddog @burnettk Is there anything specific we need to test related to this ticket?

@jbirddog
Copy link
Contributor Author

@jbirddog @burnettk Is there anything specific we need to test related to this ticket?

Nothing specific, should have no noticeable impact on the environments.

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.

None yet

4 participants