Skip to content

feat: custom worker count for IBM models in OpenSearch#10866

Merged
edwinjosechittilappilly merged 8 commits into
mainfrom
fix-open-search-workers
Dec 3, 2025
Merged

feat: custom worker count for IBM models in OpenSearch#10866
edwinjosechittilappilly merged 8 commits into
mainfrom
fix-open-search-workers

Conversation

@edwinjosechittilappilly
Copy link
Copy Markdown
Collaborator

@edwinjosechittilappilly edwinjosechittilappilly commented Dec 3, 2025

This pull request introduces a targeted update to the embedding concurrency logic in opensearch_multimodal.py. The main change is the restriction of parallel embedding requests for IBM/Watsonx models to avoid hitting rate limits.

Concurrency and rate limit handling:

  • In embed_chunk, the max_workers value is set to 1 for IBM/Watsonx models, ensuring only one embedding request is processed at a time and thus reducing the risk of rate limit errors. For other models, the previous logic of up to 8 workers is retained.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of IBM Watsonx embedding operations by optimizing concurrency settings to prevent rate-limiting issues. Non-IBM embedding models continue to use parallel processing for improved performance.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 3, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds conditional concurrency control for embeddings by detecting IBM Watsonx models and restricting parallelism to a single worker when identified. Otherwise, standard parallelism calculation min(max(len(texts), 1), 8) is used.

Changes

Cohort / File(s) Change Summary
Embedding Concurrency Control
src/lfx/src/lfx/components/elastic/opensearch_multimodal.py
Adds model detection logic in embedding operations to conditionally set max_workers. When embedding_model name contains "ibm" or selected_embedding type name contains "watsonx", max_workers is restricted to 1. Otherwise, standard parallelism formula is applied.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Review the conditional logic for model name detection (IBM/Watsonx strings)
  • Verify that max_workers assignment doesn't inadvertently affect other embedding models
  • Confirm the impact on the threading/retry loop behavior remains as intended

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • phact

Pre-merge checks and finishing touches

Important

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Test Quality And Coverage ⚠️ Warning IBM/Watsonx concurrency control implementation (lines 881-885) lacks any corresponding tests in the test suite. Add test cases validating IBM/Watsonx detection logic, max_workers=1 assignment, and ThreadPoolExecutor behavior with single-worker concurrency.
Test Coverage For New Implementations ❓ Inconclusive Cannot verify test coverage; the modified opensearch_multimodal.py file and test files are not accessible in the current repository context. Provide access to the PR changes with the modified source file and corresponding test files to verify test coverage for the max_workers concurrency control implementation.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: introducing custom worker count configuration for IBM models in OpenSearch embedding operations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Test File Naming And Structure ✅ Passed PR includes comprehensive test file (test_opensearch_multimodal.py) with robust pytest structure, descriptive test functions, proper fixtures, and coverage of unit, integration, positive and negative test cases.
Excessive Mock Usage Warning ✅ Passed PR only modifies source code for concurrency control with no test file changes. Existing tests show minimal mock usage (0.03 @patch per test, 10 total calls across 31 tests) with appropriate fixture reuse and real component testing.

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces concurrency control for IBM/Watsonx embedding models to mitigate rate limiting issues during document ingestion in OpenSearch. The change restricts parallel embedding requests to a single worker for IBM models while maintaining the existing multi-threaded approach (up to 8 workers) for other embedding providers.

Key Changes:

  • Added detection logic to identify IBM/Watsonx models based on model name or embedding class name
  • Set max_workers=1 for IBM/Watsonx models to prevent rate limit errors during parallel embedding generation
  • Preserved existing concurrency logic for non-IBM models

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +882 to +884
is_ibm = (embedding_model and "ibm" in str(embedding_model).lower()) or (
selected_embedding and "watsonx" in type(selected_embedding).__name__.lower()
)
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

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

The detection logic for IBM/Watsonx models relies on substring matching which could be fragile. Consider checking the exact class type instead:

from langchain_ibm import WatsonxEmbeddings

is_ibm = isinstance(selected_embedding, WatsonxEmbeddings)

