Skip to content

make config file dir configurable - #750

Merged
mainred merged 6 commits into
masterfrom
root_config_path_configurable
Jul 30, 2025
Merged

mainred merged 6 commits into
masterfrom
root_config_path_configurable

Conversation

@mainred

@mainred mainred commented Jul 29, 2025 •

Copy link
Copy Markdown
Collaborator

export CONFIG_PATH_DIR=/home/azureuser/testholmes
running holmes aks gives the following files correctly

ls ~/testholmes 
config.yaml  history  toolsets_status.json

@coderabbitai

coderabbitai Bot commented Jul 29, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

The changes refactor the configuration and state file locations in the application, replacing hardcoded user home directory paths with locations derived from a new, configurable config_path_dir variable. This variable is defined in a new module and imported where needed, centralizing and standardizing file path management across the codebase.

Changes

Cohort / File(s) Change Summary
Config Path Centralization
holmes/core/config.py
Introduces config_path_dir, set from the HOLMES_CONFIGPATH_DIR environment variable or defaults to ~/.holmes.
Config File Location Update
holmes/config.py
Changes DEFAULT_CONFIG_LOCATION to use config_path_dir.
Toolset Status Location Update
holmes/core/toolset_manager.py
Changes DEFAULT_TOOLSET_STATUS_LOCATION to use config_path_dir instead of a hardcoded home directory path.
Interactive History Location Update
holmes/interactive.py
Changes the interactive history file location to use config_path_dir instead of a hardcoded home directory path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between db88db4 and 4b241c9.

📒 Files selected for processing (1)
  • holmes/core/config.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • holmes/core/config.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). (3)
  • GitHub Check: Pre-commit checks
  • GitHub Check: llm_evals
  • GitHub Check: Pre-commit checks
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch root_config_path_configurable

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, 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 @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @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 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 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 73ef138 and e60ddf2.

📒 Files selected for processing (4)
  • holmes/config.py (2 hunks)
  • holmes/core/config.py (1 hunks)
  • holmes/core/toolset_manager.py (1 hunks)
  • holmes/interactive.py (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.py: Use Ruff for formatting and linting (configured in pyproject.toml)
Type hints required (mypy configuration in pyproject.toml)

Files:

  • holmes/core/toolset_manager.py
  • holmes/core/config.py
  • holmes/interactive.py
  • holmes/config.py
🧠 Learnings (3)
holmes/core/toolset_manager.py (2)

Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to holmes/plugins/toolsets/**/*.yaml : Toolsets: holmes/plugins/toolsets/{name}.yaml or {name}/

Learnt from: nherment
PR: #535
File: holmes/plugins/toolsets/bash/bash_toolset.py:207-209
Timestamp: 2025-06-24T05:51:04.543Z
Learning: The init_config method in toolsets should be idempotent - safely callable multiple times without errors. self.config should maintain consistent typing (not alternate between dict and config object types) throughout the object lifecycle.

holmes/interactive.py (1)

Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to holmes/plugins/prompts/**/*.jinja2 : Prompts: holmes/plugins/prompts/{name}.jinja2

holmes/config.py (4)

Learnt from: nherment
PR: #610
File: .github/workflows/llm-evaluation.yaml:39-42
Timestamp: 2025-07-08T08:45:41.069Z
Learning: The robusta-dev/holmesgpt codebase has comprehensive existing validation for Azure environment variables (AZURE_API_BASE, AZURE_API_KEY, AZURE_API_VERSION) and MODEL in tests/llm/utils/classifiers.py, tests/llm/conftest.py, and holmes/core/llm.py. Don't suggest adding redundant validation logic.

Learnt from: nherment
PR: #610
File: .github/workflows/llm-evaluation.yaml:39-42
Timestamp: 2025-07-08T08:45:41.069Z
Learning: When suggesting improvements to environment variable handling in robusta-dev/holmesgpt, check first if validation logic already exists rather than reimplementing it.

Learnt from: CR
PR: robusta-dev/holmesgpt#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-27T14:10:31.590Z
Learning: Applies to holmes/plugins/prompts/**/*.jinja2 : Prompts: holmes/plugins/prompts/{name}.jinja2

Learnt from: nherment
PR: #535
File: holmes/plugins/toolsets/bash/bash_toolset.py:207-209
Timestamp: 2025-06-24T05:51:04.543Z
Learning: The init_config method in toolsets should be idempotent - safely callable multiple times without errors. self.config should maintain consistent typing (not alternate between dict and config object types) throughout the object lifecycle.

🧬 Code Graph Analysis (1)
holmes/config.py (4)
holmes/utils/definitions.py (1)
  • RobustaConfig (11-13)
holmes/utils/env.py (1)
  • replace_env_vars_values (29-53)
holmes/utils/file_utils.py (1)
  • load_yaml_file (19-56)
holmes/utils/pydantic_utils.py (2)
  • RobustaBaseConfig (14-15)
  • load_model_from_file (39-54)
🪛 GitHub Actions: Build and test HolmesGPT
holmes/config.py

[error] 112-120: ruff-format: File was reformatted by ruff-format hook. Please run 'ruff --fix' or the pre-commit hook locally to apply formatting changes.

⏰ 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). (2)
  • GitHub Check: Pre-commit checks
  • GitHub Check: llm_evals
