Skip to content

Conversation

@amindadgar
Copy link
Member

@amindadgar amindadgar commented Jun 29, 2025

As a temporary fix to llama-index first loading into vectorstore issue, we limit the batch size to 1.

Summary by CodeRabbit

  • Refactor
    • Adjusted document processing to handle each document individually during data loading to improve reliability. Batch processing will be reinstated once underlying issues are resolved.

As a temporary fix to llama-index first loading into vectorstore issue, we limit the batch size to 1.

The issue described:
In llama-index pipeline when trying to load documents into vectorstore, it first loads into docstore and then into vectorstore.
In any case problems raised while loading into docstore the data would be missed to be loaded into vectorstore. So we limit the batch size to 1 meaning the data will be 1 by 1 loaded into docstore + vectorstore.
@amindadgar amindadgar linked an issue Jun 29, 2025 that may be closed by this pull request
@coderabbitai
Copy link

coderabbitai bot commented Jun 29, 2025

Walkthrough

The batch size for document processing in the load method of the MediawikiETL class was changed from 1000 to 1. This adjustment means each document is now processed individually rather than in large batches, while the parallel processing and error handling logic remains the same. A TODO comment was added to revert the batch size once a known llama-index issue is resolved.

Changes

File(s) Change Summary
hivemind_etl/mediawiki/etl.py Changed batch size in MediawikiETL.load from 1000 to 1; added TODO comment about reverting batch size after llama-index fix.

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant MediawikiETL
    participant ThreadPoolExecutor

    Caller->>MediawikiETL: load(documents)
    MediawikiETL->>MediawikiETL: Split documents into batches of 1
    loop For each document
        MediawikiETL->>ThreadPoolExecutor: submit(process, [document])
    end
    ThreadPoolExecutor-->>MediawikiETL: Return results as completed
    MediawikiETL-->>Caller: Return processing results
Loading

Possibly related PRs

Poem

One by one, the docs now go,
Through ETL’s careful flow.
No more crowds in every batch,
Each document gets its own dispatch!
Rabbits cheer, “Efficiency’s fun!”
Processed alone, but never outdone.
🐇✨


📜 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 0185c7f and aaf252c.

📒 Files selected for processing (1)
  • hivemind_etl/mediawiki/etl.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • hivemind_etl/mediawiki/etl.py
✨ Finishing Touches
  • 📝 Generate Docstrings

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

Copy link

@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

🔭 Outside diff range comments (1)
hivemind_etl/mediawiki/etl.py (1)

119-124: Improve error handling for single-document processing.

With batch_size=1, any single document failure now stops the entire ETL process. This makes the pipeline more fragile than necessary. Consider implementing partial failure handling to skip problematic documents while continuing to process the rest.

                try:
                    future.result()  # This will raise any exceptions that occurred
                    logging.info(f"Successfully loaded batch {batch_idx} of {len(batches)} documents into Qdrant!")
                except Exception as e:
-                    logging.error(f"Error processing batch {batch_idx}: {e}")
-                    raise  # Re-raise the exception to stop the process
+                    logging.error(f"Error processing document {batch_idx}: {e}")
+                    # Continue processing other documents instead of failing the entire batch
+                    continue

This aligns with the retrieved learning that "Errors should be caught in ETL processes, especially in the load method."

🧹 Nitpick comments (1)
hivemind_etl/mediawiki/etl.py (1)

109-114: Consider reducing ThreadPoolExecutor workers for single-document batches.

With batch_size=1, having max_workers=10 may create unnecessary overhead since each worker now processes only one document. Consider reducing the worker count or implementing a different concurrency strategy.

-        with ThreadPoolExecutor(max_workers=10) as executor:
+        # Reduced workers for single-document processing to minimize overhead
+        max_workers = min(10, len(documents), 5)  # Cap at 5 for single-document batches
+        with ThreadPoolExecutor(max_workers=max_workers) as executor:
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f6f3d49 and 0185c7f.

📒 Files selected for processing (1)
  • hivemind_etl/mediawiki/etl.py (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: amindadgar
PR: TogetherCrew/temporal-worker-python#15
File: hivemind_etl/mediawiki/llama_xml_reader.py:77-95
Timestamp: 2025-04-13T06:12:17.600Z
Learning: Error handling for XML parsing in the `XMLReader.load_data` method in `hivemind_etl/mediawiki/llama_xml_reader.py` has been deferred for a future implementation.
Learnt from: amindadgar
PR: TogetherCrew/temporal-worker-python#1
File: hivemind_etl/website/website_etl.py:84-94
Timestamp: 2024-11-25T11:29:38.063Z
Learning: Errors should be caught in ETL processes, especially in the `load` method of the `WebsiteETL` class in `hivemind_etl/website/website_etl.py`.
hivemind_etl/mediawiki/etl.py (1)
Learnt from: amindadgar
PR: TogetherCrew/temporal-worker-python#15
File: hivemind_etl/mediawiki/llama_xml_reader.py:77-95
Timestamp: 2025-04-13T06:12:17.600Z
Learning: Error handling for XML parsing in the `XMLReader.load_data` method in `hivemind_etl/mediawiki/llama_xml_reader.py` has been deferred for a future implementation.
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: ci / test / Test

@amindadgar amindadgar merged commit 3745b99 into main Jun 29, 2025
5 of 6 checks passed
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.

MediaWiki ETL limit loading batch into 1!

2 participants