dynamic env configurations with Db table
What
- Introduced support for overriding system configuration values (e.g.,
MAX_PARALLEL_FILE_BATCHES) on a per-organization basis. - Added a new model to store organization-level config overrides.
- Implemented a utility to fetch the effective config value with fallback to the global default
env. - Applied the override logic for
MAX_PARALLEL_FILE_BATCHES.
Why
- Different organizations may require customized system behavior, such as varying batch sizes.
- This flexibility improves system adaptability and allows fine-tuning without global impact.
- Supports future use cases like organization-specific timeouts, feature flags, etc.
How
- Created a new Django model in the
configurationapp to store key-value config overrides scoped to organizations. - Added logic to resolve config values in the following order:
organization override > default system config - Refactored existing places where
MAX_PARALLEL_FILE_BATCHESis used to go through the new config resolution utility.
Can this PR break any existing features. If yes, please list possible items. If no, please explain why. (PS: Admins do not merge the PR without this section filled)
- No
Database Migrations
- Yes, new table added for organization-level configuration overrides.
Env Config
Relevant Docs
Related Issues or PRs
Dependencies Versions
Notes on Testing
Screenshots
Checklist
I have read and understood the Contribution Guidelines.
Quality Gate passed
Issues
1 New issue
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
Summary by CodeRabbit
-
New Features
- Introduced organization-level configuration management, allowing system settings to be customized per organization.
- Added support for configuring the maximum number of parallel file batches, with validation and default limits.
- Provided a new admin-accessible model for managing configuration overrides.
-
Chores
- Updated environment variable documentation to include new configuration options.
Summary by CodeRabbit
-
New Features
- Introduced a new configuration system allowing organization-specific settings to be managed in the app.
- Added support for storing, retrieving, and casting typed configuration values per organization.
- Configuration values now include validation and type handling (integer, string, boolean, JSON).
-
Improvements
- Batch processing behavior now dynamically adapts based on organization-specific configuration instead of a fixed value.
Walkthrough
A new Django app named "configuration" is introduced, including its model, enums, and migration for storing per-organization configuration values. The Django project settings are updated to include this app. The workflow batching logic is refactored to fetch its configuration dynamically from the database using the new configuration system instead of a static settings value.
Changes
| File(s) | Change Summary |
|---|---|
| backend/backend/settings/base.py | Added MAX_PARALLEL_FILE_BATCHES and MAX_PARALLEL_FILE_BATCHES_MAX_VALUE settings; included "configuration" in SHARED_APPS. |
| backend/sample.env | Added environment variable MAX_PARALLEL_FILE_BATCHES_MAX_VALUE. |
| backend/configuration/apps.py | Added Django app config class ConfigurationConfig for the new "configuration" app. |
| backend/configuration/enums.py | Added enums and dataclasses for configuration types, keys, and value casting logic with validation. |
| backend/configuration/migrations/0001_initial.py | Added initial migration for new Configuration model with fields, constraints, and organization linkage. |
| backend/configuration/models.py | Added Configuration model with per-organization config storage, value casting, validation, and retrieval logic. |
| backend/workflow_manager/workflow_v2/workflow_helper.py | Refactored file batching logic to fetch batch size from the new configuration model per organization. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant WorkflowHelper
participant Configuration
participant Database
User->>WorkflowHelper: get_file_batches(user, files)
WorkflowHelper->>Configuration: get_value_by_organization(ConfigKey, user.organization)
Configuration->>Database: Query Configuration for (organization, ConfigKey)
Database-->>Configuration: Return config value (or None)
Configuration-->>WorkflowHelper: Return typed config value (or default)
WorkflowHelper-->>User: Return file batches (using config value)
📜 Recent review details
Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro Cache: Disabled due to Reviews > Disable Cache setting Knowledge Base: Disabled due to Reviews > Disable Knowledge Base setting
📥 Commits
Reviewing files that changed from the base of the PR and between 6ab4443a09649b86d93eb44bfb8e4bbd608fdd17 and 3ecd2e5df8d11ffce6ec7eec2b05123f97f20c40.
📒 Files selected for processing (2)
backend/backend/settings/base.py(2 hunks)backend/configuration/enums.py(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
- backend/backend/settings/base.py
- backend/configuration/enums.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build
✨ Finishing Touches
- [ ] 📝 Generate Docstrings
🪧 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>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@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.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
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 using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
| filepath | function | $$\textcolor{#23d18b}{\tt{passed}}$$ | SUBTOTAL |
|---|---|---|---|
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_logs}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_cleanup}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_cleanup\_skip}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_client\_init}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_get\_image\_exists}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_get\_image}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_get\_container\_run\_config}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_get\_container\_run\_config\_without\_mount}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_run\_container}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_get\_image\_for\_sidecar}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{runner/src/unstract/runner/clients/test\_docker.py}}$$ | $$\textcolor{#23d18b}{\tt{test\_sidecar\_container}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ | $$\textcolor{#23d18b}{\tt{1}}$$ |
| $$\textcolor{#23d18b}{\tt{TOTAL}}$$ | $$\textcolor{#23d18b}{\tt{11}}$$ | $$\textcolor{#23d18b}{\tt{11}}$$ |
Quality Gate passed
Issues
0 New issues
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code