🔇 Additional comments (7)
holmes/core/config.py (1)

1-5: LGTM! Clean and focused configuration module.

The implementation is straightforward and follows good practices:

  • Uses os.environ.get() with a sensible default fallback
  • Centralizes the configurable base directory in one location
  • Uses os.path.expanduser() to properly handle the tilde in the default path
holmes/core/toolset_manager.py (2)

10-10: LGTM! Proper import of the centralized config path.

The import follows the established pattern for using the configurable base directory.


16-16: LGTM! Consistent usage of configurable directory path.

The change successfully replaces the hardcoded path with the configurable config_path_dir, maintaining backward compatibility while enabling customization via the CONFIG_PATH_DIR environment variable.

holmes/interactive.py (2)

30-30: LGTM! Consistent import of the centralized config path.

The import aligns with the configurable directory approach used across the codebase.


824-826: LGTM! Proper usage of configurable directory with safety checks.

The implementation correctly:

  • Uses the configurable config_path_dir for the history file location
  • Maintains the existing directory creation logic to ensure the parent directory exists
  • Preserves backward compatibility with the default ~/.holmes path
holmes/config.py (2)

34-34: LGTM! Consistent import of the centralized config path.

The import follows the established pattern for using the configurable base directory.


40-40: LGTM! Proper usage of configurable directory path.

The change successfully replaces the hardcoded path with the configurable config_path_dir, maintaining backward compatibility while enabling customization via the CONFIG_PATH_DIR environment variable.

Comment thread holmes/config.py Outdated
Comment thread holmes/core/config.py Outdated
@mainred
mainred enabled auto-merge (squash) July 30, 2025 00:02
@github-actions

Copy link
Copy Markdown
Contributor

Results of HolmesGPT evals

  • ask_holmes: 24/34 test cases were successful, 0 regressions, 1 skipped, 9 mock failures
Test suite Test case Status
ask 01_how_many_pods ✅
ask 02_what_is_wrong_with_pod 🔧
ask 03_what_is_the_command_to_port_forward 🔧
ask 04_related_k8s_events ↪️
ask 05_image_version 🔧
ask 09_crashpod ✅
ask 10_image_pull_backoff 🔧
ask 11_init_containers ✅
ask 13_pending_node_selector ✅
ask 14_pending_resources ✅
ask 15_failed_readiness_probe ✅
ask 17_oom_kill ✅
ask 18_crash_looping_v2 ✅
ask 19_detect_missing_app_details 🔧
ask 24_misconfigured_pvc 🔧
ask 28_permissions_error ✅
ask 29_events_from_alert_manager ✅
ask 39_failed_toolset 🔧
ask 41_setup_argo0 ✅
ask 41_setup_argo1 ✅
ask 42_dns_issues_steps_new_tools 🔧
ask 43_current_datetime_from_prompt ✅
ask 45_fetch_deployment_logs_simple ✅
ask 51_logs_summarize_errors 🔧
ask 53_logs_find_term ✅
ask 54_not_truncated_when_getting_pods 🔧
ask 59_label_based_counting ✅
ask 60_count_less_than 🔧
ask 61_exact_match_counting ✅
ask 63_fetch_error_logs_no_errors ✅
ask 79_configmap_mount_issue 🔧
ask 83_secret_not_found 🔧
ask 89_runbook_missing_cloudwatch 🔧
ask 90_runbook_basic_selection 🔧

Legend

  • ✅ the test was successful
  • ↪️ the test was skipped
  • ⚠️ the test failed but is known to be flaky or known to fail
  • 🔧 the test failed due to mock data issues (not a code regression)
  • ❌ the test failed and should be fixed before merging the PR

@mainred
mainred merged commit 29f130a into master Jul 30, 2025
@mainred
mainred deleted the root_config_path_configurable branch July 30, 2025 04:12
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