Graphinate 0.2.12__tar.gz → 0.2.13__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.
Files changed (94) hide show
  1. {graphinate-0.2.12 → graphinate-0.2.13}/PKG-INFO +4 -4
  2. graphinate-0.2.13/docs/assets/images/logo-128.png +0 -0
  3. {graphinate-0.2.12 → graphinate-0.2.13}/docs/intro.md +32 -11
  4. {graphinate-0.2.12 → graphinate-0.2.13}/docs/usage/lib.md +4 -4
  5. {graphinate-0.2.12 → graphinate-0.2.13}/examples/code/python_dependencies.py +1 -1
  6. {graphinate-0.2.12 → graphinate-0.2.13}/mkdocs.yml +2 -2
  7. {graphinate-0.2.12 → graphinate-0.2.13}/pyproject.toml +5 -5
  8. graphinate-0.2.13/src/graphinate/server/__init__.py +108 -0
  9. graphinate-0.2.13/src/graphinate/server/web/elements/index.html +20 -0
  10. graphinate-0.2.13/src/graphinate/server/web/rapidoc/index.html +14 -0
  11. graphinate-0.2.13/src/graphinate/server/web/static/images/logo-128.png +0 -0
  12. graphinate-0.2.13/src/graphinate/server/web/voyager/__init__.py +0 -0
  13. graphinate-0.2.13/src/graphinate/tools/__init__.py +0 -0
  14. graphinate-0.2.12/docs/assets/images/logo-128.png +0 -0
  15. graphinate-0.2.12/src/graphinate/server/__init__.py +0 -48
  16. graphinate-0.2.12/src/graphinate/server/web/static/images/logo-128.png +0 -0
  17. {graphinate-0.2.12 → graphinate-0.2.13}/.coveragerc +0 -0
  18. {graphinate-0.2.12 → graphinate-0.2.13}/.github/dependabot.yml +0 -0
  19. {graphinate-0.2.12 → graphinate-0.2.13}/.github/workflows/codeql.yml +0 -0
  20. {graphinate-0.2.12 → graphinate-0.2.13}/.github/workflows/publish-docs.yaml +0 -0
  21. {graphinate-0.2.12 → graphinate-0.2.13}/.github/workflows/publish.yml +0 -0
  22. {graphinate-0.2.12 → graphinate-0.2.13}/.github/workflows/test-beta.yml +0 -0
  23. {graphinate-0.2.12 → graphinate-0.2.13}/.github/workflows/test.yml +0 -0
  24. {graphinate-0.2.12 → graphinate-0.2.13}/.gitignore +0 -0
  25. {graphinate-0.2.12 → graphinate-0.2.13}/LICENSE +0 -0
  26. {graphinate-0.2.12 → graphinate-0.2.13}/README.md +0 -0
  27. {graphinate-0.2.12 → graphinate-0.2.13}/STATS.md +0 -0
  28. {graphinate-0.2.12 → graphinate-0.2.13}/docs/acknowledge.md +0 -0
  29. {graphinate-0.2.12 → graphinate-0.2.13}/docs/assets/images/network_graph.png +0 -0
  30. {graphinate-0.2.12 → graphinate-0.2.13}/docs/assets/stylesheets/extra.css +0 -0
  31. {graphinate-0.2.12 → graphinate-0.2.13}/docs/dev.md +0 -0
  32. {graphinate-0.2.12 → graphinate-0.2.13}/docs/examples/code.md +0 -0
  33. {graphinate-0.2.12 → graphinate-0.2.13}/docs/examples/github.md +0 -0
  34. {graphinate-0.2.12 → graphinate-0.2.13}/docs/examples/math.md +0 -0
  35. {graphinate-0.2.12 → graphinate-0.2.13}/docs/examples/web.md +0 -0
  36. {graphinate-0.2.12 → graphinate-0.2.13}/docs/gen_ref_pages.py +0 -0
  37. {graphinate-0.2.12 → graphinate-0.2.13}/docs/index.md +0 -0
  38. {graphinate-0.2.12 → graphinate-0.2.13}/docs/start.md +0 -0
  39. {graphinate-0.2.12 → graphinate-0.2.13}/docs/usage/cli.md +0 -0
  40. {graphinate-0.2.12 → graphinate-0.2.13}/examples/code/python_ast.py +0 -0
  41. {graphinate-0.2.12 → graphinate-0.2.13}/examples/code/requirements.txt +0 -0
  42. {graphinate-0.2.12 → graphinate-0.2.13}/examples/github/_client.py +0 -0
  43. {graphinate-0.2.12 → graphinate-0.2.13}/examples/github/commits_visibilty_graph.py +0 -0
  44. {graphinate-0.2.12 → graphinate-0.2.13}/examples/github/followers.graphql +0 -0
  45. {graphinate-0.2.12 → graphinate-0.2.13}/examples/github/followers.py +0 -0
  46. {graphinate-0.2.12 → graphinate-0.2.13}/examples/github/graphql.config.yml +0 -0
  47. {graphinate-0.2.12 → graphinate-0.2.13}/examples/github/repositories.graphql +0 -0
  48. {graphinate-0.2.12 → graphinate-0.2.13}/examples/github/repositories.py +0 -0
  49. {graphinate-0.2.12 → graphinate-0.2.13}/examples/github/requirements.txt +0 -0
  50. {graphinate-0.2.12 → graphinate-0.2.13}/examples/math/graph_atlas.py +0 -0
  51. {graphinate-0.2.12 → graphinate-0.2.13}/examples/math/polygonal_graph.py +0 -0
  52. {graphinate-0.2.12 → graphinate-0.2.13}/examples/web/page_links.py +0 -0
  53. {graphinate-0.2.12 → graphinate-0.2.13}/examples/web/requirements.txt +0 -0
  54. {graphinate-0.2.12 → graphinate-0.2.13}/playground/ethernet/traceroute.py +0 -0
  55. {graphinate-0.2.12 → graphinate-0.2.13}/playground/genric_graph.graphql +0 -0
  56. {graphinate-0.2.12 → graphinate-0.2.13}/playground/graphql.config.yml +0 -0
  57. {graphinate-0.2.12 → graphinate-0.2.13}/playground/house_of_graphs.py +0 -0
  58. {graphinate-0.2.12 → graphinate-0.2.13}/playground/social/albums.json +0 -0
  59. {graphinate-0.2.12 → graphinate-0.2.13}/playground/social/musicisians.py +0 -0
  60. {graphinate-0.2.12 → graphinate-0.2.13}/playground/text/nlp_graph.py +0 -0
  61. {graphinate-0.2.12 → graphinate-0.2.13}/playground/text/requirements.txt +0 -0
  62. {graphinate-0.2.12 → graphinate-0.2.13}/playground/time_series/requirements.txt +0 -0
  63. {graphinate-0.2.12 → graphinate-0.2.13}/playground/time_series/visibility_graph.py +0 -0
  64. {graphinate-0.2.12 → graphinate-0.2.13}/sonar-project.properties +0 -0
  65. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/__init__.py +0 -0
  66. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/__main__.py +0 -0
  67. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/builders.py +0 -0
  68. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/cli.py +0 -0
  69. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/color.py +0 -0
  70. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/materializers/__init__.py +0 -0
  71. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/materializers/matplotlib.py +0 -0
  72. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/modeling.py +0 -0
  73. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/server/starlette/__init__.py +0 -0
  74. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/server/starlette/views.py +0 -0
  75. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/server/web/__init__.py +0 -0
  76. {graphinate-0.2.12/src/graphinate/server/web/graphiql → graphinate-0.2.13/src/graphinate/server/web/elements}/__init__.py +0 -0
  77. {graphinate-0.2.12/src/graphinate/server/web/viewer → graphinate-0.2.13/src/graphinate/server/web/graphiql}/__init__.py +0 -0
  78. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/server/web/graphiql/index.html +0 -0
  79. {graphinate-0.2.12/src/graphinate/server/web/voyager → graphinate-0.2.13/src/graphinate/server/web/rapidoc}/__init__.py +0 -0
  80. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/server/web/static/images/network_graph.png +0 -0
  81. {graphinate-0.2.12/src/graphinate/tools → graphinate-0.2.13/src/graphinate/server/web/viewer}/__init__.py +0 -0
  82. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/server/web/viewer/index.html +0 -0
  83. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/server/web/voyager/index.html +0 -0
  84. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/tools/gui.py +0 -0
  85. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/tools/mutators.py +0 -0
  86. {graphinate-0.2.12 → graphinate-0.2.13}/src/graphinate/typing.py +0 -0
  87. {graphinate-0.2.12 → graphinate-0.2.13}/tests/conftest.py +0 -0
  88. {graphinate-0.2.12 → graphinate-0.2.13}/tests/graphinate/test_builders.py +0 -0
  89. {graphinate-0.2.12 → graphinate-0.2.13}/tests/graphinate/test_cli.py +0 -0
  90. {graphinate-0.2.12 → graphinate-0.2.13}/tests/graphinate/test_color.py +0 -0
  91. {graphinate-0.2.12 → graphinate-0.2.13}/tests/graphinate/test_materializers.py +0 -0
  92. {graphinate-0.2.12 → graphinate-0.2.13}/tests/graphinate/test_modeling.py +0 -0
  93. {graphinate-0.2.12 → graphinate-0.2.13}/tests/graphinate/test_server.py +0 -0
  94. {graphinate-0.2.12 → graphinate-0.2.13}/tests/graphinate/test_tools.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: Graphinate
3
- Version: 0.2.12
3
+ Version: 0.2.13
4
4
  Summary: Graphinate. Data to Graphs.
5
5
  Project-URL: Homepage, https://erivlis.github.io/graphinate
6
6
  Project-URL: Documentation, https://erivlis.github.io/graphinate
@@ -30,9 +30,9 @@ Requires-Python: >=3.9
30
30
  Requires-Dist: click==8.1.7
31
31
  Requires-Dist: inflect==7.0.0
32
32
  Requires-Dist: loguru==0.7.2
33
- Requires-Dist: matplotlib==3.8.2
33
+ Requires-Dist: matplotlib==3.8.3
34
34
  Requires-Dist: networkx==3.2.1
35
- Requires-Dist: strawberry-graphql[asgi,opentelemetry]==0.219.1
35
+ Requires-Dist: strawberry-graphql[asgi,opentelemetry]==0.219.2
36
36
  Provides-Extra: dev
37
37
  Requires-Dist: pipdeptree; extra == 'dev'
38
38
  Requires-Dist: ruff; extra == 'dev'
@@ -50,7 +50,7 @@ Provides-Extra: server
50
50
  Requires-Dist: starlette-prometheus; extra == 'server'
51
51
  Requires-Dist: uvicorn[standard]>=0.27.0; extra == 'server'
52
52
  Provides-Extra: test
53
- Requires-Dist: faker>=23.1.0; extra == 'test'
53
+ Requires-Dist: faker>=23.2.1; extra == 'test'
54
54
  Requires-Dist: pytest-asyncio>=0.23.4; extra == 'test'
55
55
  Requires-Dist: pytest-cov>=4.1.0; extra == 'test'
56
56
  Requires-Dist: pytest-randomly>=3.15.0; extra == 'test'
@@ -6,8 +6,8 @@
6
6
 
7
7
  **Graphinate** is a python library that aims to simplify the generation of Graph Data Structures from Data Sources.
8
8
 
9
- It can help create an efficient retrieval pipeline from a given data source, while also enabling the developer to easily
10
- map data payloads and hierarchies to a Graph.
9
+ It can help create an efficient retrieval pipeline from a given data source, while also enabling the developer to map
10
+ data payloads and hierarchies to a Graph.
11
11
 
12
12
  In addition, there are several modes of output to enable examination of the Graph and its content.
13
13
 
@@ -49,14 +49,14 @@ A Graph consists of two types of elements:
49
49
  A Graph Node can be any Python Hashable object. Usually it will be a primitive type such as an integer or a string,
50
50
  in particular when the node in itself has no special meaning.
51
51
  One can also add attributes to the node to describe additional information.
52
- This information can include anything. Usually they are used to store scalar dimensions (e.g., area, width, age etc.)
52
+ This information can include anything. Often they are used to store scalar dimensions (e.g., weight, area, width, age etc.)
53
53
  or stylistic information (e.g., color, size, shape, label etc.).
54
54
 
55
55
  #### Edges
56
56
 
57
- A Graph Node is a tuple of two node values. It can also have additional attributes in the same vain as a Graph Node.
57
+ A Graph Edge is a tuple of two node values. It can also have additional attributes in the same vain as a Graph Node.
58
58
 
59
- ### Define a Graph
59
+ ### Defining a Graph
60
60
 
61
61
  One can define a Graph in two general ways:
62
62
 
@@ -68,7 +68,7 @@ definition to convey additional characteristics.
68
68
 
69
69
  In this case, one defines the **edges explicitly** and the **nodes implicitly**.
70
70
 
71
- Such a graph is focused more on the _relationships_ or the _structure_ of the graph than on the nodes themselves.
71
+ Such a graph is focused more on the _relationships_ between nodes or the _structure_ of the graph than on the nodes themselves.
72
72
 
73
73
  #### Node First
74
74
 
@@ -80,10 +80,31 @@ In this case, **both nodes and the edges** are defined **explicitly**.
80
80
 
81
81
  Such a graph has focus, first on the nodes, and then on the relationship between them.
82
82
 
83
- ### Graphinate - "Hydrate" a Graph from a Data Source
83
+ ### Graphinate
84
84
 
85
- Graphinate enable generating graphs from data sources.
85
+ "Hydrate" a Graph from a Data Source.
86
+ Using Graphinate enables generating graphs from data sources.
86
87
  It supports both *Edge First* and *Node First* creation scenarios.
87
- Data sources are represented as an Iterable of items that will be transformed to edges and/or nodes.
88
- Graphinate uses decorators to instruct how to transform the items Iterable to a graph element.
89
- It is recommended to use Generators as the items Iterables.
88
+
89
+ This is achieved following these steps:
90
+
91
+ #### Source
92
+
93
+ It is required to represent the Data sources as an Iterable of items that will be transformed to graph edges
94
+ and/or nodes.
95
+ It is recommended to use Generators as the items Iterables.
96
+
97
+ #### Model
98
+
99
+ Using Graphinate GraphMode decorators, we can define how to transform the items supplied by the data source generators,
100
+ to graph elements.
101
+
102
+ #### Build
103
+ A Graph Model can be used to generate an actual instance of a Graph.
104
+ It is achieved by using a GraphBuilder to both retrieve the data and assemble the Graph.
105
+ Several formats are available.
106
+
107
+ #### Materialize
108
+
109
+ Finally, we can use the builders to Materialize the graph in several ways that support different use cases
110
+ (i.e., visualizing, querying, reporting, etc.)
@@ -18,7 +18,7 @@
18
18
 
19
19
  ## SDK
20
20
 
21
- ### Modeling
21
+ ### Model
22
22
 
23
23
  * [`graphinate.GraphModel`](/reference/graphinate/modeling/#graphinate.modeling.GraphModel)
24
24
 
@@ -28,7 +28,7 @@
28
28
 
29
29
  * [`graphinate.NodeModel`](/reference/graphinate/modeling/#graphinate.modeling.NodeModel) - TBD
30
30
 
31
- ### Builders
31
+ ### Build
32
32
 
33
33
  * [`graphinate.builders.NetworkxBuilder`](/reference/graphinate/builders/#graphinate.builders.NetworkxBuilder) -
34
34
  Generates a NetworkX Graph instance.
@@ -39,10 +39,10 @@
39
39
  * [`graphinate.builders.GraphQLBuilder`](/reference/graphinate/builders/#graphinate.builders.GraphQLBuilder) - Generates
40
40
  a Strawberry GraphQL Schema instance
41
41
 
42
- ### Actualizers
42
+ ### Actualize
43
43
 
44
44
  > TBD
45
45
 
46
- ### Materializers
46
+ ### Materialize
47
47
 
48
48
  > TBD
@@ -28,5 +28,5 @@ if __name__ == '__main__':
28
28
  graphinate.materialize(
29
29
  dependency_model,
30
30
  builder=graphinate.builders.GraphQLBuilder,
31
- actualizer=graphinate.plot
31
+ actualizer=graphinate.graphql
32
32
  )
@@ -68,8 +68,8 @@ markdown_extensions:
68
68
  use_pygments: true
69
69
  pygments_lang_class: true
70
70
  - pymdownx.emoji:
71
- emoji_index: !!python/name:materialx.emoji.twemoji
72
- emoji_generator: !!python/name:materialx.emoji.to_svg
71
+ emoji_index: !!python/name:material.extensions.emoji.twemoji
72
+ emoji_generator: !!python/name:material.extensions.emoji.to_svg
73
73
  - pymdownx.inlinehilite
74
74
  - pymdownx.snippets
75
75
  - pymdownx.superfences
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "Graphinate"
3
- version = "0.2.12"
3
+ version = "0.2.13"
4
4
  authors = [
5
5
  { name = "Eran Rivlis", email = "eran@rivlis.info" },
6
6
  ]
@@ -31,9 +31,9 @@ dependencies = [
31
31
  "click==8.1.7",
32
32
  "inflect==7.0.0",
33
33
  "loguru==0.7.2",
34
- "matplotlib==3.8.2",
34
+ "matplotlib==3.8.3",
35
35
  "networkx==3.2.1",
36
- "strawberry-graphql[asgi,opentelemetry]==0.219.1"
36
+ "strawberry-graphql[asgi,opentelemetry]==0.219.2"
37
37
  ]
38
38
 
39
39
 
@@ -59,7 +59,7 @@ docs = [
59
59
  "mkdocs-section-index",
60
60
  ]
61
61
  test = [
62
- "faker>=23.1.0",
62
+ "faker>=23.2.1",
63
63
  "pytest>=7.4.4",
64
64
  "pytest-asyncio>=0.23.4",
65
65
  "pytest-cov>=4.1.0",
@@ -102,7 +102,7 @@ exclude_also = [
102
102
  "if TYPE_CHECKING:",
103
103
  "class .*\\bProtocol\\):",
104
104
  "@(abc\\.)?abstractmethod"
105
- ]
105
+ ]
106
106
 
107
107
 
108
108
  [tool.black]
@@ -0,0 +1,108 @@
1
+ import contextlib
2
+ import webbrowser
3
+
4
+ import strawberry
5
+ from starlette.applications import Starlette
6
+ from starlette.schemas import SchemaGenerator
7
+ from strawberry.asgi import GraphQL
8
+ from strawberry.extensions.tracing import OpenTelemetryExtension
9
+
10
+ from .starlette import routes
11
+
12
+ DEFAULT_PORT: int = 8072
13
+
14
+
15
+ def openapi_schema(request):
16
+ schema = SchemaGenerator(
17
+ {
18
+ "openapi": "3.0.0",
19
+ "info": {"title": "Graphinate API", "version": "1.0"},
20
+ "paths": {
21
+ "/graphql": {
22
+ "get": {
23
+ "responses": {
24
+ 200: {
25
+ "description": "GraphQL"
26
+ }
27
+ }
28
+ }
29
+ },
30
+ "/graphiql": {
31
+ "get": {
32
+ "responses": {
33
+ 200: {
34
+ "description": "GraphiQL UI."
35
+ }
36
+ }
37
+ }
38
+ },
39
+ "/metrics": {
40
+ "get": {
41
+ "responses": {
42
+ 200: {
43
+ "description": "Prometheus metrics."
44
+ }
45
+ }
46
+ }
47
+ },
48
+ "/viewer": {
49
+ "get": {
50
+ "responses": {
51
+ 200: {
52
+ "description": "3D Force-Directed Graph Viewer"
53
+ }
54
+ }
55
+ }
56
+ },
57
+ "/voyager": {
58
+ "get": {
59
+ "responses": {
60
+ 200: {
61
+ "description": "Voyager GraphQL Schema Viewer"
62
+ }
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ )
69
+ return schema.OpenAPIResponse(request=request)
70
+
71
+
72
+ def graphql(graphql_schema: strawberry.Schema, port: int = DEFAULT_PORT):
73
+ """
74
+
75
+ Args:
76
+ graphql_schema:
77
+ port:
78
+
79
+ Returns:
80
+
81
+ """
82
+ graphql_schema.extensions.append(OpenTelemetryExtension)
83
+
84
+ @contextlib.asynccontextmanager
85
+ async def lifespan(app: Starlette): # pragma: no cover
86
+ def open_url():
87
+ for app_name in ('voyager', 'graphiql', 'viewer'):
88
+ webbrowser.open(f'http://localhost:{port}/{app_name}')
89
+
90
+ open_url()
91
+ yield
92
+
93
+ graphql_app: GraphQL = GraphQL(graphql_schema)
94
+ app = Starlette(
95
+ lifespan=lifespan,
96
+ routes=routes()
97
+ )
98
+ app.add_route("/graphql", graphql_app)
99
+ app.add_websocket_route("/graphql", graphql_app)
100
+
101
+ from starlette_prometheus import PrometheusMiddleware, metrics
102
+ app.add_middleware(PrometheusMiddleware)
103
+ app.add_route("/metrics", metrics)
104
+
105
+ app.add_route("/schema", route=openapi_schema, include_in_schema=False)
106
+
107
+ import uvicorn
108
+ uvicorn.run(app, host='0.0.0.0', port=port)
@@ -0,0 +1,20 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6
+ <title>Elements in HTML</title>
7
+ <!-- Embed elements Elements via Web Component -->
8
+ <script src="https://unpkg.com/@stoplight/elements/web-components.min.js"></script>
9
+ <link rel="stylesheet" href="https://unpkg.com/@stoplight/elements/styles.min.css">
10
+ </head>
11
+ <body>
12
+
13
+ <elements-api
14
+ apiDescriptionUrl="/schema"
15
+ router="hash"
16
+ layout="sidebar"
17
+ />
18
+
19
+ </body>
20
+ </html>
@@ -0,0 +1,14 @@
1
+ <!doctype html> <!-- Important: must specify -->
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8"> <!-- Important: rapi-doc uses utf8 characters -->
5
+ <script type="module" src="https://unpkg.com/rapidoc/dist/rapidoc-min.js"></script>
6
+ <title>Graphinate OpenAPI</title>
7
+ </head>
8
+ <body>
9
+ <rapi-doc
10
+ spec-url="/schema"
11
+ theme = "dark"
12
+ > </rapi-doc>
13
+ </body>
14
+ </html>
File without changes
@@ -1,48 +0,0 @@
1
- import contextlib
2
- import webbrowser
3
-
4
- import strawberry
5
- from starlette.applications import Starlette
6
- from strawberry.asgi import GraphQL
7
- from strawberry.extensions.tracing import OpenTelemetryExtension
8
-
9
- from .starlette import routes
10
-
11
- DEFAULT_PORT: int = 8072
12
-
13
-
14
- def graphql(graphql_schema: strawberry.Schema, port: int = DEFAULT_PORT):
15
- """
16
-
17
- Args:
18
- graphql_schema:
19
- port:
20
-
21
- Returns:
22
-
23
- """
24
- graphql_schema.extensions.append(OpenTelemetryExtension)
25
-
26
- @contextlib.asynccontextmanager
27
- async def lifespan(app: Starlette): # pragma: no cover
28
- def open_url():
29
- for app_name in ('voyager', 'graphiql', 'viewer'):
30
- webbrowser.open(f'http://localhost:{port}/{app_name}')
31
-
32
- open_url()
33
- yield
34
-
35
- graphql_app: GraphQL = GraphQL(graphql_schema)
36
- app = Starlette(
37
- lifespan=lifespan,
38
- routes=routes()
39
- )
40
- app.add_route("/graphql", graphql_app)
41
- app.add_websocket_route("/graphql", graphql_app)
42
-
43
- from starlette_prometheus import PrometheusMiddleware, metrics
44
- app.add_middleware(PrometheusMiddleware)
45
- app.add_route("/metrics", metrics)
46
-
47
- import uvicorn
48
- uvicorn.run(app, host='0.0.0.0', port=port)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes