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

added batching to matcher.py and unit tests #69

Merged
merged 1 commit into from
Nov 30, 2024

Conversation

makrianast
Copy link
Contributor

Description

A new environment variable, BATCH_SIZE, was introduced in the matcher.py file to control the batch size when sending items to the LLM. The default value for BATCH_SIZE is 50 if the environment variable is not explicitly set.

Additionally, a function process_items_in_batches() was added to implement the batching logic. This function divides the input items into batches based on the BATCH_SIZE value and processes them accordingly. Special handling ensures that when BATCH_SIZE is set to 0, all items are processed together in a single batch.

Fixes #63

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

Testing

Six unit tests were implemented to verify the functionallity of the batching logic:

  • Test for basic batching: Confirms that 10 items are split into 2 batches when BATCH_SIZE is set to 5.
  • Test for single batch: Ensures that when BATCH_SIZE exceeds the number of items, all items are processed in a single batch.
  • Test for BATCH_SIZE == 0: Validates that batching is disabled, and all items are processed together.
  • Test for negative BATCH_SIZE: Ensures that when BATCH_SIZE is set to a negative value, it defaults to 0.
  • Test for default behavior: Confirms that BATCH_SIZE defaults to 50 when the environment variable is not set.
  • Test for invalid BATCH_SIZE: Verifies that BATCH_SIZE defaults to 50 if set to an invalid value.

Test Configuration

  • Library version:
  • OS: Windows11
  • Toolchain: 3.10.0

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

@woodthom2 woodthom2 merged commit 3631da3 into harmonydata:main Nov 30, 2024
1 check passed
@woodthom2
Copy link
Contributor

Thanks Anastasia!

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.

Add batching in matcher.py
2 participants