Graphinate 0.0.7__tar.gz → 0.0.9__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.
- graphinate-0.0.9/PKG-INFO +234 -0
- graphinate-0.0.9/README.md +188 -0
- graphinate-0.0.9/docs/acknowledgements.md +26 -0
- graphinate-0.0.9/docs/examples.md +18 -0
- graphinate-0.0.9/docs/gallery.md +13 -0
- graphinate-0.0.9/docs/index.md +13 -0
- graphinate-0.0.9/docs/install.md +15 -0
- graphinate-0.0.9/docs/intro.md +63 -0
- graphinate-0.0.9/docs/start.md +37 -0
- graphinate-0.0.9/docs/usage.md +19 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/code/python_ast.py +3 -3
- graphinate-0.0.9/examples/code/requirements.txt +1 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/github/followers.py +2 -3
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/github/repositories.py +4 -5
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/math/graph_atlas.py +2 -2
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/math/hailstone.py +2 -2
- graphinate-0.0.9/examples/math/polygonal_graph.py +36 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/text/nlp_graph.py +1 -2
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/web/requirements.txt +0 -1
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/web/web_graph.py +4 -10
- {graphinate-0.0.7 → graphinate-0.0.9}/mkdocs.yml +7 -1
- {graphinate-0.0.7 → graphinate-0.0.9}/pyproject.toml +15 -16
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/__init__.py +1 -1
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/builders.py +38 -13
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/cli.py +5 -7
- {graphinate-0.0.7/src/graphinate/materialize → graphinate-0.0.9/src/graphinate/materializers}/__init__.py +13 -7
- {graphinate-0.0.7/src/graphinate/materialize → graphinate-0.0.9/src/graphinate/materializers}/matplotlib.py +7 -7
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/modeling.py +2 -2
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/__init__.py +3 -1
- graphinate-0.0.7/PKG-INFO +0 -132
- graphinate-0.0.7/README.md +0 -83
- graphinate-0.0.7/docs/index.md +0 -7
- graphinate-0.0.7/docs/install.md +0 -9
- graphinate-0.0.7/docs/usage.md +0 -10
- graphinate-0.0.7/examples/code/requirements.txt +0 -1
- {graphinate-0.0.7 → graphinate-0.0.9}/.github/workflows/codeql.yml +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/.github/workflows/publish.yml +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/.github/workflows/test-python-beta.yml +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/.github/workflows/test.yml +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/.gitignore +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/LICENSE +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/docs/assets/images/network_graph.png +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/code/call_graph.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/ethernet/traceroute.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/genric_graph.graphql +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/github/_client.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/github/followers.graphql +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/github/graphql.config.yml +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/github/repositories.graphql +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/examples/graphql.config.yml +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/playground/grap_genus.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/playground/house_of_graphs.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/__main__.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/color.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/starlette/__init__.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/starlette/views.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/web/__init__.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/web/graphiql/__init__.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/web/graphiql/index.html +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/web/static/images/network_graph.png +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/web/viewer/__init__.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/web/viewer/index.html +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/web/voyager/__init__.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/server/web/voyager/index.html +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/tools/__init__.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/tools/fs.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/tools/gui.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/tools/importer.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/tools/mutators.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/src/graphinate/typing.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/tests/conftest.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/tests/graphinate/test_builders.py +0 -0
- {graphinate-0.0.7 → graphinate-0.0.9}/tests/graphinate/test_modeling.py +0 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: Graphinate
|
|
3
|
+
Version: 0.0.9
|
|
4
|
+
Summary: Graphinate. Data to Graphs.
|
|
5
|
+
Project-URL: Homepage, https://github.com/erivlis/graphinate
|
|
6
|
+
Project-URL: Documentation, https://github.com/erivlis/graphinate#README.md
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/erivlis/graphinate/issues
|
|
8
|
+
Project-URL: Source, https://github.com/erivlis/graphinate
|
|
9
|
+
Author-email: Eran Rivlis <eran@rivlis.info>
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: declarative,graph
|
|
12
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Information Technology
|
|
15
|
+
Classifier: Intended Audience :: Science/Research
|
|
16
|
+
Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)
|
|
17
|
+
Classifier: Natural Language :: English
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Programming Language :: Python :: 3
|
|
20
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
25
|
+
Classifier: Topic :: Scientific/Engineering
|
|
26
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.9
|
|
29
|
+
Requires-Dist: click>=8
|
|
30
|
+
Requires-Dist: inflect>=7
|
|
31
|
+
Requires-Dist: loguru>=0.7
|
|
32
|
+
Requires-Dist: matplotlib>=3.7
|
|
33
|
+
Requires-Dist: networkx>=3
|
|
34
|
+
Requires-Dist: strawberry-graphql[asgi,opentelemetry]
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
37
|
+
Provides-Extra: plot
|
|
38
|
+
Requires-Dist: scipy; extra == 'plot'
|
|
39
|
+
Provides-Extra: server
|
|
40
|
+
Requires-Dist: starlette-prometheus; extra == 'server'
|
|
41
|
+
Requires-Dist: uvicorn[standard]; extra == 'server'
|
|
42
|
+
Provides-Extra: test
|
|
43
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == 'test'
|
|
44
|
+
Requires-Dist: pytest>=7.3.2; extra == 'test'
|
|
45
|
+
Description-Content-Type: text/markdown
|
|
46
|
+
|
|
47
|
+
# Graphinate. Data to Graphs.
|
|
48
|
+
|
|
49
|
+
> [!WARNING]
|
|
50
|
+
> **UNDER DEVELOPMENT**
|
|
51
|
+
>
|
|
52
|
+
> **This library is alpha-quality**
|
|
53
|
+
|
|
54
|
+