This would be more robust than checking for "watsonx" in the class name, as it would work correctly even if the class is renamed or extended. If you need to support multiple IBM embedding classes, you could check against a tuple of types.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

could be a future use case but currently only for ingestion hence selected embeddings is fine

Comment on lines +881 to +885
# Restrict concurrency for IBM/Watsonx models to avoid rate limits
is_ibm = (embedding_model and "ibm" in str(embedding_model).lower()) or (
selected_embedding and "watsonx" in type(selected_embedding).__name__.lower()
)
max_workers = 1 if is_ibm else min(max(len(texts), 1), 8)
Copy link

Copilot AI Dec 3, 2025

Choose a reason for hiding this comment

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

The new concurrency restriction logic for IBM/Watsonx models lacks test coverage. Consider adding tests to verify:

  1. When an IBM/Watsonx embedding is used, max_workers is set to 1
  2. When a non-IBM embedding is used, max_workers follows the original logic (min(max(len(texts), 1), 8))
  3. The detection logic correctly identifies IBM models by checking the embedding_model string
  4. The detection logic correctly identifies Watsonx models by checking the class name

This would help prevent regressions if the detection logic or concurrency settings change in the future.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
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: 0

🧹 Nitpick comments (1)
src/lfx/src/lfx/components/elastic/opensearch_multimodal.py (1)

878-887: IBM/Watsonx concurrency guard looks correct; consider small readability tweaks

The is_ibm check and max_workers = 1 branch achieve the PR goal without changing behavior for other providers. A couple of minor, optional nits:

  • is_ibm and max_workers don’t depend on the retry attempt; you could compute them once before the while loop to avoid repeating the same logic and make intent clearer.
  • If you expect more IBM/Watsonx-specific handling later, extracting the detection into a tiny helper (e.g. _is_ibm_embedding(embedding_model, selected_embedding)) would centralize the heuristic and make it easier to extend (e.g. other IBM model name patterns).

No functional changes are required here; these would just tighten clarity and future maintainability.

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 17af7fb and 7e36fce.

📒 Files selected for processing (1)
  • src/lfx/src/lfx/components/elastic/opensearch_multimodal.py (1 hunks)
⏰ 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). (4)
  • GitHub Check: CodeQL analysis (python)
  • GitHub Check: Agent
  • GitHub Check: Update Component Index
  • GitHub Check: Update Starter Projects

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Dec 3, 2025
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Dec 3, 2025
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Dec 3, 2025
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 3, 2025

Frontend Unit Test Coverage Report

Coverage Summary

Lines Statements Branches Functions
Coverage: 15%
15.43% (4244/27499) 8.61% (1811/21013) 9.69% (587/6057)

Unit Test Results

Tests Skipped Failures Errors Time
1671 0 💤 0 ❌ 0 🔥 21.413s ⏱️

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 32.54%. Comparing base (17af7fb) to head (3a3a17c).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #10866      +/-   ##
==========================================
- Coverage   32.82%   32.54%   -0.29%     
==========================================
  Files        1367     1370       +3     
  Lines       64017    63518     -499     
  Branches     9553     9391     -162     
==========================================
- Hits        21014    20672     -342     
+ Misses      41943    41806     -137     
+ Partials     1060     1040      -20     
Flag Coverage Δ
backend 51.53% <ø> (-0.42%) ⬇️
frontend 14.28% <ø> (+0.15%) ⬆️
lfx 39.99% <ø> (-0.29%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 34 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Dec 3, 2025
@edwinjosechittilappilly edwinjosechittilappilly added this pull request to the merge queue Dec 3, 2025
Merged via the queue into main with commit 6b391f3 Dec 3, 2025
22 of 24 checks passed
@edwinjosechittilappilly edwinjosechittilappilly deleted the fix-open-search-workers branch December 3, 2025 22:53
Wallgau pushed a commit that referenced this pull request Dec 16, 2025
* Update opensearch_multimodal.py

* [autofix.ci] apply automated fixes

* Update opensearch_multimodal.py

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants