|
2 | 2 |
|
3 | 3 | Thanks for interested to contribute to TerminusDB Client, to get started, fork this repo and follow the [instruction setting up dev environment](#setting-up-dev-environment-). If you don't have idea where to start, you can look for [`good first issue`](https://github.com/terminusdb/terminusdb-client-python/contribute) or [`help wanted`](https://github.com/terminusdb/terminusdb-client-python/issues?q=is:open+is:issue+label:"help+wanted") label at issues. All pull request should follow the [Pull Request Format Guideline](#pull-request-format-guideline-) and pull request (PR) that involving coding should come with [tests](#writing-tests-and-testing-) and [documentations](#writing-documentation-). |
4 | 4 |
|
| 5 | +## Quick Start (Python + Poetry) 🚀 |
| 6 | + |
| 7 | +If you have Python 3.9+ installed, here's the fastest way to get started: |
| 8 | + |
| 9 | +```bash |
| 10 | +# 1. Clone the repository |
| 11 | +git clone https://github.com/terminusdb/terminusdb-client-python.git |
| 12 | +cd terminusdb-client-python |
| 13 | + |
| 14 | +# 2. Create and activate a virtual environment with Python 3.9+ |
| 15 | +python3.9 -m venv .venv # or python3.10, python3.11, python3.12 |
| 16 | +source .venv/bin/activate # On Windows: .venv\Scripts\activate |
| 17 | + |
| 18 | +# 3. Install Poetry (if not already installed) |
| 19 | +pip install poetry |
| 20 | + |
| 21 | +# 4. Install dependencies and set up development environment |
| 22 | +poetry install --with dev |
| 23 | + |
| 24 | +# 5. Install pre-commit hooks (optional, requires Python 3.10+) |
| 25 | +# If you have Python 3.10+, you can install pre-commit: |
| 26 | +# poetry add --group dev pre-commit && poetry run pre-commit install |
| 27 | + |
| 28 | +# 6. Install the package in editable mode |
| 29 | +poetry run dev install-dev |
| 30 | + |
| 31 | +# 7. Start TerminusDB server (for integration tests) |
| 32 | +docker run --pull always -d -p 127.0.0.1:6363:6363 -v terminusdb_storage:/app/terminusdb/storage --name terminusdb terminusdb/terminusdb-server:v12 |
| 33 | + |
| 34 | +# 8. Run tests to verify everything works |
| 35 | +poetry run dev test |
| 36 | + |
| 37 | +# 9. Get help with available commands |
| 38 | +poetry run dev --help |
| 39 | +``` |
| 40 | + |
| 41 | +**Important**: This project requires Python 3.9 or higher. If you're using Python 3.8, please upgrade to Python 3.9+ before proceeding. |
| 42 | + |
| 43 | +That's it! You're now ready to start contributing. See [Poetry Scripts Reference](#poetry-scripts-reference-) for all available commands. |
| 44 | + |
5 | 45 | ## Setting up dev environment 💻 |
6 | 46 |
|
7 | 47 | Make sure you have Python>=3.9 and <3.13 installed. |
@@ -57,35 +97,82 @@ For integration tests, you can either: |
57 | 97 |
|
58 | 98 | The test configuration will automatically detect and use an available server. |
59 | 99 |
|
60 | | -We use [shed](https://pypi.org/project/shed/) to lint our code. Although you can do it manually by running `shed`, we highly recommend setting up the pre-commit hook to do the linting automatically. |
| 100 | +**To run integration tests, Docker must be installed locally.** |
61 | 101 |
|
62 | | -To install the pre-commit hook: |
| 102 | +We use [shed](https://pypi.org/project/shed/) to lint our code. You can run it manually with `poetry run dev lint`, or set up a pre-commit hook (requires Python 3.10+): |
63 | 103 |
|
64 | | -`pre-commit install` |
| 104 | +```bash |
| 105 | +poetry add --group dev pre-commit |
| 106 | +poetry run pre-commit install |
| 107 | +``` |
65 | 108 |
|
66 | 109 | ## Writing tests and testing ✅ |
67 | 110 |
|
68 | | -We are using [pytest](https://docs.pytest.org/en/latest/) for testing. All tests are stored in `/tests` |
| 111 | +We are using [pytest](https://docs.pytest.org/en/latest/) for testing. All tests are stored in `terminusdb_client/tests/`. |
| 112 | + |
| 113 | +### Using Poetry Scripts (Recommended) |
69 | 114 |
|
70 | | -We also use tox to run tests in a virtual environment, we recommend running `tox` for the first time before you make any changes. This is to initialize the tox environments (or do it separately by `tox -e deps`) and make sure all tests pass initially. |
| 115 | +```bash |
| 116 | +# Format your code |
| 117 | +poetry run dev format |
| 118 | + |
| 119 | +# Run linting (read-only, just checks) |
| 120 | +poetry run dev lint |
| 121 | + |
| 122 | +# Run flake8 only |
| 123 | +poetry run dev flake8 |
71 | 124 |
|
72 | | -To run the unittests without integration tests: |
| 125 | +# Fix linting issues automatically |
| 126 | +poetry run dev lint-fix |
73 | 127 |
|
74 | | -`pytest terminusdb_client/tests/ --ignore=terminusdb_client/tests/integration_tests/` |
| 128 | +# Run all tests |
| 129 | +poetry run dev test-all |
75 | 130 |
|
76 | | -To run all tests including integration tests: |
| 131 | +# Prepare your PR (runs format, lint, and all tests) |
| 132 | +poetry run dev pr |
| 133 | +``` |
77 | 134 |
|
78 | | -`tox -e test` |
| 135 | +### Using tox (Alternative) |
79 | 136 |
|
80 | | -To run all checks and auto formatting: |
| 137 | +You can also use tox to run tests in an isolated environment: |
81 | 138 |
|
82 | | -`tox -e check` |
| 139 | +```bash |
| 140 | +# Run all tests |
| 141 | +tox -e test |
83 | 142 |
|
84 | | -To run all tests and checks: |
| 143 | +# Run all checks and auto formatting |
| 144 | +tox -e check |
85 | 145 |
|
86 | | -`tox` |
| 146 | +# Run everything |
| 147 | +tox |
| 148 | +``` |
87 | 149 |
|
88 | | -**please make sure `tox` passes before making PR** |
| 150 | +**Please make sure all tests pass before making a PR.** |
| 151 | + |
| 152 | +## Poetry Scripts Reference 📋 |
| 153 | + |
| 154 | +The project includes a `dev` script that provides the following commands: |
| 155 | + |
| 156 | +| Command | Description | |
| 157 | +|--------|-------------| |
| 158 | +| `poetry run dev init-dev` | Initialize development environment | |
| 159 | +| `poetry run dev install-dev` | Install package in editable mode | |
| 160 | +| `poetry run dev format` | Format code with black and ruff | |
| 161 | +| `poetry run dev lint` | Run flake8 linting (read-only) | |
| 162 | +| `poetry run dev lint-fix` | Run linting and fix issues automatically | |
| 163 | +| `poetry run dev flake8` | Run flake8 linting only | |
| 164 | +| `poetry run dev ruff` | Run ruff linting only | |
| 165 | +| `poetry run dev check` | Run all static analysis checks | |
| 166 | +| `poetry run dev test` | Run unit tests | |
| 167 | +| `poetry run dev test-unit` | Run unit tests with coverage | |
| 168 | +| `poetry run dev test-integration` | Run integration tests | |
| 169 | +| `poetry run dev test-all` | Run all tests | |
| 170 | +| `poetry run dev docs` | Build documentation | |
| 171 | +| `poetry run dev tox` | Run tox for isolated testing | |
| 172 | +| `poetry run dev clean` | Clean build artifacts | |
| 173 | +| `poetry run dev pr` | Run all PR preparation checks | |
| 174 | + |
| 175 | +Run `poetry run dev --help` to see all available commands. |
89 | 176 |
|
90 | 177 | ## Writing Documentation 📖 |
91 | 178 |
|
|
0 commit comments