|
1 | 1 | # Contributing Guidelines |
2 | 2 |
|
3 | | -Thank you for your interest in contributing to MindSQL! Your contributions help improve the project for everyone. Before you get started, please take a moment to review these guidelines to ensure a smooth collaboration process. |
| 3 | +Thank you for your interest in contributing to the MariaDB Vector Store integration for MindSQL! |
4 | 4 |
|
5 | | -## Getting Started |
| 5 | +## Quick Setup |
6 | 6 |
|
7 | | -1. **Fork the Repository**: Fork the MindSQL repository to your own GitHub account. |
| 7 | +```bash |
| 8 | +# Fork and clone |
| 9 | +git clone https://github.com/YOUR_USERNAME/MindSQL.git |
| 10 | +cd MindSQL |
8 | 11 |
|
9 | | -2. **Clone the Repository**: Clone your fork of the repository locally onto your machine. |
| 12 | +# Setup environment |
| 13 | +python -m venv venv |
| 14 | +source venv/bin/activate # Windows: venv\Scripts\activate |
10 | 15 |
|
11 | | - ```bash |
12 | | - git clone https://github.com/{YourUsername}/MindSQL.git |
13 | | - ``` |
| 16 | +# Install dependencies |
| 17 | +pip install -r requirements_demo.txt |
| 18 | +pip install mariadb pytest black flake8 |
14 | 19 |
|
15 | | -3. **Create a Branch**: Create a new branch for your work based on the `master` branch. |
| 20 | +# Setup test database |
| 21 | +mysql -u root -p |
| 22 | +CREATE DATABASE mindsql_test; |
| 23 | +CREATE USER 'mindsql_test'@'localhost' IDENTIFIED BY 'test_password'; |
| 24 | +GRANT ALL PRIVILEGES ON mindsql_test.* TO 'mindsql_test'@'localhost'; |
16 | 25 |
|
17 | | - ```bash |
18 | | - git checkout -b your-branch-name master |
19 | | - ``` |
| 26 | +# Verify |
| 27 | +pytest tests/ -v |
| 28 | +``` |
20 | 29 |
|
21 | | -## Making Changes |
| 30 | +--- |
22 | 31 |
|
23 | | -1. **Adhere to Coding Standards**: Make sure your code follows the PEP8 coding standards and conventions used in the project. Consistency makes maintenance easier for everyone. |
| 32 | +## Coding Standards |
24 | 33 |
|
25 | | -2. **Test Your Changes**: Thoroughly test your changes to ensure they work as intended. Add a test case in the `tests` folder to cover your changes if applicable. |
| 34 | +### PEP 8 Compliance |
26 | 35 |
|
27 | | -## Submitting Changes |
| 36 | +```python |
| 37 | +# 4 spaces, max 100 chars, type hints required |
28 | 38 |
|
29 | | -1. **Commit Your Changes**: Once you've made your changes, commit them to your branch with clear and descriptive commit messages. |
| 39 | +def process_query(question: str, n_results: int = 5) -> List[str]: |
| 40 | + """ |
| 41 | + Brief description. |
| 42 | + |
| 43 | + Args: |
| 44 | + question: Description |
| 45 | + n_results: Description |
| 46 | + |
| 47 | + Returns: |
| 48 | + Description |
| 49 | + """ |
| 50 | + return results |
| 51 | +``` |
30 | 52 |
|
31 | | - ```bash |
32 | | - git commit -am 'Add descriptive commit message' |
33 | | - ``` |
| 53 | +### Naming Conventions |
34 | 54 |
|
35 | | -2. **Push Your Changes**: Push your changes to your fork on GitHub. |
| 55 | +- Classes: `PascalCase` |
| 56 | +- Functions/variables: `snake_case` |
| 57 | +- Constants: `UPPER_CASE` |
| 58 | +- Private methods: `_leading_underscore` |
36 | 59 |
|
37 | | - ```bash |
38 | | - git push origin your-branch-name |
39 | | - ``` |
| 60 | +### Code Quality |
40 | 61 |
|
41 | | -3. **Submit a Pull Request**: Go to the MindSQL repository on GitHub and submit a pull request from your branch to the `master` branch. Be sure to include a clear description of the problem you're solving and the solution you're proposing. |
| 62 | +```bash |
| 63 | +# Format and lint |
| 64 | +black mindsql/ tests/ |
| 65 | +flake8 mindsql/ tests/ --max-line-length=100 |
42 | 66 |
|
43 | | -## Code of Conduct |
| 67 | +# Before commit |
| 68 | +pytest tests/ -v && black --check mindsql/ tests/ && flake8 mindsql/ tests/ |
| 69 | +``` |
44 | 70 |
|
45 | | -Please note that MindSQL has a [Code of Conduct](./CODE_OF_CONDUCT.md). By participating in this project, you agree to abide by its terms. |
| 71 | +--- |
46 | 72 |
|
47 | | -## Need Help? |
| 73 | +## Testing |
48 | 74 |
|
49 | | -If you need any assistance or have questions about contributing, feel free to reach out to us via GitHub issues or email. |
| 75 | +### Writing Tests |
50 | 76 |
|
51 | | -We appreciate your contributions to MindSQL and thank you for helping make it better! |
| 77 | +```python |
| 78 | +import pytest |
| 79 | +from mindsql.vectorstores import MariaDBVectorStore |
| 80 | + |
| 81 | +class TestMariaDBVectorStore: |
| 82 | + @pytest.fixture |
| 83 | + def vectorstore(self): |
| 84 | + config = {'host': 'localhost', 'user': 'mindsql_test', 'password': 'test_password'} |
| 85 | + return MariaDBVectorStore(config=config) |
| 86 | + |
| 87 | + def test_add_ddl(self, vectorstore): |
| 88 | + result = vectorstore.add_ddl("CREATE TABLE users (id INT);") |
| 89 | + assert "Successfully" in result |
| 90 | +``` |
| 91 | + |
| 92 | +### Running Tests |
| 93 | + |
| 94 | +```bash |
| 95 | +pytest tests/ -v # All tests |
| 96 | +pytest tests/ --cov=mindsql -v # With coverage |
| 97 | +pytest tests/test_file.py::test_name -v # Specific test |
| 98 | +``` |
| 99 | + |
| 100 | +**Requirements:** |
| 101 | +- New features: 80% coverage minimum |
| 102 | +- Bug fixes: Include test reproducing bug |
| 103 | +- All public methods tested |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## Pull Request Process |
| 108 | + |
| 109 | +### Workflow |
| 110 | + |
| 111 | +```bash |
| 112 | +# 1. Create branch |
| 113 | +git checkout -b feature/your-feature |
| 114 | + |
| 115 | +# 2. Make changes |
| 116 | +# Edit code, add tests, update docs |
| 117 | + |
| 118 | +# 3. Test and format |
| 119 | +pytest tests/ -v |
| 120 | +black mindsql/ tests/ |
| 121 | +flake8 mindsql/ tests/ |
| 122 | + |
| 123 | +# 4. Commit with proper message |
| 124 | +git add . |
| 125 | +git commit -m "feat: add batch processing support" |
| 126 | + |
| 127 | +# 5. Push and create PR |
| 128 | +git push origin feature/your-feature |
| 129 | +``` |
| 130 | + |
| 131 | +### Commit Message Format |
| 132 | + |
| 133 | +``` |
| 134 | +<type>: <short description> |
| 135 | +
|
| 136 | +[Optional longer description] |
| 137 | +
|
| 138 | +[Optional footer: Closes #123] |
| 139 | +``` |
| 140 | + |
| 141 | +**Types:** |
| 142 | +- `feat`: New feature |
| 143 | +- `fix`: Bug fix |
| 144 | +- `docs`: Documentation |
| 145 | +- `test`: Tests |
| 146 | +- `refactor`: Code refactoring |
| 147 | + |
| 148 | +**Examples:** |
| 149 | +``` |
| 150 | +feat: add batch embedding support |
| 151 | +
|
| 152 | +fix: resolve connection timeout issue |
| 153 | +
|
| 154 | +docs: update API reference for retrieve_ddl |
| 155 | +``` |
| 156 | + |
| 157 | +### PR Checklist |
| 158 | + |
| 159 | +- [ ] Code follows PEP 8 |
| 160 | +- [ ] Tests pass (`pytest tests/ -v`) |
| 161 | +- [ ] Code formatted (`black mindsql/ tests/`) |
| 162 | +- [ ] Documentation updated |
| 163 | +- [ ] No breaking changes (or documented) |
| 164 | + |
| 165 | +--- |
| 166 | + |
| 167 | +## Issue Reporting |
| 168 | + |
| 169 | +### Bug Report Template |
| 170 | + |
| 171 | +```markdown |
| 172 | +**Description:** Brief bug description |
| 173 | + |
| 174 | +**Steps to Reproduce:** |
| 175 | +1. Step one |
| 176 | +2. Step two |
| 177 | + |
| 178 | +**Expected:** What should happen |
| 179 | +**Actual:** What actually happens |
| 180 | + |
| 181 | +**Environment:** |
| 182 | +- Python: 3.11.6 |
| 183 | +- MariaDB: 10.11.5 |
| 184 | +- OS: Ubuntu 22.04 |
| 185 | + |
| 186 | +**Error:** |
| 187 | +``` |
| 188 | +[Paste error message] |
| 189 | +``` |
| 190 | +``` |
| 191 | + |
| 192 | +### Feature Request Template |
| 193 | + |
| 194 | +```markdown |
| 195 | +**Description:** What feature you want |
| 196 | + |
| 197 | +**Use Case:** Why it's needed |
| 198 | + |
| 199 | +**Proposed Solution:** How it could work |
| 200 | +``` |
| 201 | + |
| 202 | +--- |
| 203 | + |
| 204 | +## Development Best Practices |
| 205 | + |
| 206 | +### Code Quality |
| 207 | + |
| 208 | +- Keep functions small and focused |
| 209 | +- Use meaningful names |
| 210 | +- Add docstrings to public methods |
| 211 | +- Handle errors gracefully |
| 212 | +- Follow DRY principle |
| 213 | + |
| 214 | +### Testing |
| 215 | + |
| 216 | +- Test edge cases and errors |
| 217 | +- Use descriptive test names |
| 218 | +- Keep tests independent |
| 219 | +- Mock external dependencies |
| 220 | + |
| 221 | +### Security |
| 222 | + |
| 223 | +- Never commit credentials (use environment variables) |
| 224 | +- Validate all inputs |
| 225 | +- Use parameterized queries |
| 226 | +- Keep dependencies updated |
| 227 | + |
| 228 | +### Documentation |
| 229 | + |
| 230 | +When adding features: |
| 231 | +- Update README.md |
| 232 | +- Add usage examples |
| 233 | +- Update API reference |
| 234 | +- Add docstrings |
| 235 | + |
| 236 | +--- |
| 237 | + |
| 238 | +## Code Review Guidelines |
| 239 | + |
| 240 | +### For Contributors |
| 241 | + |
| 242 | +- Keep PRs small and focused |
| 243 | +- Write clear descriptions |
| 244 | +- Respond to feedback promptly |
| 245 | +- Be open to suggestions |
| 246 | + |
| 247 | +### For Reviewers |
| 248 | + |
| 249 | +- Be constructive and specific |
| 250 | +- Explain the "why" |
| 251 | +- Focus on code, not person |
| 252 | +- Acknowledge good work |
| 253 | + |
| 254 | +--- |
| 255 | + |
| 256 | +## Getting Help |
| 257 | + |
| 258 | +- Check documentation first |
| 259 | +- Search existing issues |
| 260 | +- Open new issue with details |
| 261 | +- Ask in GitHub Discussions |
| 262 | + |
| 263 | +--- |
| 264 | + |
| 265 | +## Resources |
| 266 | + |
| 267 | +**Documentation:** |
| 268 | +- [MariaDB VECTOR](https://mariadb.com/kb/en/vector-data-type/) |
| 269 | +- [MindSQL Project](https://github.com/Mindinventory/MindSQL) |
| 270 | +- [Python PEP 8](https://pep8.org/) |
| 271 | + |
| 272 | +**Tools:** |
| 273 | +- [pytest](https://docs.pytest.org/) |
| 274 | +- [black](https://black.readthedocs.io/) |
| 275 | +- [MariaDB Connector](https://mariadb.com/docs/appdev/connector-python/) |
| 276 | + |
| 277 | +--- |
| 278 | + |
| 279 | +Thank you for contributing! |
| 280 | + |
| 281 | +**Version:** 1.0.0 |
0 commit comments