Skip to content

Latest commit

 

History

History
103 lines (70 loc) · 3.33 KB

File metadata and controls

103 lines (70 loc) · 3.33 KB

Contributing to dspy-opt

Thanks for your interest in contributing to the dspy-opt!

To submit PRs, please fill out the PR template along with the PR. If the PR fixes an issue, don't forget to link the PR to the issue!

Setup Environment

Clone the repository and create the python virtual environment:

uv sync --all-extras --dev

Activate the virtual environment:

source .venv/bin/activate

Pre-commit hooks

Once the python virtual environment is setup, you can run pre-commit hooks using:

pre-commit run --all-files

Make Commands

The project includes a Makefile with common development tasks. Run make help to see all available targets.

Linting and Formatting

make lint-fmt         # Format code and auto-fix lint issues
make lint-check       # Check formatting and lint without modifying files
make lint-style       # Lint with ruff (check only)
make lint-typing      # Type check with mypy
make lint-typos       # Check for typos
make lint-all         # Format, lint, and type check

Testing

make test             # Run unit tests (excluding integration)
make test-cov         # Run tests with coverage
make test-ci          # Run tests with coverage + XML/junit output for CI
make cov              # Run tests and generate coverage reports (xml, html)

Security

make security-bandit  # Run Bandit security scan
make security-audit   # Run pip-audit dependency vulnerability scan
make security         # Run all security scans

Other

make sync             # Sync project and install dependencies
make clean            # Clean build artifacts and caches

Coding guidelines

For code style, we recommend the PEP 8 style guide.

For docstrings we use Google format.

We use ruff for code formatting and static code analysis. Ruff checks various rules including flake8. The pre-commit hooks show errors which you need to fix before submitting a PR.

Last but not the least, we use type hints in our code which is then checked using mypy.

How to Contribute

We welcome contributions that extend the functionality of this project. Here are a few ways you can contribute:

Adding a New Dataset

  1. Create a new directory in src/dspy_opt (e.g., src/dspy_opt/new_dataset).
  2. Create the necessary files, following the structure of the existing dataset modules:
    • An indexing script (new_dataset_indexing.py).
    • A RAG module (new_dataset_rag_module.py).
    • Configuration files for different optimizers.
  3. Implement the pipeline logic in your RAG module, composing the shared utilities from src/dspy_opt/utils as needed.

Adding a New Utility

  1. Create a new dspy.Module in the src/dspy_opt/utils directory.
  2. Ensure it has a clear and well-defined responsibility.
  3. Add docstrings and type hints.
  4. Integrate the new module into one or more RAG pipelines to demonstrate its usage.

Experimenting with Different Models

To experiment with different language or embedding models, simply change the model names and API keys in the .yml configuration files for the relevant dataset.