|
| 1 | +# Contributing to SQLDeps |
| 2 | + |
| 3 | +Thank you for considering contributing to SQLDeps! This guide explains how to set up your development environment and contribute to the project. |
| 4 | + |
| 5 | +## Questions and Discussion |
| 6 | + |
| 7 | +For questions or discussions, please check [SQLDeps Discussions](https://github.com/glue-lab/sqldeps/discussions) or reach out to the maintainers directly. |
| 8 | + |
| 9 | +## Development Setup |
| 10 | + |
| 11 | +### Prerequisites |
| 12 | + |
| 13 | +- [Git](https://git-scm.com/) |
| 14 | +- [UV](https://docs.astral.sh/uv/) |
| 15 | + |
| 16 | +### Clone the Repository |
| 17 | + |
| 18 | +```bash |
| 19 | +git clone https://github.com/glue-lab/sqldeps.git |
| 20 | +cd sqldeps |
| 21 | +``` |
| 22 | + |
| 23 | +### Install Development Dependencies |
| 24 | + |
| 25 | +SQLDeps uses [`uv`](https://github.com/astral-sh/uv) as the package manager for development. |
| 26 | + |
| 27 | +After installing UV, run: |
| 28 | + |
| 29 | +```bash |
| 30 | +uv sync |
| 31 | +``` |
| 32 | + |
| 33 | +This will create a virtual environment with the correct Python version and all the required dependencies, including: |
| 34 | + |
| 35 | +- Core dependencies |
| 36 | +- Development tools (`pytest`, `ruff`, etc.) |
| 37 | +- Documentation tools (`mkdocs`, etc.) |
| 38 | + |
| 39 | +### Environment Variables |
| 40 | + |
| 41 | +Create a `.env` file in the project root with your API keys: |
| 42 | + |
| 43 | +``` |
| 44 | +# LLM API Keys |
| 45 | +GROQ_API_KEY=your_groq_api_key |
| 46 | +OPENAI_API_KEY=your_openai_api_key |
| 47 | +DEEPSEEK_API_KEY=your_deepseek_api_key |
| 48 | +``` |
| 49 | + |
| 50 | +For instance, [Groq](https://console.groq.com/keys) offers free tokens without requiring payment details, making it ideal for contributions. |
| 51 | + |
| 52 | +## Development Workflow |
| 53 | + |
| 54 | +### Code Style |
| 55 | + |
| 56 | +SQLDeps uses Ruff for code formatting and linting: |
| 57 | + |
| 58 | +```bash |
| 59 | +# Format code |
| 60 | +uv run ruff format . |
| 61 | + |
| 62 | +# Fix linting issues |
| 63 | +uv run ruff check . --fix |
| 64 | +``` |
| 65 | + |
| 66 | +Alternatively, you can easily check and apply formatting and linting with `make`: |
| 67 | + |
| 68 | +```bash |
| 69 | +# Check code style without fixing |
| 70 | +make check |
| 71 | + |
| 72 | +# Apply fixes |
| 73 | +make fix |
| 74 | +``` |
| 75 | + |
| 76 | +### Running Tests |
| 77 | + |
| 78 | +The test suite is set up with markers to allow selective testing: |
| 79 | + |
| 80 | +```bash |
| 81 | +# Run all tests except those marked as 'llm' or 'integration' |
| 82 | +# This is the default when running pytest without arguments |
| 83 | +uv run pytest |
| 84 | + |
| 85 | +# Run tests with a specific marker |
| 86 | +uv run pytest -m llm # Run LLM-dependent tests (requires API keys) |
| 87 | +uv run pytest -m integration # Run integration tests (requires database) |
| 88 | + |
| 89 | +# Run tests with a specific framework |
| 90 | +uv run pytest --framework=groq |
| 91 | + |
| 92 | +# Run specific test files |
| 93 | +uv run pytest tests/unit/test_models.py |
| 94 | + |
| 95 | +# Run with coverage report |
| 96 | +uv run pytest --cov=sqldeps |
| 97 | +``` |
| 98 | + |
| 99 | +Note that by default tests marked with `llm` and `integration` are skipped to avoid requiring external dependencies during CI/CD. These tests require valid API keys and/or database connections. |
| 100 | + |
| 101 | +### Building Documentation |
| 102 | + |
| 103 | +```bash |
| 104 | +# Build and serve documentation locally |
| 105 | +uv run mkdocs serve |
| 106 | +``` |
| 107 | + |
| 108 | +This will start a local server at `http://127.0.0.1:8000` where you can preview the documentation. |
| 109 | + |
| 110 | +## Project Structure |
| 111 | + |
| 112 | +Here's the simplified project structure: |
| 113 | + |
| 114 | +``` |
| 115 | +sqldeps/ |
| 116 | +├── .github/ # GitHub configuration files |
| 117 | +├── configs/ # External configuration files for experiments |
| 118 | +├── docs/ # Documentation files |
| 119 | +├── sqldeps/ # Main package source code |
| 120 | +│ ├── app/ # Streamlit web application |
| 121 | +│ ├── database/ # Database connector implementations |
| 122 | +│ ├── llm_parsers/ # LLM integration for SQL parsing |
| 123 | +│ └── ... # Other core modules |
| 124 | +└── tests/ # Test suite |
| 125 | +``` |
| 126 | + |
| 127 | +## Adding Features |
| 128 | + |
| 129 | +### Adding a New LLM Provider |
| 130 | + |
| 131 | +1. Create a new file in `sqldeps/llm_parsers/` following the pattern of existing providers |
| 132 | +2. Implement the required methods from `BaseSQLExtractor` |
| 133 | +3. Add the new provider to `__init__.py` and the `DEFAULTS` dictionary |
| 134 | +4. Add tests in `tests/` (both unit and functional tests) |
| 135 | + |
| 136 | +### Adding Database Support |
| 137 | + |
| 138 | +1. Create a new file in `sqldeps/database/` following the pattern of existing connectors |
| 139 | +2. Implement the required methods from `SQLBaseConnector` |
| 140 | +3. Add the new connector to `__init__.py` |
| 141 | +4. Add tests in `tests/` (both unit and integration tests) |
| 142 | + |
| 143 | +## Pull Request Process |
| 144 | + |
| 145 | +1. Fork the repository |
| 146 | +2. Create a new branch for your feature or bug fix |
| 147 | +3. Make your changes and add tests |
| 148 | +4. Run the tests and linting checks |
| 149 | +5. Update documentation if necessary |
| 150 | +6. Submit a pull request to the `main` branch |
| 151 | + |
| 152 | +## Package Versioning |
| 153 | + |
| 154 | +SQLDeps follows [Semantic Versioning](https://semver.org/): |
| 155 | + |
| 156 | +- **MAJOR** version when making incompatible API changes |
| 157 | +- **MINOR** version when adding functionality in a backward-compatible manner |
| 158 | +- **PATCH** version when making backward-compatible bug fixes |
| 159 | + |
| 160 | +## Code of Conduct |
| 161 | + |
| 162 | +Please be respectful and inclusive when contributing to SQLDeps. We strive to maintain a welcoming environment for all contributors. |
| 163 | + |
| 164 | +## License |
| 165 | + |
| 166 | +By contributing to SQLDeps, you agree that your contributions will be licensed under the project's MIT License. |
0 commit comments