Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/insert_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ def parameter_to_document(param):
}
]}

print(json.dumps(application))
print(json.dumps(application, indent=2))
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
/requirements-dev.txt
/requirements.txt

# converage file
# Generated documentation JSON
docs.json

# coverage file
cov.xml

.venv
Expand Down
115 changes: 101 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,46 @@

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

## Quick Start (Python + Poetry) 🚀

If you have Python 3.9+ installed, here's the fastest way to get started:

```bash
# 1. Clone the repository
git clone https://github.com/terminusdb/terminusdb-client-python.git
cd terminusdb-client-python

# 2. Create and activate a virtual environment with Python 3.9+
python3.9 -m venv .venv # or python3.10, python3.11, python3.12
source .venv/bin/activate # On Windows: .venv\Scripts\activate

# 3. Install Poetry (if not already installed)
pip install poetry

# 4. Install dependencies and set up development environment
poetry install --with dev

# 5. Install pre-commit hooks (optional, requires Python 3.10+)
# If you have Python 3.10+, you can install pre-commit:
# poetry add --group dev pre-commit && poetry run pre-commit install

# 6. Install the package in editable mode
poetry run dev install-dev

# 7. Start TerminusDB server (for integration tests)
docker run --pull always -d -p 127.0.0.1:6363:6363 -v terminusdb_storage:/app/terminusdb/storage --name terminusdb terminusdb/terminusdb-server:v12

# 8. Run tests to verify everything works
poetry run dev test

# 9. Get help with available commands
poetry run dev --help
```

**Important**: This project requires Python 3.9 or higher. If you're using Python 3.8, please upgrade to Python 3.9+ before proceeding.

That's it! You're now ready to start contributing. See [Poetry Scripts Reference](#poetry-scripts-reference-) for all available commands.

## Setting up dev environment 💻

Make sure you have Python>=3.9 and <3.13 installed.
Expand Down Expand Up @@ -57,35 +97,82 @@ For integration tests, you can either:

The test configuration will automatically detect and use an available server.

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.
**To run integration tests, Docker must be installed locally.**

To install the pre-commit hook:
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+):

`pre-commit install`
```bash
poetry add --group dev pre-commit
poetry run pre-commit install
```

## Writing tests and testing ✅

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

### Using Poetry Scripts (Recommended)

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.
```bash
# Format your code
poetry run dev format

# Run linting (read-only, just checks)
poetry run dev lint

# Run flake8 only
poetry run dev flake8

To run the unittests without integration tests:
# Fix linting issues automatically
poetry run dev lint-fix

`pytest terminusdb_client/tests/ --ignore=terminusdb_client/tests/integration_tests/`
# Run all tests
poetry run dev test-all

To run all tests including integration tests:
# Prepare your PR (runs format, lint, and all tests)
poetry run dev pr
```

`tox -e test`
### Using tox (Alternative)

To run all checks and auto formatting:
You can also use tox to run tests in an isolated environment:

`tox -e check`
```bash
# Run all tests
tox -e test

To run all tests and checks:
# Run all checks and auto formatting
tox -e check

`tox`
# Run everything
tox
```

**please make sure `tox` passes before making PR**
**Please make sure all tests pass before making a PR.**

## Poetry Scripts Reference 📋

The project includes a `dev` script that provides the following commands:

| Command | Description |
|--------|-------------|
| `poetry run dev init-dev` | Initialize development environment |
| `poetry run dev install-dev` | Install package in editable mode |
| `poetry run dev format` | Format code with black and ruff |
| `poetry run dev lint` | Run flake8 linting (read-only) |
| `poetry run dev lint-fix` | Run linting and fix issues automatically |
| `poetry run dev flake8` | Run flake8 linting only |
| `poetry run dev ruff` | Run ruff linting only |
| `poetry run dev check` | Run all static analysis checks |
| `poetry run dev test` | Run unit tests |
| `poetry run dev test-unit` | Run unit tests with coverage |
| `poetry run dev test-integration` | Run integration tests |
| `poetry run dev test-all` | Run all tests |
| `poetry run dev docs` | Build documentation |
| `poetry run dev tox` | Run tox for isolated testing |
| `poetry run dev clean` | Clean build artifacts |
| `poetry run dev pr` | Run all PR preparation checks |

Run `poetry run dev --help` to see all available commands.

## Writing Documentation 📖

Expand Down
Loading