|
|
55
|
+

|
|
56
|
+

|
|
57
|
+

|
|
58
|
+

|
|
59
|
+

|
|
60
|
+
[](https://github.com/erivlis/graphinate/graphs/contributors)
|
|
61
|
+

|
|
62
|
+
|
|
63
|
+
[](https://github.com/erivlis/graphinate/actions/workflows/test.yml)
|
|
64
|
+
[](https://github.com/erivlis/graphinate/actions/workflows/publish.yml)
|
|
65
|
+
|
|
66
|
+
## Introduction
|
|
67
|
+
|
|
68
|
+
### What is Graphinate?
|
|
69
|
+
|
|
70
|
+
Graphinate is a library that aims to simplify the generation of Graph Data Structures from Data Sources.
|
|
71
|
+
|
|
72
|
+
It utilizes and builds upon the excellent [**_NetworkX_**](https://networkx.org/) library.
|
|
73
|
+
|
|
74
|
+
In addition, it has several interfaces for ease of use:
|
|
75
|
+
|
|
76
|
+
- CLI (using [**_Click_**](https://palletsprojects.com/p/click/)),
|
|
77
|
+
- GraphQL API (using [**_Strawberry GraphQL_**](https://strawberry.rocks/)).
|
|
78
|
+
|
|
79
|
+
[//]: # (- TUI (using [**_Textual_**](https://textual.textualize.io/)) **⚠️Not available yet⚠️**)
|
|
80
|
+
|
|
81
|
+
## Install
|
|
82
|
+
|
|
83
|
+
Graphinate is available on PyPI:
|
|
84
|
+
|
|
85
|
+
```shell
|
|
86
|
+
pip install graphinate
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
To install with server support
|
|
90
|
+
|
|
91
|
+
```shell
|
|
92
|
+
pip install graphinate[server]
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Graphinate officially supports Python 3.9+.
|
|
96
|
+
|
|
97
|
+
## Quick Start
|
|
98
|
+
|
|
99
|
+
### `GraphModel`
|
|
100
|
+
|
|
101
|
+
Graphinate defines the `GraphModel` Class which can be used to declaratively register _Edge_ and/or _Node_ data
|
|
102
|
+
supplier functions by using decorators.
|
|
103
|
+
|
|
104
|
+
### `materialize`
|
|
105
|
+
|
|
106
|
+
Graphinate supplies a `materialize` function to output the `GraphModel`.
|
|
107
|
+
|
|
108
|
+
### Example
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
import graphinate
|
|
112
|
+
|
|
113
|
+
N: int = 8
|
|
114
|
+
|
|
115
|
+
# Define GraphModel
|
|
116
|
+
graph_model = graphinate.GraphModel(name="Octagonal Graph")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# Register edges supplier function
|
|
120
|
+
@graph_model.edge()
|
|
121
|
+
def edge():
|
|
122
|
+
for i in range(N):
|
|
123
|
+
yield {'source': i, 'target': i + 1}
|
|
124
|
+
yield {'source': N, 'target': 0}
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
# Materialize the GraphModel
|
|
128
|
+
graphinate.materialize(graph_model)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## CLI
|
|
132
|
+
|
|
133
|
+
### Commands
|
|
134
|
+
|
|
135
|
+
```
|
|
136
|
+
Usage: python -m graphinate [OPTIONS] COMMAND [ARGS]...
|
|
137
|
+
|
|
138
|
+
Options:
|
|
139
|
+
--help Show this message and exit.
|
|
140
|
+
|
|
141
|
+
Commands:
|
|
142
|
+
save
|
|
143
|
+
server
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
#### Save
|
|
147
|
+
|
|
148
|
+
```
|
|
149
|
+
Usage: python -m graphinate save [OPTIONS] MODEL
|
|
150
|
+
|
|
151
|
+
Options:
|
|
152
|
+
--help Show this message and exit.
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
#### Server
|
|
156
|
+
|
|
157
|
+
```
|
|
158
|
+
Usage: python -m graphinate server [OPTIONS] MODEL
|
|
159
|
+
|
|
160
|
+
Options:
|
|
161
|
+
-p, --port INTEGER
|
|
162
|
+
--help Show this message and exit.
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## TUI
|
|
166
|
+
|
|
167
|
+
UNDER DEVELOPMENT
|
|
168
|
+
|
|
169
|
+
## Gallery
|
|
170
|
+
|
|
171
|
+
### Python AST
|
|
172
|
+
|
|
173
|
+

|
|
174
|
+
|
|
175
|
+
### GitHub Repository
|
|
176
|
+
|
|
177
|
+

|
|
178
|
+
|
|
179
|
+
### Python AST - 3D Force-Directed Animation
|
|
180
|
+
|
|
181
|
+

|
|
182
|
+
|
|
183
|
+
## Development
|
|
184
|
+
|
|
185
|
+
### Lint
|
|
186
|
+
|
|
187
|
+
```shell
|
|
188
|
+
ruff check src
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Docs
|
|
192
|
+
|
|
193
|
+
```shell
|
|
194
|
+
python -m mkdocs build
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Build
|
|
198
|
+
|
|
199
|
+
```shell
|
|
200
|
+
python -m build
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Test
|
|
204
|
+
|
|
205
|
+
```shell
|
|
206
|
+
python -m pytest ./tests --cov=./src --cov-branch --cov-report=xml --junitxml=test_results.xml
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Acknowledgements
|
|
210
|
+
|
|
211
|
+
### Dependencies
|
|
212
|
+
|
|
213
|
+
#### Python
|
|
214
|
+
|
|
215
|
+
<a href="https://palletsprojects.com/p/click/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://click.palletsprojects.com/en/7.x/_images/click-logo.png" alt="Click Logo."></a>
|
|
216
|
+
<a href="https://github.com/Delgan/loguru"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://raw.githubusercontent.com/Delgan/loguru/master/docs/_static/img/logo.png" alt="Loguru Logo."></a>
|
|
217
|
+
<a href="https://matplotlib.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://matplotlib.org/_static/logo_dark.svg" alt="matplotlib Logo."></a>
|
|
218
|
+
<a href="https://networkx.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://networkx.org/_static/networkx_logo.svg" alt="NetworkX Logo."></a>
|
|
219
|
+
<a href="https://strawberry.rocks/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/strawberry-graphql/strawberry/raw/main/.github/logo.png" alt="Strawberry GraphQL Logo."></a>
|
|
220
|
+
|
|
221
|
+
#### Javascript and HTML
|
|
222
|
+
|
|
223
|
+
<a href="https://vasturiano.github.io/3d-force-graph/"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="http://gist.github.com/vasturiano/02affe306ce445e423f992faeea13521/raw/preview.png" alt="3D Force-Directed Graph Logo."></a>
|
|
224
|
+
<a href="https://github.com/graphql-kit/graphql-voyager"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/graphql-kit/graphql-voyager/raw/main/docs/cover.png" alt="Graphql Voyager Logo."></a>
|
|
225
|
+
|
|
226
|
+
### Dev Tools
|
|
227
|
+
|
|
228
|
+
<a href="https://hatch.pypa.io/"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://hatch.pypa.io/latest/assets/images/logo.svg" alt="Hatch logo."></a>
|
|
229
|
+
<a href="https://pytest.org"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://docs.pytest.org/en/7.4.x/_static/pytest_logo_curves.svg" alt="pytest logo."></a>
|
|
230
|
+
<a href="https://astral.sh/ruff"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://astralcms.wpengine.com/wp-content/uploads/2023/03/Ruff-Logo.svg" alt="Ruff logo."></a>
|
|
231
|
+
|
|
232
|
+
### IDE
|
|
233
|
+
|
|
234
|
+
<a href="https://www.jetbrains.com/pycharm/"><img height="50" style="background: linear-gradient(-45deg, #FCF84A, #3DEA62, #21D789);" src="https://resources.jetbrains.com/storage/products/company/brand/logos/PyCharm.png" alt="PyCharm logo."></a>
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
# Graphinate. Data to Graphs.
|
|
2
|
+
|
|
3
|
+
> [!WARNING]
|
|
4
|
+
> **UNDER DEVELOPMENT**
|
|
5
|
+
>
|
|
6
|
+
> **This library is alpha-quality**
|
|
7
|
+
|
|
8
|
+

|
|
9
|
+

|
|
10
|
+

|
|
11
|
+

|
|
12
|
+

|
|
13
|
+

|
|
14
|
+
[](https://github.com/erivlis/graphinate/graphs/contributors)
|
|
15
|
+

|
|
16
|
+
|
|
17
|
+
[](https://github.com/erivlis/graphinate/actions/workflows/test.yml)
|
|
18
|
+
[](https://github.com/erivlis/graphinate/actions/workflows/publish.yml)
|
|
19
|
+
|
|
20
|
+
## Introduction
|
|
21
|
+
|
|
22
|
+
### What is Graphinate?
|
|
23
|
+
|
|
24
|
+
Graphinate is a library that aims to simplify the generation of Graph Data Structures from Data Sources.
|
|
25
|
+
|
|
26
|
+
It utilizes and builds upon the excellent [**_NetworkX_**](https://networkx.org/) library.
|
|
27
|
+
|
|
28
|
+
In addition, it has several interfaces for ease of use:
|
|
29
|
+
|
|
30
|
+
- CLI (using [**_Click_**](https://palletsprojects.com/p/click/)),
|
|
31
|
+
- GraphQL API (using [**_Strawberry GraphQL_**](https://strawberry.rocks/)).
|
|
32
|
+
|
|
33
|
+
[//]: # (- TUI (using [**_Textual_**](https://textual.textualize.io/)) **⚠️Not available yet⚠️**)
|
|
34
|
+
|
|
35
|
+
## Install
|
|
36
|
+
|
|
37
|
+
Graphinate is available on PyPI:
|
|
38
|
+
|
|
39
|
+
```shell
|
|
40
|
+
pip install graphinate
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
To install with server support
|
|
44
|
+
|
|
45
|
+
```shell
|
|
46
|
+
pip install graphinate[server]
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Graphinate officially supports Python 3.9+.
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
### `GraphModel`
|
|
54
|
+
|
|
55
|
+
Graphinate defines the `GraphModel` Class which can be used to declaratively register _Edge_ and/or _Node_ data
|
|
56
|
+
supplier functions by using decorators.
|
|
57
|
+
|
|
58
|
+
### `materialize`
|
|
59
|
+
|
|
60
|
+
Graphinate supplies a `materialize` function to output the `GraphModel`.
|
|
61
|
+
|
|
62
|
+
### Example
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
import graphinate
|
|
66
|
+
|
|
67
|
+
N: int = 8
|
|
68
|
+
|
|
69
|
+
# Define GraphModel
|
|
70
|
+
graph_model = graphinate.GraphModel(name="Octagonal Graph")
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
# Register edges supplier function
|
|
74
|
+
@graph_model.edge()
|
|
75
|
+
def edge():
|
|
76
|
+
for i in range(N):
|
|
77
|
+
yield {'source': i, 'target': i + 1}
|
|
78
|
+
yield {'source': N, 'target': 0}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# Materialize the GraphModel
|
|
82
|
+
graphinate.materialize(graph_model)
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## CLI
|
|
86
|
+
|
|
87
|
+
### Commands
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
Usage: python -m graphinate [OPTIONS] COMMAND [ARGS]...
|
|
91
|
+
|
|
92
|
+
Options:
|
|
93
|
+
--help Show this message and exit.
|
|
94
|
+
|
|
95
|
+
Commands:
|
|
96
|
+
save
|
|
97
|
+
server
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### Save
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
Usage: python -m graphinate save [OPTIONS] MODEL
|
|
104
|
+
|
|
105
|
+
Options:
|
|
106
|
+
--help Show this message and exit.
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
#### Server
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
Usage: python -m graphinate server [OPTIONS] MODEL
|
|
113
|
+
|
|
114
|
+
Options:
|
|
115
|
+
-p, --port INTEGER
|
|
116
|
+
--help Show this message and exit.
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## TUI
|
|
120
|
+
|
|
121
|
+
UNDER DEVELOPMENT
|
|
122
|
+
|
|
123
|
+
## Gallery
|
|
124
|
+
|
|
125
|
+
### Python AST
|
|
126
|
+
|
|
127
|
+

|
|
128
|
+
|
|
129
|
+
### GitHub Repository
|
|
130
|
+
|
|
131
|
+

|
|
132
|
+
|
|
133
|
+
### Python AST - 3D Force-Directed Animation
|
|
134
|
+
|
|
135
|
+

|
|
136
|
+
|
|
137
|
+
## Development
|
|
138
|
+
|
|
139
|
+
### Lint
|
|
140
|
+
|
|
141
|
+
```shell
|
|
142
|
+
ruff check src
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Docs
|
|
146
|
+
|
|
147
|
+
```shell
|
|
148
|
+
python -m mkdocs build
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Build
|
|
152
|
+
|
|
153
|
+
```shell
|
|
154
|
+
python -m build
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Test
|
|
158
|
+
|
|
159
|
+
```shell
|
|
160
|
+
python -m pytest ./tests --cov=./src --cov-branch --cov-report=xml --junitxml=test_results.xml
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Acknowledgements
|
|
164
|
+
|
|
165
|
+
### Dependencies
|
|
166
|
+
|
|
167
|
+
#### Python
|
|
168
|
+
|
|
169
|
+
<a href="https://palletsprojects.com/p/click/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://click.palletsprojects.com/en/7.x/_images/click-logo.png" alt="Click Logo."></a>
|
|
170
|
+
<a href="https://github.com/Delgan/loguru"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://raw.githubusercontent.com/Delgan/loguru/master/docs/_static/img/logo.png" alt="Loguru Logo."></a>
|
|
171
|
+
<a href="https://matplotlib.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://matplotlib.org/_static/logo_dark.svg" alt="matplotlib Logo."></a>
|
|
172
|
+
<a href="https://networkx.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://networkx.org/_static/networkx_logo.svg" alt="NetworkX Logo."></a>
|
|
173
|
+
<a href="https://strawberry.rocks/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/strawberry-graphql/strawberry/raw/main/.github/logo.png" alt="Strawberry GraphQL Logo."></a>
|
|
174
|
+
|
|
175
|
+
#### Javascript and HTML
|
|
176
|
+
|
|
177
|
+
<a href="https://vasturiano.github.io/3d-force-graph/"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="http://gist.github.com/vasturiano/02affe306ce445e423f992faeea13521/raw/preview.png" alt="3D Force-Directed Graph Logo."></a>
|
|
178
|
+
<a href="https://github.com/graphql-kit/graphql-voyager"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/graphql-kit/graphql-voyager/raw/main/docs/cover.png" alt="Graphql Voyager Logo."></a>
|
|
179
|
+
|
|
180
|
+
### Dev Tools
|
|
181
|
+
|
|
182
|
+
<a href="https://hatch.pypa.io/"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://hatch.pypa.io/latest/assets/images/logo.svg" alt="Hatch logo."></a>
|
|
183
|
+
<a href="https://pytest.org"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://docs.pytest.org/en/7.4.x/_static/pytest_logo_curves.svg" alt="pytest logo."></a>
|
|
184
|
+
<a href="https://astral.sh/ruff"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://astralcms.wpengine.com/wp-content/uploads/2023/03/Ruff-Logo.svg" alt="Ruff logo."></a>
|
|
185
|
+
|
|
186
|
+
### IDE
|
|
187
|
+
|
|
188
|
+
<a href="https://www.jetbrains.com/pycharm/"><img height="50" style="background: linear-gradient(-45deg, #FCF84A, #3DEA62, #21D789);" src="https://resources.jetbrains.com/storage/products/company/brand/logos/PyCharm.png" alt="PyCharm logo."></a>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Acknowledgements
|
|
2
|
+
|
|
3
|
+
## Dependencies
|
|
4
|
+
|
|
5
|
+
### Python
|
|
6
|
+
|
|
7
|
+
<a href="https://palletsprojects.com/p/click/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://click.palletsprojects.com/en/7.x/_images/click-logo.png" alt="Click Logo."></a>
|
|
8
|
+
<a href="https://github.com/Delgan/loguru"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://raw.githubusercontent.com/Delgan/loguru/master/docs/_static/img/logo.png" alt="Loguru Logo."></a>
|
|
9
|
+
<a href="https://matplotlib.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://matplotlib.org/_static/logo_dark.svg" alt="matplotlib Logo."></a>
|
|
10
|
+
<a href="https://networkx.org/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://networkx.org/_static/networkx_logo.svg" alt="NetworkX Logo."></a>
|
|
11
|
+
<a href="https://strawberry.rocks/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/strawberry-graphql/strawberry/raw/main/.github/logo.png" alt="Strawberry GraphQL Logo."></a>
|
|
12
|
+
|
|
13
|
+
### Javascript and HTML
|
|
14
|
+
|
|
15
|
+
<a href="https://vasturiano.github.io/3d-force-graph/"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="http://gist.github.com/vasturiano/02affe306ce445e423f992faeea13521/raw/preview.png" alt="3D Force-Directed Graph Logo."></a>
|
|
16
|
+
<a href="https://github.com/graphql-kit/graphql-voyager"><img height="50" style="padding: 5px; background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://github.com/graphql-kit/graphql-voyager/raw/main/docs/cover.png" alt="Graphql Voyager Logo."></a>
|
|
17
|
+
|
|
18
|
+
## Dev Tools
|
|
19
|
+
|
|
20
|
+
<a href="https://hatch.pypa.io/"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://hatch.pypa.io/latest/assets/images/logo.svg" alt="Hatch logo."></a>
|
|
21
|
+
<a href="https://pytest.org"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://docs.pytest.org/en/7.4.x/_static/pytest_logo_curves.svg" alt="pytest logo."></a>
|
|
22
|
+
<a href="https://astral.sh/ruff"><img height="50" style="background: linear-gradient(-45deg, #FFFFFF, #CCCCCC);" src="https://astralcms.wpengine.com/wp-content/uploads/2023/03/Ruff-Logo.svg" alt="Ruff logo."></a>
|
|
23
|
+
|
|
24
|
+
## IDE
|
|
25
|
+
|
|
26
|
+
<a href="https://www.jetbrains.com/pycharm/"><img height="50" style="background: linear-gradient(-45deg, #FCF84A, #3DEA62, #21D789);" src="https://resources.jetbrains.com/storage/products/company/brand/logos/PyCharm.png" alt="PyCharm logo."></a>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Gallery
|
|
2
|
+
|
|
3
|
+
## Python AST
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## GitHub Repository
|
|
8
|
+
|
|
9
|
+

|
|
10
|
+
|
|
11
|
+
## Python AST - 3D Force-Directed Animation
|
|
12
|
+
|
|
13
|
+

|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Graphinate. Data to Graphs.
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
[](https://github.com/erivlis/graphinate/graphs/contributors)
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
[](https://github.com/erivlis/graphinate/actions/workflows/test.yml)
|
|
13
|
+
[](https://github.com/erivlis/graphinate/actions/workflows/publish.yml)
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Introduction
|
|
2
|
+
|
|
3
|
+
## What is Graphinate?
|
|
4
|
+
|
|
5
|
+
Graphinate is a library that aims to simplify the generation of Graph Data Structures from Data Sources.
|
|
6
|
+
|
|
7
|
+
It utilizes and builds upon the excellent [**_NetworkX_**](https://networkx.org/) library.
|
|
8
|
+
|
|
9
|
+
In addition, it has several interfaces for ease of use:
|
|
10
|
+
|
|
11
|
+
- CLI (using [**_Click_**](https://palletsprojects.com/p/click/)),
|
|
12
|
+
- TUI (using [**_Textual_**](https://textual.textualize.io/)) **⚠️Not available yet⚠️**
|
|
13
|
+
- GraphQL API (using [**_Strawberry GraphQL_**](https://strawberry.rocks/)).
|
|
14
|
+
|
|
15
|
+
## What is a Graph?
|
|
16
|
+
|
|
17
|
+
“In a mathematician's terminology, a graph is a collection of points and lines connecting some (possibly empty) subset
|
|
18
|
+
of them. The points of a graph are most commonly known as graph vertices, but may also be called "nodes" or simply "
|
|
19
|
+
points." Similarly, the lines connecting the vertices of a graph are most commonly known as graph edges, but may also
|
|
20
|
+
be called "arcs" or "lines."”
|
|
21
|
+
|
|
22
|
+
— [https://mathworld.wolfram.com/Graph.html](https://mathworld.wolfram.com/Graph.html)
|
|
23
|
+
|
|
24
|
+
## What is Data?
|
|
25
|
+
|
|
26
|
+
“...data is a collection of discrete or continuous values that convey information, describing the quantity, quality,
|
|
27
|
+
fact, statistics, other basic units of meaning, or simply sequences of symbols that may be further interpreted
|
|
28
|
+
formally.”
|
|
29
|
+
|
|
30
|
+
— [https://en.wikipedia.org/wiki/Data](https://en.wikipedia.org/wiki/Data)
|
|
31
|
+
|
|
32
|
+
## A Graph as Data Structure
|
|
33
|
+
|
|
34
|
+
A Graph is a very useful data structure. They are the simplest data structure that is more the just simple collection of
|
|
35
|
+
entities. As such they can be used to model all data sources that have structure.
|
|
36
|
+
|
|
37
|
+
Let's start with a simple use case, The Social Network Graph.
|
|
38
|
+
|
|
39
|
+
## Defining a Graph
|
|
40
|
+
|
|
41
|
+
One can define a Graph in two general ways:
|
|
42
|
+
|
|
43
|
+
### Edge first
|
|
44
|
+
|
|
45
|
+
Generate a Graph by supplying a list of edges. The simplest definition of an edge will be a tuple of 2 values. Each
|
|
46
|
+
value represent a node (or vertex) in the graph. Additional attributes may be also added to the edge definition to
|
|
47
|
+
signify additional meaning.
|
|
48
|
+
|
|
49
|
+
In this case one defines the **edges explicitly** and the **nodes implicitly**.
|
|
50
|
+
|
|
51
|
+
Such graph is focused more on the _relationships_ or the _structure_ of the Graph than on the nodes themselves.
|
|
52
|
+
|
|
53
|
+
### Node first
|
|
54
|
+
|
|
55
|
+
Alternatively, one can first add nodes (vertices) to a graph without defining edges. Additional attributes may be added
|
|
56
|
+
to the node definition to signify additional meaning. Later on edge definitions are added to generate the relationships
|
|
57
|
+
between the nodes.
|
|
58
|
+
|
|
59
|
+
In this case **both nodes and the edges** are defines **explicitly**.
|
|
60
|
+
|
|
61
|
+
Such a graph has focus first on the nodes and later on the relationship between them.
|
|
62
|
+
|
|
63
|
+
## Graphinate - Hydrate a Graph from a Data Source
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
## Quick Start
|
|
3
|
+
|
|
4
|
+
Graphinate is designed to be used as library first and foremost. In addition, it has several interfaces for ease of
|
|
5
|
+
use: CLI, TUI (using [Textual]) and a GraphQL API (using [**_Strawberry GraphQL_**](https://strawberry.rocks/)).
|
|
6
|
+
|
|
7
|
+
### GraphModel
|
|
8
|
+
|
|
9
|
+
Graphinate defines the _**GraphModel**_ Class which can be used to declaratively register Edge and/or Node data
|
|
10
|
+
supplier functions by using decorators.
|
|
11
|
+
|
|
12
|
+
### Materialize
|
|
13
|
+
|
|
14
|
+
Graphinate supplies quick materialize function to output the GraphModel.
|
|
15
|
+
|
|
16
|
+
### Sample Code
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
import graphinate
|
|
20
|
+
|
|
21
|
+
# Define GraphModel
|
|
22
|
+
model = graphinate.GraphModel(name= "Octagonal Graph")
|
|
23
|
+
|
|
24
|
+
# Register edges supplier function
|
|
25
|
+
N: int = 8
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@model.edge()
|
|
29
|
+
def edge():
|
|
30
|
+
for i in range(N):
|
|
31
|
+
yield {'source': i, 'target': i + 1}
|
|
32
|
+
yield {'source': N, 'target': 0}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
# Materialize the GraphModel
|
|
36
|
+
graphinate.materialize(model)
|
|
37
|
+
```
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Usage
|
|
2
|
+
|
|
3
|
+
## Model
|
|
4
|
+
|
|
5
|
+
## Build
|
|
6
|
+
|
|
7
|
+
## Materialize
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### By Convention
|
|
14
|
+
|
|
15
|
+
https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/followers.py
|
|
16
|
+
|
|
17
|
+
### By Configuration
|
|
18
|
+
|
|
19
|
+
https://github.com/erivlis/graphinate/blob/f5b363a360907aecf52cf11249b78666eb470d20/examples/github/repositories.py
|
|
@@ -2,7 +2,7 @@ import ast
|
|
|
2
2
|
import inspect
|
|
3
3
|
import operator
|
|
4
4
|
from _ast import AST
|
|
5
|
-
from
|
|
5
|
+
from collections.abc import Iterable
|
|
6
6
|
|
|
7
7
|
import graphinate
|
|
8
8
|
import graphinate.builders
|
|
@@ -29,7 +29,7 @@ def _ast_edge(parsed_ast: AST):
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def ast_graph_model():
|
|
32
|
-
graph_model = graphinate.GraphModel(name='AST')
|
|
32
|
+
graph_model = graphinate.GraphModel(name='AST Graph')
|
|
33
33
|
|
|
34
34
|
root_ast_node = ast.parse(inspect.getsource(graphinate.builders.D3Builder))
|
|
35
35
|
|
|
@@ -58,4 +58,4 @@ def ast_graph_model():
|
|
|
58
58
|
|
|
59
59
|
if __name__ == '__main__':
|
|
60
60
|
ast_model = ast_graph_model()
|
|
61
|
-
graphinate.materialize(
|
|
61
|
+
graphinate.materialize(ast_model)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
PyGithub
|