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

Compressed data table #1569

Closed
wants to merge 4 commits into from
Closed

Compressed data table #1569

wants to merge 4 commits into from

Conversation

jasquat
Copy link
Contributor

@jasquat jasquat commented May 20, 2024

Supports #1567

Adds compression to task data so it takes up less space. Adds a new table compressed_data that will hold this data and moves usage away from json_data to this table.

Summary by CodeRabbit

  • New Features

    • Introduced CompressedDataModel for efficient data storage and retrieval.
  • Enhancements

    • Replaced JsonDataModel with CompressedDataModel across various modules, improving data handling performance.
  • Bug Fixes

    • Updated data retrieval and storage methods to ensure compatibility with the new CompressedDataModel.
  • Code Refactor

    • Streamlined code by removing deprecated JsonDataModel references and integrating CompressedDataModel methods.

Copy link
Contributor

coderabbitai bot commented May 20, 2024

Walkthrough

Walkthrough

The recent updates to the spiffworkflow-backend module involve transitioning from JsonDataModel to CompressedDataModel for handling data storage and retrieval. This change enhances data compression capabilities across various components, including models, controllers, and services. The updates ensure efficient data management, impacting methods for data insertion, updating, and retrieval within tasks, processes, and reports.

Changes

File(s) Change Summary
.../load_database_models.py Added import statement for CompressedDataModel.
.../models/compressed_data.py Introduced CompressedDataModel class with methods for data compression, storage, and retrieval.
.../models/process_instance_report.py Updated to use CompressedDataModel for report metadata handling.
.../models/task.py Replaced JsonDataModel with CompressedDataModel in data retrieval methods.
.../models/task_draft_data.py Updated get_saved_form_data to use CompressedDataModel.
.../routes/process_api_blueprint.py Replaced JsonDataModel with CompressedDataModel for data retrieval in BPMN processes.
.../routes/process_instances_controller.py Updated data serialization/deserialization to use CompressedDataModel.
.../routes/tasks_controller.py Replaced references to JsonDataModel with CompressedDataModel for data handling.
.../services/process_instance_processor.py Updated functions for data retrieval and storage to use CompressedDataModel.
.../services/task_service.py Replaced JsonDataModel and JsonDataDict with CompressedDataModel and CompressedDataDict.
.../tests/spiffworkflow_backend/unit/test_process_instance_processor.py Removed import of JsonDataModel.

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.

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.
  • 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: 1

Review Details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits Files that changed from the base of the PR and between 10e9511 and a6bc8c7.
Files ignored due to path filters (1)
  • spiffworkflow-backend/migrations/versions/ada8eab55f1a_.py is excluded by !spiffworkflow-backend/migrations/**
Files selected for processing (11)
  • spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py (1 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/models/compressed_data.py (1 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_report.py (4 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/models/task.py (2 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/models/task_draft_data.py (2 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py (2 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py (3 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py (5 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py (5 hunks)
  • spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py (9 hunks)
  • spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_processor.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • spiffworkflow-backend/tests/spiffworkflow_backend/unit/test_process_instance_processor.py
Additional comments not posted (29)
spiffworkflow-backend/src/spiffworkflow_backend/models/task_draft_data.py (2)

14-14: Import of CompressedDataModel correctly replaces JsonDataModel to align with the new data handling strategy.


51-51: Updated method get_saved_form_data to use CompressedDataModel for data retrieval, aligning with the new data handling strategy.

spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_report.py (3)

8-8: Correctly updated import to use CompressedDataModel, supporting the new data handling requirements.


93-93: Method get_report_metadata correctly updated to retrieve data using CompressedDataModel, aligning with the new compressed data strategy.


117-117: Method create_report appropriately updated to use CompressedDataModel for creating and inserting compressed data, aligning with the updated data handling strategy.

spiffworkflow-backend/src/spiffworkflow_backend/models/compressed_data.py (1)

27-93: The CompressedDataModel class is well-implemented with methods for handling compressed data efficiently using gzip and SHA256. The database interaction methods are correctly adapted for different database types, ensuring compatibility.

spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py (1)

72-72: Import of CompressedDataModel correctly added to ensure it is recognized by SQLAlchemy and available throughout the application.

spiffworkflow-backend/src/spiffworkflow_backend/models/task.py (3)

16-16: Import of CompressedDataModel correctly updated to support the new data handling strategy.


90-90: Method python_env_data correctly updated to retrieve data using CompressedDataModel, aligning with the new compressed data strategy.


93-93: Method json_data appropriately updated to use CompressedDataModel for data retrieval, aligning with the updated data handling strategy.

spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py (3)

28-28: Import of CompressedDataModel correctly updated to support the new data handling strategy.


185-185: Method process_instance_list correctly updated to use CompressedDataModel for creating and inserting compressed data, aligning with the updated data handling strategy.


205-205: Method process_instance_report_show correctly updated to retrieve data using CompressedDataModel, aligning with the new compressed data strategy.

spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py (9)

18-19: Imports of CompressedDataDict and CompressedDataModel have been added to replace JsonDataModel.


126-126: Initialization of compressed_data_dicts dictionary to store compressed data.


136-136: Usage of CompressedDataModel.insert_or_update_compressed_data_records to handle bulk updates of compressed data.


208-212: Method update_task_data_on_bpmn_process is used to update BPMN process data and store the resulting compressed data dictionary.


262-264: Repetition of the pattern seen in lines 208-212, confirming consistent use of CompressedDataModel for handling compressed data.


301-310: The method update_json_data_on_db_model_and_return_dict_if_updated is used to update the task model with compressed data, replacing the previous JSON data handling.


429-433: The method update_task_data_on_bpmn_process is used within add_bpmn_process to handle compressed data for new BPMN processes.


539-549: Implementation of update_task_data_on_bpmn_process to handle the conversion of data to compressed format and update the BPMN process hash accordingly.


554-558: Method update_json_data_on_db_model_and_return_dict_if_updated is adapted to handle compressed data, ensuring that the hash is updated only if it changes.

spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py (4)

29-29: Import of CompressedDataModel is correct as per the PR objectives.


261-265: The integration of CompressedDataModel in task_data_update is correctly implemented.


593-599: The use of CompressedDataModel in _interstitial_stream for fetching and decompressing data is correctly implemented.


Line range hint 728-747: The integration of CompressedDataModel in task_save_draft is correctly implemented.

Verification successful

The previous script failed due to an incorrect file type specification for rg. Let's correct this and re-run the script to verify the integration of CompressedDataModel methods with other components in the codebase.


The CompressedDataModel methods are indeed integrated with various components across the codebase, as evidenced by the search results. This confirms that the integration is widespread and consistent.

  • Files and lines where CompressedDataModel is used:
    • spiffworkflow-backend/src/spiffworkflow_backend/models/task_draft_data.py
    • spiffworkflow-backend/src/spiffworkflow_backend/models/task.py
    • spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py
    • spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py
    • spiffworkflow-backend/src/spiffworkflow_backend/services/task_service.py
    • spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py
    • spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py
    • spiffworkflow-backend/src/spiffworkflow_backend/models/process_instance_report.py
    • spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py
    • spiffworkflow-backend/src/spiffworkflow_backend/models/compressed_data.py

Given this extensive usage, the integration appears to be thorough and well-implemented.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `CompressedDataModel` methods are correctly integrated with other components.

# Test: Search for usage of `CompressedDataModel` methods in other parts of the codebase.
rg --type python $'CompressedDataModel'

Length of output: 69



Script:

#!/bin/bash
# Description: Verify that `CompressedDataModel` methods are correctly integrated with other components.

# Test: Search for usage of `CompressedDataModel` methods in other parts of the codebase.
rg 'CompressedDataModel' --glob '*.py'

Length of output: 5854

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

70-70: Import of CompressedDataModel is correctly added to replace JsonDataModel.


668-669: Usage of CompressedDataModel.find_data_dict_by_hash correctly replaces the previous JsonDataModel method.


1639-1639: Usage of CompressedDataModel.insert_or_update_compressed_data_records correctly replaces the previous JsonDataModel method.

@@ -156,7 +156,7 @@ def _get_data_object_from_bpmn_process(
bpmn_process_guid: str | None,
process_instance: ProcessInstanceModel,
) -> Any:
bpmn_process_data = JsonDataModel.find_data_dict_by_hash(bpmn_process.json_data_hash)
bpmn_process_data = CompressedDataModel.find_data_dict_by_hash(bpmn_process.json_data_hash)
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The search results indicate that there are still references to JsonDataModel in the codebase, specifically in the load_database_models.py and json_data.py files. These references need to be updated to CompressedDataModel.

  • spiffworkflow-backend/src/spiffworkflow_backend/load_database_models.py
  • spiffworkflow-backend/src/spiffworkflow_backend/models/json_data.py
Analysis chain

Change from JsonDataModel to CompressedDataModel correctly implemented.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that all references to `JsonDataModel` have been replaced with `CompressedDataModel` in the entire codebase.

# Test: Search for the old model usage. Expect: No occurrences of `JsonDataModel`.
rg --type python $'JsonDataModel'

Length of output: 63



Script:

#!/bin/bash
# Description: Verify that all references to `JsonDataModel` have been replaced with `CompressedDataModel` in the entire codebase.

# Test: Search for the old model usage. Expect: No occurrences of `JsonDataModel`.
rg --glob '*.py' 'JsonDataModel'

Length of output: 1179

@jasquat jasquat marked this pull request as draft May 22, 2024 14:17
@jasquat
Copy link
Contributor Author

jasquat commented Jun 18, 2024

Closing for now since we may no be going this route.

@jasquat jasquat closed this Jun 18, 2024
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