Skip to content

Conversation

OCWC22
Copy link

@OCWC22 OCWC22 commented Jun 9, 2025

Description

Fixes #23

This PR resolves the critical bug where BasicOptimizationStrategy.run fails with OptimizationError: 'str' object has no attribute 'kwargs'.

Root Cause

The bug was caused by incorrectly passing num_threads to the dspy.MIPROv2() constructor, which doesn't accept this parameter. This caused a TypeError that was masked by broad exception handling.

Solution

  • ✅ Remove num_threads from dspy.MIPROv2() constructor
  • ✅ Pass num_threads correctly via eval_kwargs to optimizer.compile()
  • ✅ Add comprehensive unit and integration tests
  • ✅ Ensure parallel processing works as intended

Testing

  • Unit tests for API compliance (test_prompt_strategies.py)
  • Integration tests for dspy interaction (test_core_integration.py)
  • CLI end-to-end tests (test_cli_integration.py)
  • All existing tests pass

Breaking Changes

None - this is a bug fix that enables previously broken functionality.

Files Changed

  • src/llama_prompt_ops/core/prompt_strategies.py - Core fix
  • tests/unit/test_prompt_strategies.py - New unit tests
  • tests/integration/test_core_integration.py - Integration test
  • tests/integration/test_cli_integration.py - CLI test

@facebook-github-bot
Copy link

Hi @OCWC22!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

OCWC22 added 2 commits June 8, 2025 21:14
Files Updated:
• CHANGELOG.md: Added entries documenting the fix for the OptimizationError related to the num_threads parameter in BasicOptimizationStrategy.
• TECHNICAL_DEBT.md: Documented the need to refactor broad exception handling in BasicOptimizationStrategy.run to improve error diagnosis.

Description:
Created a CHANGELOG.md to track notable changes, including the resolution of a critical bug in the BasicOptimizationStrategy related to incorrect parameter passing to the dspy.MIPROv2 constructor. Additionally, a TECHNICAL_DEBT.md file was added to highlight the need for improved exception handling practices.

Reasoning:
The addition of a changelog enhances project transparency and user awareness of changes, while documenting technical debt ensures that future refactoring efforts are prioritized to improve code maintainability.

Trade-offs:
• Positive: Improved documentation and tracking of changes for better project management.
• Minimal: Requires ongoing updates to the changelog and technical debt documentation as the project evolves.

Considerations:
• The changelog follows the Keep a Changelog format, ensuring consistency and clarity for users.
• Technical debt documentation will guide future refactoring efforts to enhance error handling.

Future Work:
• Regularly update the changelog with future releases and bug fixes.
• Address the technical debt related to exception handling in upcoming development cycles.
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Jun 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OptimizationError: 'str' object has no attribute 'kwargs' in llama-prompt-ops v0.0.7

2 participants