Skip to content

Commit d828905

Browse files
committed
Make it easier to contribute
1 parent c855139 commit d828905

5 files changed

Lines changed: 1893 additions & 705 deletions

File tree

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,14 @@
22
/requirements-dev.txt
33
/requirements.txt
44

5-
# converage file
5+
# Generated documentation JSON
6+
docs.json
7+
8+
# coverage file
69
cov.xml
710

11+
.venv
12+
813
.mypy_cache/
914

1015
.pytest_cache/

CONTRIBUTING.md

Lines changed: 114 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,51 +2,143 @@
22

33
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-).
44

5-
## Setting up dev environment 💻
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. Run tests to verify everything works
32+
poetry run dev test
33+
34+
# 8. Get help with available commands
35+
poetry run dev --help
36+
```
37+
38+
**Important**: This project requires Python 3.9 or higher. If you're using Python 3.8, please upgrade to Python 3.9+ before proceeding.
639

7-
Make sure you have Python>=3.9 installed. We use [pipenv](https://pipenv-fork.readthedocs.io/en/latest/) for dev environment, to install pipenv:
40+
That's it! You're now ready to start contributing. See [Poetry Scripts Reference](#poetry-scripts-reference-) for all available commands.
841

9-
`pip3 install pipenv --upgrade`
42+
## Setting up dev environment 💻
1043

11-
[Fork and clone](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) this repo, then in your local repo:
44+
Make sure you have Python>=3.9 installed. We use [Poetry](https://python-poetry.org/) for dependency management.
1245

13-
`pipenv install --dev --pre` or `make init`
46+
### Using Poetry (Recommended)
1447

15-
To “editable” install the local Terminus Client Python:
48+
1. [Fork and clone](https://help.github.com/en/github/getting-started-with-github/fork-a-repo) this repo
1649

17-
`pip3 install -e .`
50+
2. Create and activate a virtual environment:
51+
```bash
52+
python3 -m venv .venv
53+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
54+
```
1855

19-
**to be able to run integration tests, local installation of docker is required**
56+
3. Install Poetry and dependencies:
57+
```bash
58+
pip install poetry
59+
poetry install --with dev
60+
```
2061

21-
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.
62+
4. Install the package in editable mode:
63+
```bash
64+
poetry run dev install-dev
65+
```
2266

23-
To install the pre-commit hook:
67+
**To run integration tests, Docker must be installed locally.**
2468

25-
`pre-commit install`
69+
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+):
70+
71+
```bash
72+
poetry add --group dev pre-commit
73+
poetry run pre-commit install
74+
```
2675

2776
## Writing tests and testing ✅
2877

29-
We are using [pytest](https://docs.pytest.org/en/latest/) for testing. All tests are stored in `/tests`
78+
We are using [pytest](https://docs.pytest.org/en/latest/) for testing. All tests are stored in `terminusdb_client/tests/`.
3079

31-
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.
80+
### Using Poetry Scripts (Recommended)
3281

33-
To run the unittests without integration tests:
82+
```bash
83+
# Format your code
84+
poetry run dev format
3485

35-
`pytest terminusdb_client/tests/ --ignore=terminusdb_client/tests/integration_tests/`
86+
# Run linting (read-only, just checks)
87+
poetry run dev lint
3688

37-
To run all tests including integration tests:
89+
# Run flake8 only
90+
poetry run dev flake8
3891

39-
`tox -e test`
92+
# Fix linting issues automatically
93+
poetry run dev lint-fix
4094

41-
To run all checks and auto formatting:
95+
# Run all tests
96+
poetry run dev test-all
4297

43-
`tox -e check`
98+
# Prepare your PR (runs format, lint, and all tests)
99+
poetry run dev pr
100+
```
101+
102+
### Using tox (Alternative)
103+
104+
You can also use tox to run tests in an isolated environment:
44105

45-
To run all tests and checks:
106+
```bash
107+
# Run all tests
108+
tox -e test
46109

47-
`tox`
110+
# Run all checks and auto formatting
111+
tox -e check
112+
113+
# Run everything
114+
tox
115+
```
48116

49-
**please make sure `tox` passes before making PR**
117+
**Please make sure all tests pass before making a PR.**
118+
119+
## Poetry Scripts Reference 📋
120+
121+
The project includes a `dev` script that provides the following commands:
122+
123+
| Command | Description |
124+
|--------|-------------|
125+
| `poetry run dev init-dev` | Initialize development environment |
126+
| `poetry run dev install-dev` | Install package in editable mode |
127+
| `poetry run dev format` | Format code with shed |
128+
| `poetry run dev lint` | Run linting checks (read-only) |
129+
| `poetry run dev lint-fix` | Run linting and fix issues automatically |
130+
| `poetry run dev flake8` | Run flake8 linting only |
131+
| `poetry run dev check` | Run all static analysis checks |
132+
| `poetry run dev test` | Run unit tests |
133+
| `poetry run dev test-unit` | Run unit tests with coverage |
134+
| `poetry run dev test-integration` | Run integration tests |
135+
| `poetry run dev test-all` | Run all tests |
136+
| `poetry run dev docs` | Build documentation |
137+
| `poetry run dev tox` | Run tox for isolated testing |
138+
| `poetry run dev clean` | Clean build artifacts |
139+
| `poetry run dev pr` | Run all PR preparation checks |
140+
141+
Run `poetry run dev --help` to see all available commands.
50142

51143
## Writing Documentation 📖
52144

0 commit comments

Comments
 (0)