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

add qbg-hander config #2821

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Conversation

datelier
Copy link
Contributor

@datelier datelier commented Jan 30, 2025

Description

Add rust-QBG-Handler Config

Related Issue

Versions

  • Vald Version: v1.7.16
  • Go Version: v1.23.5
  • Rust Version: v1.83.0
  • Docker Version: v27.4.0
  • Kubernetes Version: v1.32.0
  • Helm Version: v3.16.3
  • NGT Version: v2.3.5
  • Faiss Version: v1.9.0

Checklist

Special notes for your reviewer

Summary by CodeRabbit

  • New Features

    • Added configuration management for the QBG agent service.
    • Introduced dynamic configuration loading for service initialization.
  • Chores

    • Added new configuration dependency.
    • Created sample configuration file for QBG agent.
  • Refactor

    • Updated service initialization to support external configuration settings.

Copy link
Contributor

coderabbitai bot commented Jan 30, 2025

📝 Walkthrough

Walkthrough

The pull request introduces configuration management for the vald-agent-qbg component by adding a new YAML configuration file and updating the Rust implementation to support dynamic configuration loading. A new sample.yaml file defines comprehensive settings for the agent, including versioning, logging preferences, server configurations, and QBG-specific parameters. The Rust implementation in main.rs has been modified to utilize a new constructor for the QBGService, allowing for dynamic initialization based on external configuration parameters.

Changes

File Change Summary
cmd/agent/core/qbg/sample.yaml New configuration file with comprehensive settings for vald-agent-qbg, including version, logging, server configurations, TLS, observability, and QBG-specific parameters
rust/bin/agent/Cargo.toml Added config = "0.14.0" dependency for configuration management
rust/bin/agent/src/main.rs Updated QBGService with new new(settings: Config) constructor for dynamic configuration initialization

Sequence Diagram

sequenceDiagram
    participant Config as Configuration File
    participant Main as Main Function
    participant QBGService as QBGService
    participant ANN as ANN Algorithm

    Config ->> Main: Load configuration
    Main ->> QBGService: Create new instance with config
    QBGService -->> QBGService: Initialize properties
    QBGService -->> ANN: Configure algorithm settings
Loading

Suggested reviewers

  • kpango
  • kmrmt
  • vankichi

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>, please review it.
    • 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 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 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 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. (Beta)
  • @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.

This commit fixes the style issues introduced in d18ab60 according to the output
from Gofumpt and Prettier.

Details: #2821
Copy link

cloudflare-workers-and-pages bot commented Jan 30, 2025

Deploying vald with  Cloudflare Pages  Cloudflare Pages

Latest commit: f620778
Status: ✅  Deploy successful!
Preview URL: https://ce41376e.vald.pages.dev
Branch Preview URL: https://feature-agent-rust-agent-qbg-zu75.vald.pages.dev

View logs

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

🧹 Nitpick comments (2)
rust/bin/agent/src/main.rs (2)

100-104: Add documentation to QBGService.

This struct houses critical fields for the QBG index and property initialization. Adding doc comments ensures new contributors and maintainers understand its purpose and usage.


273-276: Handle missing or invalid config file paths.

The Config::builder() and subsequent .unwrap() can panic if /etc/server/config.yaml is missing or contains invalid syntax. Consider checking the file's existence or providing a fallback path to ensure a stable startup.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e3865d4 and 9459fbc.

