turingdb 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of turingdb might be problematic. Click here for more details.

@@ -0,0 +1,31 @@
1
+ name: CI macos ARM
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: macos-latest-xlarge
12
+
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Install uv
27
+ uses: astral-sh/setup-uv@v3
28
+
29
+ - name: Build package
30
+ run: uv build
31
+
@@ -0,0 +1,65 @@
1
+ # .github/workflows/build.yml
2
+ name: Release
3
+
4
+ on:
5
+ push:
6
+ tags:
7
+ - "v*" # Trigger on version tags like v1.0.0, v2.1.3, etc.
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Install uv
27
+ uses: astral-sh/setup-uv@v3
28
+
29
+ - name: Build package
30
+ run: uv build
31
+
32
+ - name: Upload build artifacts
33
+ uses: actions/upload-artifact@v4
34
+ with:
35
+ name: python-package-distributions-${{ matrix.python-version }}
36
+ path: dist/
37
+
38
+ release:
39
+ needs: build # Wait for all build jobs to complete
40
+ runs-on: ubuntu-latest
41
+ environment:
42
+ name: pypi
43
+ url: https://pypi.org/p/turingdb
44
+ permissions:
45
+ contents: write # Required to create GitHub releases
46
+ id-token: write
47
+
48
+ steps:
49
+ - name: Download all artifacts
50
+ uses: actions/download-artifact@v4
51
+ with:
52
+ pattern: python-package-distributions-*
53
+ path: dist/
54
+ merge-multiple: true
55
+
56
+ - name: Create GitHub Release
57
+ uses: softprops/action-gh-release@v2
58
+ with:
59
+ files: dist/*
60
+ generate_release_notes: true
61
+ env:
62
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63
+
64
+ - name: Publish distribution 📦 to PyPI
65
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,31 @@
1
+ name: CI Ubuntu
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
16
+
17
+ steps:
18
+ - name: Checkout code
19
+ uses: actions/checkout@v4
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Install uv
27
+ uses: astral-sh/setup-uv@v3
28
+
29
+ - name: Build package
30
+ run: uv build
31
+
@@ -0,0 +1,195 @@
1
+ # Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,python
2
+ # Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,python
3
+
4
+ ### Python ###
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ *.py[cod]
8
+ *$py.class
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ build/
16
+ develop-eggs/
17
+ dist/
18
+ downloads/
19
+ eggs/
20
+ .eggs/
21
+ lib/
22
+ lib64/
23
+ parts/
24
+ sdist/
25
+ var/
26
+ wheels/
27
+ share/python-wheels/
28
+ *.egg-info/
29
+ .installed.cfg
30
+ *.egg
31
+ MANIFEST
32
+
33
+ # PyInstaller
34
+ # Usually these files are written by a python script from a template
35
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
36
+ *.manifest
37
+ *.spec
38
+
39
+ # Installer logs
40
+ pip-log.txt
41
+ pip-delete-this-directory.txt
42
+
43
+ # Unit test / coverage reports
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *.cover
53
+ *.py,cover
54
+ .hypothesis/
55
+ .pytest_cache/
56
+ cover/
57
+
58
+ # Translations
59
+ *.mo
60
+ *.pot
61
+
62
+ # Django stuff:
63
+ *.log
64
+ local_settings.py
65
+ db.sqlite3
66
+ db.sqlite3-journal
67
+
68
+ # Flask stuff:
69
+ instance/
70
+ .webassets-cache
71
+
72
+ # Scrapy stuff:
73
+ .scrapy
74
+
75
+ # Sphinx documentation
76
+ docs/_build/
77
+
78
+ # PyBuilder
79
+ .pybuilder/
80
+ target/
81
+
82
+ # Jupyter Notebook
83
+ .ipynb_checkpoints
84
+
85
+ # IPython
86
+ profile_default/
87
+ ipython_config.py
88
+
89
+ # pyenv
90
+ # For a library or package, you might want to ignore these files since the code is
91
+ # intended to run in multiple environments; otherwise, check them in:
92
+ # .python-version
93
+
94
+ # pipenv
95
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
96
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
97
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
98
+ # install all needed dependencies.
99
+ #Pipfile.lock
100
+
101
+ # poetry
102
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
103
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
104
+ # commonly ignored for libraries.
105
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
106
+ #poetry.lock
107
+
108
+ # pdm
109
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
110
+ #pdm.lock
111
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
112
+ # in version control.
113
+ # https://pdm.fming.dev/#use-with-ide
114
+ .pdm.toml
115
+
116
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
117
+ __pypackages__/
118
+
119
+ # Celery stuff
120
+ celerybeat-schedule
121
+ celerybeat.pid
122
+
123
+ # SageMath parsed files
124
+ *.sage.py
125
+
126
+ # Environments
127
+ .env
128
+ .venv
129
+ env/
130
+ venv/
131
+ ENV/
132
+ env.bak/
133
+ venv.bak/
134
+
135
+ # Spyder project settings
136
+ .spyderproject
137
+ .spyproject
138
+
139
+ # Rope project settings
140
+ .ropeproject
141
+
142
+ # mkdocs documentation
143
+ /site
144
+
145
+ # mypy
146
+ .mypy_cache/
147
+ .dmypy.json
148
+ dmypy.json
149
+
150
+ # Pyre type checker
151
+ .pyre/
152
+
153
+ # pytype static type analyzer
154
+ .pytype/
155
+
156
+ # Cython debug symbols
157
+ cython_debug/
158
+
159
+ # PyCharm
160
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
161
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
162
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
163
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
164
+ #.idea/
165
+
166
+ ### Python Patch ###
167
+ # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
168
+ poetry.toml
169
+
170
+ # ruff
171
+ .ruff_cache/
172
+
173
+ # LSP config files
174
+ pyrightconfig.json
175
+
176
+ ### VisualStudioCode ###
177
+ .vscode/*
178
+ !.vscode/settings.json
179
+ !.vscode/tasks.json
180
+ !.vscode/launch.json
181
+ !.vscode/extensions.json
182
+ !.vscode/*.code-snippets
183
+
184
+ # Local History for Visual Studio Code
185
+ .history/
186
+
187
+ # Built Visual Studio Code Extensions
188
+ *.vsix
189
+
190
+ ### VisualStudioCode Patch ###
191
+ # Ignore all local history of files
192
+ .history
193
+ .ionide
194
+
195
+ # End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,python
@@ -0,0 +1 @@
1
+ 3.13
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Turing Biosystems Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ Metadata-Version: 2.4
2
+ Name: turingdb
3
+ Version: 0.1.0
4
+ Summary: TuringDB python sdk
5
+ Project-URL: Homepage, https://github.com/turing-db/turingdb-sdk-python
6
+ Project-URL: Repository, https://github.com/turing-db/turingdb-sdk-python
7
+ License-File: LICENSE.txt
8
+ Requires-Python: >=3.9
9
+ Requires-Dist: httpx>=0.28.1
10
+ Requires-Dist: orjson>=3.11.1
11
+ Requires-Dist: pandas>=2.3.1
12
+ Description-Content-Type: text/markdown
13
+
14
+ # turingdb-sdk-python
15
+ Python SDK of the TuringDB graph database engine
@@ -0,0 +1,2 @@
1
+ # turingdb-sdk-python
2
+ Python SDK of the TuringDB graph database engine
turingdb-0.1.0/main.py ADDED
@@ -0,0 +1,6 @@
1
+ def main():
2
+ print("Hello from src!")
3
+
4
+
5
+ if __name__ == "__main__":
6
+ main()
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "turingdb"
7
+ version = "0.1.0"
8
+ description = "TuringDB python sdk"
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ dependencies = [
12
+ "httpx>=0.28.1",
13
+ "orjson>=3.11.1",
14
+ "pandas>=2.3.1",
15
+ ]
16
+
17
+ [project.urls]
18
+ Homepage = "https://github.com/turing-db/turingdb-sdk-python"
19
+ Repository = "https://github.com/turing-db/turingdb-sdk-python"
20
+
21
+ [dependency-groups]
22
+ dev = [
23
+ "twine>=6.1.0",
24
+ ]
@@ -0,0 +1,150 @@
1
+ from typing import Optional
2
+
3
+
4
+ class TuringDBException(Exception):
5
+ def __init__(self, message: str):
6
+ super().__init__(message)
7
+
8
+
9
+ class TuringDB:
10
+ DEFAULT_HEADERS = {
11
+ "Accept": "application/json",
12
+ "Content-Type": "application/json",
13
+ }
14
+
15
+ def __init__(
16
+ self,
17
+ instance_id: str = "",
18
+ auth_token: str = "",
19
+ host: str = "https://engines.turingdb.ai/sdk",
20
+ ):
21
+ import httpx
22
+ import copy
23
+
24
+ self.host = host
25
+
26
+ self._client = httpx.Client(auth=None, verify=False)
27
+
28
+ self._params = {
29
+ "graph": "default",
30
+ }
31
+
32
+ self._headers = copy.deepcopy(TuringDB.DEFAULT_HEADERS)
33
+
34
+ if instance_id != "":
35
+ self._headers["Turing-Instance-Id"] = instance_id
36
+
37
+ if auth_token != "":
38
+ self._headers["Authorization"] = f"Bearer {auth_token}"
39
+
40
+ def list_available_graphs(self) -> list[str]:
41
+ return self._send_request("list_avail_graphs")["data"]
42
+
43
+ def list_loaded_graphs(self) -> list[str]:
44
+ return self._send_request("list_loaded_graphs")["data"][0][0]
45
+
46
+ def load_graph(self, graph_name: str, raise_if_loaded: bool = True):
47
+ try:
48
+ return self._send_request("load_graph", params={"graph": graph_name})
49
+ except TuringDBException as e:
50
+ if raise_if_loaded or e.__str__() != "GRAPH_ALREADY_EXISTS":
51
+ raise e
52
+
53
+ def create_graph(self, graph_name: str):
54
+ return self.query(f"create graph {graph_name}")
55
+
56
+ def query(self, query: str):
57
+ json = self._send_request("query", data=query, params=self._params)
58
+
59
+ if not isinstance(json, dict):
60
+ raise TuringDBException("Invalid response from the server")
61
+
62
+ return self._parse_chunks(json)
63
+
64
+ def set_commit(self, commit: str):
65
+ self._params["commit"] = commit
66
+
67
+ def set_change(self, change: str):
68
+ self._params["change"] = change
69
+
70
+ def checkout(self, change: str = "main", commit: str = "HEAD"):
71
+ if change == "main":
72
+ if "change" in self._params:
73
+ del self._params["change"]
74
+ else:
75
+ self.set_change(change)
76
+
77
+ if commit == "HEAD":
78
+ if "commit" in self._params:
79
+ del self._params["commit"]
80
+ else:
81
+ self.set_commit(commit)
82
+
83
+ def set_graph(self, graph_name: str):
84
+ self._params["graph"] = graph_name
85
+
86
+ def _send_request(
87
+ self,
88
+ path: str,
89
+ data: Optional[dict | str] = None,
90
+ params: Optional[dict] = None,
91
+ ):
92
+ import orjson
93
+
94
+ if data is None:
95
+ data = ""
96
+
97
+ url = f"{self.host}/{path}"
98
+
99
+ if isinstance(data, dict):
100
+ response = self._client.post(
101
+ url, json=data, params=params, headers=self._headers
102
+ )
103
+ else:
104
+ response = self._client.post(
105
+ url, content=data, params=params, headers=self._headers
106
+ )
107
+ response.raise_for_status()
108
+
109
+ json = orjson.loads(response.text)
110
+
111
+ if isinstance(json, dict):
112
+ err = json.get("error")
113
+ if err is not None:
114
+ raise TuringDBException(err)
115
+
116
+ return json
117
+
118
+ def _parse_chunks(self, json: dict):
119
+ import pandas as pd
120
+ import numpy as np
121
+
122
+ data_header = json["header"]
123
+ column_names: list[str] = data_header["column_names"]
124
+ column_types: list[str] = data_header["column_types"]
125
+ dtypes: list[np.dtype] = []
126
+ columns: list[list] = []
127
+
128
+ for chunk in json["data"]:
129
+ for i, col in enumerate(chunk):
130
+ if i >= len(columns):
131
+ match column_types[i]:
132
+ case "String":
133
+ dtypes.append(np.dtype(np.dtypes.StringDType))
134
+ case "Int64":
135
+ dtypes.append(np.dtype(np.dtypes.Int64DType))
136
+ case "UInt64":
137
+ dtypes.append(np.dtype(np.dtypes.UInt64DType))
138
+ case "Double":
139
+ dtypes.append(np.dtype(np.dtypes.Float64DType))
140
+ case "Boolean":
141
+ dtypes.append(np.dtype(np.dtypes.BoolDType))
142
+
143
+ columns.append([])
144
+
145
+ columns[i] = columns[i] + col
146
+
147
+ arrays = [np.array(columns[i], dtype=dtypes[i]) for i in range(len(columns))]
148
+
149
+ return pd.DataFrame(dict(zip(column_names, arrays)), index=None)
150
+