Skip to content

Commit 7dfa7a1

Browse files
Merge pull request #284 from tigergraph/release_2.0.1
Release 2.0.1
2 parents f2b8947 + 2538c72 commit 7dfa7a1

78 files changed

Lines changed: 3230 additions & 12694 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,116 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.0.1] - 2026-03-23
9+
10+
### Breaking Changes
11+
12+
- **`showSecrets()` removed.** Use `getSecrets()` instead.
13+
- **`runInstalledQuery()` now auto-selects GET or POST** based on `params` type (`dict` → POST, `str` → GET). Passing a raw query string with `usePost=True` raises `TigerGraphException`.
14+
- **MCP tools moved to [`pytigergraph-mcp`](https://github.com/tigergraph/pytigergraph-mcp).** Do not import from `pyTigerGraph.mcp` directly.
15+
16+
### New Features
17+
18+
- **Unified vertex parameter syntax for `runInstalledQuery()`.** Use `(id,)` for `VERTEX<T>`, `(id, "type")` for untyped `VERTEX`, and lists of tuples for sets. Works identically for both GET and POST.
19+
- **MAP parameter support.** Pass a Python `dict` for a `MAP` query parameter; it is converted to TigerGraph's wire format automatically.
20+
- **`getVectorIndexStatus()`** — poll vector index build status without writing raw GSQL.
21+
- **`runSchemaChange()`** — run GSQL DDL as a schema-change job via a single API call.
22+
- **Data-source management APIs**`createDataSource()`, `updateDataSource()`, `getDataSource()`, `getDataSources()`, `dropDataSource()`, `dropAllDataSources()`.
23+
- **Improved performance for parallel workloads.** Sync connections use per-thread HTTP sessions; async connections use `aiohttp`. Both reduce contention and improve throughput under concurrent load.
24+
- **TigerGraph 3.x compatibility.** Queries, loading jobs, and schema operations automatically fall back to 3.x `gsqlserver` endpoints, so the same client code works on both 3.x and 4.x.
25+
26+
### Fixed
27+
28+
- **Edge upsert `vertexMustExist`** flag now correctly forwarded to TigerGraph in all code paths.
29+
- **Edge upsert attribute payloads** serialized correctly for all attribute types.
30+
31+
---
32+
33+
## [2.0.0] - 2025-03-04
34+
35+
### Added
36+
37+
- **MCP (Model Context Protocol) tools.** pyTigerGraph now ships with built-in MCP tool definitions, enabling integration with MCP-compatible AI frameworks.
38+
39+
---
40+
41+
## [1.9.1] - 2024-11-04
42+
43+
### Changed
44+
45+
- API enhancements.
46+
47+
---
48+
49+
## [1.9.0] - 2025-06-30
50+
51+
### Changed
52+
53+
- Multiple API enhancements.
54+
55+
---
56+
57+
## [1.8.4] - 2025-01-20
58+
59+
### Fixed
60+
61+
- Fixed URL construction when `gsPort` and `restppPort` are set to the same value.
62+
63+
---
64+
65+
## [1.8.3] - 2024-12-04
66+
67+
### Fixed
68+
69+
- Fixed `httpx` timeout during async function calls, most notably when installing a query via `.gsql()`.
70+
71+
---
72+
73+
## [1.8.1] - 2024-11-19
74+
75+
### Fixed
76+
77+
- Fixed import error of `TigerGraphException` in the GDS submodule.
78+
79+
---
80+
81+
## [1.8.0] - 2024-11-04
82+
83+
### Added
84+
85+
- **`AsyncTigerGraphConnection`** — full async communication with TigerGraph using the new `AsyncTigerGraphConnection` class.
86+
- **`delVerticesByType()`** — delete all vertices of a given type in one call.
87+
- **`limit` parameter for `getEdgesByType()`** — cap the number of edges returned. Note: the limit is applied client-side after retrieval.
88+
- **Upsert atomicity configuration** — new parameters to control atomicity behaviour of upsert operations.
89+
- **`runLoadingJobWithDataFrame()`** — run a GSQL loading job directly from a Pandas DataFrame.
90+
- **`runLoadingJobWithData()`** — run a GSQL loading job from a raw data string.
91+
92+
---
93+
94+
## [1.7.4] - 2024-10-16
95+
96+
### Fixed
97+
98+
- Fixed error when generating a token via `getToken()` with a secret key.
99+
100+
---
101+
102+
## [1.7.3] - 2024-10-14
103+
104+
### Fixed
105+
106+
- Fixed error when generating a token via `getToken()` on TigerGraph Cloud v3.x instances.
107+
108+
---
109+
110+
## [1.7.2] - 2024-10-01
111+
112+
### Added
113+
114+
- **`delVerticesByType()`** — delete all vertices of a specified type. Supports `permanent` (prevent re-insertion of the same IDs) and `ack` (`"all"` or `"none"`) parameters.
115+
116+
---
117+
8118
## [1.1] - 2022-09-06
9119

10120
Release of pyTigerGraph version 1.1.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
same "printed page" as the copyright notice for easier
187187
identification within third-party archives.
188188

189-
Copyright 2022 TigerGraph Inc.
189+
Copyright 2022-2026 TigerGraph Inc.
190190

191191
Licensed under the Apache License, Version 2.0 (the "License");
192192
you may not use this file except in compliance with the License.

README.md

Lines changed: 205 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,233 @@
11
# pyTigerGraph
22

3-
pyTigerGraph is a Python package for connecting to TigerGraph databases. Check out the documentation [here](https://docs.tigergraph.com/pytigergraph/current/intro/).
3+
pyTigerGraph is a Python client for [TigerGraph](https://www.tigergraph.com/) databases. It wraps the REST++ and GSQL APIs and provides both a synchronous and an asynchronous interface.
44

5-
[![Downloads](https://static.pepy.tech/badge/pyTigergraph)](https://pepy.tech/project/pyTigergraph)
6-
[![Downloads](https://static.pepy.tech/badge/pyTigergraph/month)](https://pepy.tech/project/pyTigergraph)
7-
[![Downloads](https://static.pepy.tech/badge/pyTigergraph/week)](https://pepy.tech/project/pyTigergraph)
5+
Full documentation: <https://docs.tigergraph.com/pytigergraph/current/intro/>
86

9-
## Quickstart
7+
Downloads: [![Total Downloads](https://static.pepy.tech/badge/pyTigergraph)](https://pepy.tech/project/pyTigergraph) | [![Monthly Downloads](https://static.pepy.tech/badge/pyTigergraph/month)](https://pepy.tech/project/pyTigergraph) | [![Weekly Downloads](https://static.pepy.tech/badge/pyTigergraph/week)](https://pepy.tech/project/pyTigergraph)
8+
9+
---
10+
11+
## Installation
12+
13+
### Base package
1014

11-
### Installing pyTigerGraph
12-
This section walks you through installing pyTigerGraph on your machine.
15+
```sh
16+
pip install pyTigerGraph
17+
```
1318

14-
#### Prerequisites
15-
* Python 3+
16-
* If you wish to use the GDS functionality, install `torch` ahead of time.
19+
### Optional extras
1720

18-
#### Install _pyTigerGraph_
21+
| Extra | What it adds | Install command |
22+
|-------|-------------|-----------------|
23+
| `gds` | Graph Data Science — data loaders for PyTorch Geometric, DGL, and Pandas | `pip install 'pyTigerGraph[gds]'` |
24+
| `mcp` | Model Context Protocol server — installs [`pyTigerGraph-mcp`](https://github.com/tigergraph/tigergraph-mcp) (convenience alias) | `pip install 'pyTigerGraph[mcp]'` |
25+
| `fast` | [orjson](https://github.com/ijl/orjson) JSON backend — 2–10× faster parsing, releases the GIL under concurrent load | `pip install 'pyTigerGraph[fast]'` |
1926

20-
To download _pyTigerGraph_, run the following command in the command line or use the appropriate tool of your development environment (anaconda, PyCharm, etc.).:
27+
Extras can be combined:
2128

2229
```sh
23-
pip3 install pyTigerGraph
30+
pip install 'pyTigerGraph[fast,gds,mcp]'
2431
```
2532

26-
#### Install _pyTigerGraph[gds]_
33+
#### `[gds]` prerequisites
2734

28-
To utilize the Graph Data Science Functionality, there are a few options:
29-
* To use the GDS functions with **PyTorch Geometric**, install `torch` and `PyTorch Geometric` according to their instructions:
35+
Install `torch` before installing the `gds` extra:
3036

31-
1) [Install Torch](https://pytorch.org/get-started/locally/)
37+
1. [Install Torch](https://pytorch.org/get-started/locally/)
38+
2. Optionally [Install PyTorch Geometric](https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html) or [Install DGL](https://www.dgl.ai/pages/start.html)
39+
3. `pip install 'pyTigerGraph[gds]'`
3240

33-
2) [Install PyTorch Geometric](https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html)
41+
#### `[fast]` — orjson JSON backend
3442

35-
3) Install pyTigerGraph with:
36-
```sh
37-
pip3 install 'pyTigerGraph[gds]'
38-
```
43+
`orjson` is a Rust-backed JSON library that is detected and used automatically when installed. No code changes are required. It improves throughput in two ways:
3944

40-
* To use the GDS functions with **DGL**, install `torch` and `dgl` according to their instructions:
45+
- **Faster parsing** — 2–10× vs stdlib `json`
46+
- **GIL release** — threads parse responses concurrently instead of serialising on the GIL
4147

42-
1) [Install Torch](https://pytorch.org/get-started/locally/)
48+
If `orjson` is not installed the library falls back to stdlib `json` transparently.
4349

44-
2) [Install DGL](https://www.dgl.ai/pages/start.html)
50+
---
4551

46-
3) Install pyTigerGraph with:
47-
```sh
48-
pip3 install 'pyTigerGraph[gds]'
49-
```
52+
## Quickstart
5053

51-
* To use the GDS functions without needing to produce output in the format supported by PyTorch Geometric or DGL.
52-
This makes the data loaders output *Pandas dataframes*:
53-
```sh
54-
pip3 install 'pyTigerGraph[gds]'
54+
### Synchronous connection
55+
56+
```python
57+
from pyTigerGraph import TigerGraphConnection
58+
59+
conn = TigerGraphConnection(
60+
host="http://localhost",
61+
graphname="my_graph",
62+
username="tigergraph",
63+
password="tigergraph",
64+
)
65+
66+
print(conn.echo())
5567
```
5668

57-
Once the package is installed, you can import it like any other Python package:
69+
Use as a context manager to ensure the underlying HTTP session is closed:
5870

59-
```py
60-
import pyTigerGraph as tg
71+
```python
72+
with TigerGraphConnection(host="http://localhost", graphname="my_graph") as conn:
73+
result = conn.runInstalledQuery("my_query", {"param": "value"})
6174
```
62-
### Getting Started with Core Functions
75+
76+
### Asynchronous connection
77+
78+
`AsyncTigerGraphConnection` exposes the same API as `TigerGraphConnection` but with `async`/`await` syntax. It uses [aiohttp](https://docs.aiohttp.org/) internally and shares a single connection pool across all concurrent tasks, making it significantly more efficient than threaded sync code at high concurrency.
79+
80+
```python
81+
import asyncio
82+
from pyTigerGraph import AsyncTigerGraphConnection
83+
84+
async def main():
85+
async with AsyncTigerGraphConnection(
86+
host="http://localhost",
87+
graphname="my_graph",
88+
username="tigergraph",
89+
password="tigergraph",
90+
) as conn:
91+
result = await conn.runInstalledQuery("my_query", {"param": "value"})
92+
print(result)
93+
94+
asyncio.run(main())
95+
```
96+
97+
### Token-based authentication
98+
99+
```python
100+
conn = TigerGraphConnection(
101+
host="http://localhost",
102+
graphname="my_graph",
103+
gsqlSecret="my_secret", # generates a session token automatically
104+
)
105+
```
106+
107+
### HTTPS / TigerGraph Cloud
108+
109+
```python
110+
conn = TigerGraphConnection(
111+
host="https://my-instance.i.tgcloud.io",
112+
graphname="my_graph",
113+
username="tigergraph",
114+
password="tigergraph",
115+
tgCloud=True,
116+
)
117+
```
118+
119+
---
120+
121+
## Connection parameters
122+
123+
| Parameter | Type | Default | Description |
124+
|-----------|------|---------|-------------|
125+
| `host` | `str` | `"http://127.0.0.1"` | Server URL including scheme (`http://` or `https://`) |
126+
| `graphname` | `str` | `""` | Target graph name |
127+
| `username` | `str` | `"tigergraph"` | Database username |
128+
| `password` | `str` | `"tigergraph"` | Database password |
129+
| `gsqlSecret` | `str` | `""` | GSQL secret for token-based auth (preferred over username/password) |
130+
| `apiToken` | `str` | `""` | Pre-obtained REST++ API token |
131+
| `jwtToken` | `str` | `""` | JWT token for customer-managed authentication |
132+
| `restppPort` | `int\|str` | `"9000"` | REST++ port (auto-fails over to `14240/restpp` for TigerGraph 4.x) |
133+
| `gsPort` | `int\|str` | `"14240"` | GSQL server port |
134+
| `certPath` | `str` | `None` | Path to CA certificate for HTTPS |
135+
| `tgCloud` | `bool` | `False` | Set to `True` for TigerGraph Cloud instances |
136+
137+
---
138+
139+
## Performance notes
140+
141+
### Synchronous mode (`TigerGraphConnection`)
142+
143+
- Each thread gets its own dedicated HTTP session and connection pool, so concurrent threads never block each other.
144+
- Install `pyTigerGraph[fast]` to activate the `orjson` backend and reduce JSON parsing overhead under concurrent load.
145+
- Use `ThreadPoolExecutor` to run queries in parallel:
146+
147+
```python
148+
from concurrent.futures import ThreadPoolExecutor, as_completed
149+
150+
with TigerGraphConnection(...) as conn:
151+
with ThreadPoolExecutor(max_workers=16) as executor:
152+
futures = [executor.submit(conn.runInstalledQuery, "q", {"p": v}) for v in values]
153+
for f in as_completed(futures):
154+
print(f.result())
155+
```
156+
157+
### Asynchronous mode (`AsyncTigerGraphConnection`)
158+
159+
- Uses a single `aiohttp.ClientSession` with an unbounded connection pool shared across all concurrent coroutines — no GIL, no thread-scheduling overhead.
160+
- Typically achieves higher QPS and lower tail latency than the threaded sync mode for I/O-bound workloads.
161+
162+
```python
163+
import asyncio
164+
from pyTigerGraph import AsyncTigerGraphConnection
165+
166+
async def main():
167+
async with AsyncTigerGraphConnection(...) as conn:
168+
tasks = [conn.runInstalledQuery("q", {"p": v}) for v in values]
169+
results = await asyncio.gather(*tasks)
170+
171+
asyncio.run(main())
172+
```
173+
174+
---
175+
176+
## Graph Data Science (GDS)
177+
178+
The `gds` sub-module provides data loaders that stream vertex and edge data from TigerGraph directly into PyTorch Geometric, DGL, or Pandas DataFrames for machine learning workflows.
179+
180+
Install requirements, then access via `conn.gds`:
181+
182+
```python
183+
conn = TigerGraphConnection(host="...", graphname="...")
184+
loader = conn.gds.vertexLoader(attributes=["feat", "label"], batch_size=1024)
185+
for batch in loader:
186+
train(batch)
187+
```
188+
189+
See the [GDS documentation](https://docs.tigergraph.com/pytigergraph/current/gds/) for full details.
190+
191+
---
192+
193+
## MCP Server
194+
195+
The TigerGraph MCP server is now a standalone package: **[pyTigerGraph-mcp](https://github.com/tigergraph/tigergraph-mcp)**. It exposes TigerGraph operations as tools for AI agents and LLM applications (Claude Desktop, Cursor, Copilot, etc.).
196+
197+
```sh
198+
# Recommended — install the standalone package directly
199+
pip install pyTigerGraph-mcp
200+
201+
# Or via the pyTigerGraph convenience alias (installs pyTigerGraph-mcp automatically)
202+
pip install 'pyTigerGraph[mcp]'
203+
204+
# Start the server (reads connection config from environment variables)
205+
tigergraph-mcp
206+
```
207+
208+
For full setup instructions, available tools, configuration examples, and multi-profile support, see the **[pyTigerGraph-mcp README](https://github.com/tigergraph/tigergraph-mcp#readme)**.
209+
210+
> **Migrating from `pyTigerGraph.mcp`?** Update your imports:
211+
> ```python
212+
> # Old
213+
> from pyTigerGraph.mcp import serve, ConnectionManager
214+
> # New
215+
> from tigergraph_mcp import serve, ConnectionManager
216+
> ```
217+
218+
---
219+
220+
## Getting started video
63221
64222
[![pyTigerGraph 101](https://img.youtube.com/vi/2BcC3C-qfX4/hqdefault.jpg)](https://www.youtube.com/watch?v=2BcC3C-qfX4)
65223
66-
The video above is a good starting place for learning the core functions of pyTigerGraph. [This Google Colab notebook](https://colab.research.google.com/drive/1JhYcnGVWT51KswcXZzyPzKqCoPP5htcC) is the companion notebook to the video.
224+
Companion notebook: [Google Colab](https://colab.research.google.com/drive/1JhYcnGVWT51KswcXZzyPzKqCoPP5htcC)
225+
226+
---
227+
228+
## Links
229+
230+
- [Documentation](https://docs.tigergraph.com/pytigergraph/current/intro/)
231+
- [PyPI](https://pypi.org/project/pyTigerGraph/)
232+
- [GitHub Issues](https://github.com/tigergraph/pyTigerGraph/issues)
233+
- [Source](https://github.com/tigergraph/pyTigerGraph)

0 commit comments

Comments
 (0)