⛔ Files ignored due to path filters (1)
  • rust/Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • cmd/agent/core/qbg/sample.yaml (1 hunks)
  • rust/bin/agent/Cargo.toml (1 hunks)
  • rust/bin/agent/src/main.rs (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (4)
rust/bin/agent/src/main.rs (1)

19-19: Consider verifying config crate usage.

The new use config::Config; statement is clear, but ensure the crate version is pinned in Cargo.toml to avoid unintended breaking changes during dependency resolution.

rust/bin/agent/Cargo.toml (1)

28-28: Confirm compatibility for config = "0.14.0".

Adding config is a good move for dynamic configuration. However, ensure that version 0.14.0 is compatible with other crates in the long run, or consider using a more recent stable release if needed.

cmd/agent/core/qbg/sample.yaml (2)

22-62: Verify server and health check configurations.

The server and health check sections define parameters such as timeouts and concurrency. Several fields (e.g., connection_timeout) are set to an empty string, which might be interpreted as zero or cause unexpected defaults. Confirm these values are intended or provide meaningful defaults if non-configured.


105-128: Ensure qbg parameters are fully defined or handled gracefully.

Several fields (e.g., extended_dimension, internal_data_type) are left blank. Confirm the underlying code can handle these empty values at runtime without panicking or producing incorrect results.

rust/bin/agent/src/main.rs Outdated Show resolved Hide resolved
@vdaas-ci
Copy link
Collaborator

[CHATOPS:HELP] ChatOps commands.

  • 🙆‍♀️ /approve - approve
  • 🍱 /format - format codes and add licenses
  • /gen-test - generate test codes
  • 🏷️ /label - add labels
  • 🔚 2️⃣ 🔚 /label actions/e2e-deploy - run E2E deploy & integration test

Copy link

codecov bot commented Jan 30, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 17.18%. Comparing base (c3b5832) to head (f620778).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2821      +/-   ##
==========================================
- Coverage   23.92%   17.18%   -6.75%     
==========================================
  Files         547      136     -411     
  Lines       54586    15042   -39544     
==========================================
- Hits        13061     2585   -10476     
+ Misses      40741    12154   -28587     
+ Partials      784      303     -481     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

♻️ Duplicate comments (1)
rust/bin/agent/src/main.rs (1)

107-169: 🛠️ Refactor suggestion

Handle potential parsing errors from settings.

Multiple unwrap() calls might cause runtime panics if keys are missing or misconfigured. Consider handling failures gracefully and providing fallback values or descriptive error messages.

Validate default values for QBG parameters.

The current implementation uses hardcoded default values that might not be appropriate for all use cases. Consider:

  1. Documenting the rationale behind each default value
  2. Validating parameter combinations
  3. Adding runtime checks for critical parameters

Here's a safer implementation approach:

impl QBGService {
    fn new(settings: Config) -> Result<Self, Box<dyn std::error::Error>> {
        let path = settings
            .get::<String>("qbg.index_path")
            .unwrap_or_else(|_| "index".to_string());
            
        let dimension = settings
            .get::<usize>("qbg.dimension")
            .map_err(|e| format!("Invalid dimension: {}", e))?;
            
        if dimension == 0 {
            return Err("Dimension must be greater than 0".into());
        }
        
        let mut property = Property::new();
        property.init_qbg_construction_parameters();
        
        // Continue with parameter validation...
        
        let index = Index::new(&path, &mut property)
            .map_err(|e| format!("Failed to initialize QBG index: {}", e))?;
            
        Ok(QBGService {
            path,
            index,
            property,
        })
    }
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9459fbc and 975278f.

📒 Files selected for processing (1)
  • rust/bin/agent/src/main.rs (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: Run tests for pkg packages
  • GitHub Check: coverage
  • GitHub Check: Run tests for cmd packages
  • GitHub Check: Run tests for internal packages
  • GitHub Check: check-format-diff
  • GitHub Check: build / build
  • GitHub Check: runner / textlint
  • GitHub Check: Analyze (go)
  • GitHub Check: Cloudflare Pages
🔇 Additional comments (2)
rust/bin/agent/src/main.rs (2)

19-19: LGTM!

The addition of the Config import is appropriate for the new configuration-based initialization.


100-104: LGTM!

The struct fields are well-defined and appropriate for the QBG service implementation.

rust/bin/agent/src/main.rs Show resolved Hide resolved
@datelier datelier requested review from kmrmt, kpango and vankichi February 4, 2025 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants