Spaces:
Running
Running
Basic Cypher box with grand-cypher.
Browse files
lynxkite-graph-analytics/pyproject.toml
CHANGED
@@ -5,6 +5,7 @@ description = "The graph analytics executor and boxes for LynxKite"
|
|
5 |
readme = "README.md"
|
6 |
requires-python = ">=3.11"
|
7 |
dependencies = [
|
|
|
8 |
"lynxkite-core",
|
9 |
"matplotlib>=3.10.0",
|
10 |
"networkx>=3.4.2",
|
|
|
5 |
readme = "README.md"
|
6 |
requires-python = ">=3.11"
|
7 |
dependencies = [
|
8 |
+
"grand-cypher>=0.12.0",
|
9 |
"lynxkite-core",
|
10 |
"matplotlib>=3.10.0",
|
11 |
"networkx>=3.4.2",
|
lynxkite-graph-analytics/src/lynxkite_plugins/graph_analytics/lynxkite_ops.py
CHANGED
@@ -5,6 +5,7 @@ from lynxkite.core import ops
|
|
5 |
from collections import deque
|
6 |
import dataclasses
|
7 |
import functools
|
|
|
8 |
import matplotlib
|
9 |
import networkx as nx
|
10 |
import pandas as pd
|
@@ -224,9 +225,22 @@ def sql(bundle: Bundle, *, query: ops.LongStr, save_as: str = "result"):
|
|
224 |
return bundle
|
225 |
|
226 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
227 |
@op("Organize bundle")
|
228 |
def organize_bundle(bundle: Bundle, *, code: ops.LongStr):
|
229 |
-
"""Lets you rename/copy/delete DataFrames, and modify relations.
|
|
|
|
|
|
|
230 |
bundle = bundle.copy()
|
231 |
exec(code, globals(), {"bundle": bundle})
|
232 |
return bundle
|
|
|
5 |
from collections import deque
|
6 |
import dataclasses
|
7 |
import functools
|
8 |
+
import grandcypher
|
9 |
import matplotlib
|
10 |
import networkx as nx
|
11 |
import pandas as pd
|
|
|
225 |
return bundle
|
226 |
|
227 |
|
228 |
+
@op("Cypher")
|
229 |
+
def cypher(bundle: Bundle, *, query: ops.LongStr, save_as: str = "result"):
|
230 |
+
"""Run a Cypher query on the graph in the bundle. Save the results as a new DataFrame."""
|
231 |
+
bundle = bundle.copy()
|
232 |
+
graph = bundle.to_nx()
|
233 |
+
res = grandcypher.GrandCypher(graph).run(query)
|
234 |
+
bundle.dfs[save_as] = pd.DataFrame(res)
|
235 |
+
return bundle
|
236 |
+
|
237 |
+
|
238 |
@op("Organize bundle")
|
239 |
def organize_bundle(bundle: Bundle, *, code: ops.LongStr):
|
240 |
+
"""Lets you rename/copy/delete DataFrames, and modify relations.
|
241 |
+
|
242 |
+
TODO: Use a declarative solution instead of Python code. Add UI.
|
243 |
+
"""
|
244 |
bundle = bundle.copy()
|
245 |
exec(code, globals(), {"bundle": bundle})
|
246 |
return bundle
|
lynxkite-graph-analytics/uv.lock
CHANGED
@@ -127,6 +127,26 @@ wheels = [
|
|
127 |
{ url = "https://files.pythonhosted.org/packages/99/3b/406d17b1f63e04a82aa621936e6e1c53a8c05458abd66300ac85ea7f9ae9/fonttools-4.55.3-py3-none-any.whl", hash = "sha256:f412604ccbeee81b091b420272841e5ec5ef68967a9790e80bffd0e30b8e2977", size = 1111638 },
|
128 |
]
|
129 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
130 |
[[package]]
|
131 |
name = "kiwisolver"
|
132 |
version = "1.4.8"
|
@@ -193,6 +213,15 @@ wheels = [
|
|
193 |
{ url = "https://files.pythonhosted.org/packages/4c/fa/be89a49c640930180657482a74970cdcf6f7072c8d2471e1babe17a222dc/kiwisolver-1.4.8-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:be4816dc51c8a471749d664161b434912eee82f2ea66bd7628bd14583a833e85", size = 2349213 },
|
194 |
]
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
[[package]]
|
197 |
name = "libcudf-cu12"
|
198 |
version = "24.12.0"
|
@@ -243,6 +272,7 @@ name = "lynxkite-graph-analytics"
|
|
243 |
version = "0.1.0"
|
244 |
source = { virtual = "." }
|
245 |
dependencies = [
|
|
|
246 |
{ name = "lynxkite-core" },
|
247 |
{ name = "matplotlib" },
|
248 |
{ name = "networkx" },
|
@@ -252,6 +282,7 @@ dependencies = [
|
|
252 |
|
253 |
[package.metadata]
|
254 |
requires-dist = [
|
|
|
255 |
{ name = "lynxkite-core", virtual = "../lynxkite-core" },
|
256 |
{ name = "matplotlib", specifier = ">=3.10.0" },
|
257 |
{ name = "networkx", specifier = ">=3.4.2" },
|
|
|
127 |
{ url = "https://files.pythonhosted.org/packages/99/3b/406d17b1f63e04a82aa621936e6e1c53a8c05458abd66300ac85ea7f9ae9/fonttools-4.55.3-py3-none-any.whl", hash = "sha256:f412604ccbeee81b091b420272841e5ec5ef68967a9790e80bffd0e30b8e2977", size = 1111638 },
|
128 |
]
|
129 |
|
130 |
+
[[package]]
|
131 |
+
name = "grand-cypher"
|
132 |
+
version = "0.12.0"
|
133 |
+
source = { registry = "https://pypi.org/simple" }
|
134 |
+
dependencies = [
|
135 |
+
{ name = "grandiso" },
|
136 |
+
{ name = "lark" },
|
137 |
+
{ name = "networkx" },
|
138 |
+
]
|
139 |
+
sdist = { url = "https://files.pythonhosted.org/packages/af/3e/9548603df25f4f7bc248b898ff49125fde53a0cd627ef993fb083a4cf1be/grand-cypher-0.12.0.tar.gz", hash = "sha256:95664ad6b91926872116c019ae6235306b40a2940ff32e1cb1391dc22c6103c5", size = 24722 }
|
140 |
+
|
141 |
+
[[package]]
|
142 |
+
name = "grandiso"
|
143 |
+
version = "2.2.0"
|
144 |
+
source = { registry = "https://pypi.org/simple" }
|
145 |
+
dependencies = [
|
146 |
+
{ name = "networkx" },
|
147 |
+
]
|
148 |
+
sdist = { url = "https://files.pythonhosted.org/packages/65/c6/27400e2d81bd769ebe65c695cead44c8efb55ac3769826a01c9223d65709/grandiso-2.2.0.tar.gz", hash = "sha256:66f292d27328e13122065c7905ad0ac79c4649f69a35e7b98a3631654a0bf77c", size = 16277 }
|
149 |
+
|
150 |
[[package]]
|
151 |
name = "kiwisolver"
|
152 |
version = "1.4.8"
|
|
|
213 |
{ url = "https://files.pythonhosted.org/packages/4c/fa/be89a49c640930180657482a74970cdcf6f7072c8d2471e1babe17a222dc/kiwisolver-1.4.8-cp313-cp313t-musllinux_1_2_x86_64.whl", hash = "sha256:be4816dc51c8a471749d664161b434912eee82f2ea66bd7628bd14583a833e85", size = 2349213 },
|
214 |
]
|
215 |
|
216 |
+
[[package]]
|
217 |
+
name = "lark"
|
218 |
+
version = "1.2.2"
|
219 |
+
source = { registry = "https://pypi.org/simple" }
|
220 |
+
sdist = { url = "https://files.pythonhosted.org/packages/af/60/bc7622aefb2aee1c0b4ba23c1446d3e30225c8770b38d7aedbfb65ca9d5a/lark-1.2.2.tar.gz", hash = "sha256:ca807d0162cd16cef15a8feecb862d7319e7a09bdb13aef927968e45040fed80", size = 252132 }
|
221 |
+
wheels = [
|
222 |
+
{ url = "https://files.pythonhosted.org/packages/2d/00/d90b10b962b4277f5e64a78b6609968859ff86889f5b898c1a778c06ec00/lark-1.2.2-py3-none-any.whl", hash = "sha256:c2276486b02f0f1b90be155f2c8ba4a8e194d42775786db622faccd652d8e80c", size = 111036 },
|
223 |
+
]
|
224 |
+
|
225 |
[[package]]
|
226 |
name = "libcudf-cu12"
|
227 |
version = "24.12.0"
|
|
|
272 |
version = "0.1.0"
|
273 |
source = { virtual = "." }
|
274 |
dependencies = [
|
275 |
+
{ name = "grand-cypher" },
|
276 |
{ name = "lynxkite-core" },
|
277 |
{ name = "matplotlib" },
|
278 |
{ name = "networkx" },
|
|
|
282 |
|
283 |
[package.metadata]
|
284 |
requires-dist = [
|
285 |
+
{ name = "grand-cypher", specifier = ">=0.12.0" },
|
286 |
{ name = "lynxkite-core", virtual = "../lynxkite-core" },
|
287 |
{ name = "matplotlib", specifier = ">=3.10.0" },
|
288 |
{ name = "networkx", specifier = ">=3.4.2" },
|