graphdatascience 2.2__py3-none-any.whl → 2.4__py3-none-any.whl

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 (207) hide show
  1. graphdatascience/arrow_client/arrow_endpoint_version.py +2 -2
  2. graphdatascience/arrow_client/authenticated_flight_client.py +2 -2
  3. graphdatascience/arrow_client/v1/gds_arrow_client.py +3 -3
  4. graphdatascience/arrow_client/v2/gds_arrow_client.py +4 -3
  5. graphdatascience/arrow_client/v2/job_client.py +3 -1
  6. graphdatascience/datasets/nx_loader.py +3 -4
  7. graphdatascience/datasets/ogb_loader.py +7 -13
  8. graphdatascience/embedding/config.py +2 -2
  9. graphdatascience/graph/graph_api.py +2 -2
  10. graphdatascience/graph_construction/cypher_graph_constructor.py +1 -1
  11. graphdatascience/graph_data_science.py +2 -2
  12. graphdatascience/procedure_surface/api/catalog/relationships_endpoints.py +5 -8
  13. graphdatascience/procedure_surface/api/centrality/__init__.py +44 -0
  14. graphdatascience/procedure_surface/api/centrality/articlerank_endpoints.py +2 -2
  15. graphdatascience/procedure_surface/api/centrality/articlerank_session_endpoints.py +76 -0
  16. graphdatascience/procedure_surface/api/centrality/articulationpoints_session_endpoints.py +59 -0
  17. graphdatascience/procedure_surface/api/centrality/betweenness_session_endpoints.py +68 -0
  18. graphdatascience/procedure_surface/api/centrality/bridges_session_endpoints.py +59 -0
  19. graphdatascience/procedure_surface/api/centrality/celf_session_endpoints.py +71 -0
  20. graphdatascience/procedure_surface/api/centrality/closeness_harmonic_session_endpoints.py +59 -0
  21. graphdatascience/procedure_surface/api/centrality/closeness_session_endpoints.py +73 -0
  22. graphdatascience/procedure_surface/api/centrality/degree_session_endpoints.py +65 -0
  23. graphdatascience/procedure_surface/api/centrality/eigenvector_session_endpoints.py +75 -0
  24. graphdatascience/procedure_surface/api/centrality/hits_endpoints.py +2 -2
  25. graphdatascience/procedure_surface/api/centrality/hits_session_endpoints.py +71 -0
  26. graphdatascience/procedure_surface/api/centrality/pagerank_endpoints.py +2 -2
  27. graphdatascience/procedure_surface/api/centrality/pagerank_session_endpoints.py +77 -0
  28. graphdatascience/procedure_surface/api/community/__init__.py +69 -1
  29. graphdatascience/procedure_surface/api/community/clique_counting_session_endpoints.py +59 -0
  30. graphdatascience/procedure_surface/api/community/conductance_session_endpoints.py +65 -0
  31. graphdatascience/procedure_surface/api/community/hdbscan_session_endpoints.py +71 -0
  32. graphdatascience/procedure_surface/api/community/k1coloring_session_endpoints.py +65 -0
  33. graphdatascience/procedure_surface/api/community/kcore_session_endpoints.py +59 -0
  34. graphdatascience/procedure_surface/api/community/kmeans_session_endpoints.py +86 -0
  35. graphdatascience/procedure_surface/api/community/labelpropagation_session_endpoints.py +74 -0
  36. graphdatascience/procedure_surface/api/community/leiden_session_endpoints.py +86 -0
  37. graphdatascience/procedure_surface/api/community/local_clustering_coefficient_session_endpoints.py +62 -0
  38. graphdatascience/procedure_surface/api/community/louvain_endpoints.py +9 -9
  39. graphdatascience/procedure_surface/api/community/louvain_session_endpoints.py +80 -0
  40. graphdatascience/procedure_surface/api/community/maxkcut_session_endpoints.py +74 -0
  41. graphdatascience/procedure_surface/api/community/modularity_optimization_session_endpoints.py +77 -0
  42. graphdatascience/procedure_surface/api/community/modularity_session_endpoints.py +65 -0
  43. graphdatascience/procedure_surface/api/community/scc_session_endpoints.py +62 -0
  44. graphdatascience/procedure_surface/api/community/sllpa_session_endpoints.py +68 -0
  45. graphdatascience/procedure_surface/api/community/triangle_count_endpoints.py +5 -5
  46. graphdatascience/procedure_surface/api/community/triangle_count_session_endpoints.py +65 -0
  47. graphdatascience/procedure_surface/api/community/triangles_endpoints.py +1 -1
  48. graphdatascience/procedure_surface/api/community/wcc_session_endpoints.py +71 -0
  49. graphdatascience/procedure_surface/api/node_embedding/__init__.py +28 -4
  50. graphdatascience/procedure_surface/api/node_embedding/fastpath_endpoints.py +18 -3
  51. graphdatascience/procedure_surface/api/node_embedding/fastpath_session_endpoints.py +102 -0
  52. graphdatascience/procedure_surface/api/node_embedding/fastrp_endpoints.py +17 -5
  53. graphdatascience/procedure_surface/api/node_embedding/fastrp_session_endpoints.py +84 -0
  54. graphdatascience/procedure_surface/api/node_embedding/graphsage_endpoints.py +8 -0
  55. graphdatascience/procedure_surface/api/node_embedding/graphsage_predict_endpoints.py +12 -0
  56. graphdatascience/procedure_surface/api/node_embedding/graphsage_supervised_endpoints.py +16 -0
  57. graphdatascience/procedure_surface/api/node_embedding/graphsage_supervised_model.py +15 -0
  58. graphdatascience/procedure_surface/api/node_embedding/graphsage_supervised_session_endpoints.py +63 -0
  59. graphdatascience/procedure_surface/api/node_embedding/graphsage_train_endpoints.py +4 -0
  60. graphdatascience/procedure_surface/api/node_embedding/graphsage_unsupervised_endpoints.py +16 -0
  61. graphdatascience/procedure_surface/api/node_embedding/graphsage_unsupervised_model.py +18 -0
  62. graphdatascience/procedure_surface/api/node_embedding/graphsage_unsupervised_session_endpoints.py +63 -0
  63. graphdatascience/procedure_surface/api/node_embedding/hashgnn_endpoints.py +12 -0
  64. graphdatascience/procedure_surface/api/node_embedding/hashgnn_session_endpoints.py +90 -0
  65. graphdatascience/procedure_surface/api/node_embedding/node2vec_endpoints.py +12 -0
  66. graphdatascience/procedure_surface/api/node_embedding/node2vec_session_endpoints.py +110 -0
  67. graphdatascience/procedure_surface/api/pathfinding/__init__.py +85 -9
  68. graphdatascience/procedure_surface/api/pathfinding/all_shortest_path_session_endpoints.py +80 -0
  69. graphdatascience/procedure_surface/api/pathfinding/bfs_endpoints.py +4 -4
  70. graphdatascience/procedure_surface/api/pathfinding/bfs_session_endpoints.py +68 -0
  71. graphdatascience/procedure_surface/api/pathfinding/dfs_endpoints.py +4 -4
  72. graphdatascience/procedure_surface/api/pathfinding/dfs_session_endpoints.py +68 -0
  73. graphdatascience/procedure_surface/api/pathfinding/dijkstra_endpoints.py +4 -4
  74. graphdatascience/procedure_surface/api/pathfinding/dijkstra_session_endpoints.py +68 -0
  75. graphdatascience/procedure_surface/api/pathfinding/k_spanning_tree_session_endpoints.py +71 -0
  76. graphdatascience/procedure_surface/api/pathfinding/longest_path_session_endpoints.py +62 -0
  77. graphdatascience/procedure_surface/api/pathfinding/max_flow_min_cost_session_endpoints.py +77 -0
  78. graphdatascience/procedure_surface/api/pathfinding/max_flow_session_endpoints.py +80 -0
  79. graphdatascience/procedure_surface/api/pathfinding/prize_steiner_tree_session_endpoints.py +65 -0
  80. graphdatascience/procedure_surface/api/pathfinding/random_walk_session_endpoints.py +82 -0
  81. graphdatascience/procedure_surface/api/pathfinding/shortest_path_session_endpoints.py +36 -0
  82. graphdatascience/procedure_surface/api/pathfinding/single_source_bellman_ford_session_endpoints.py +65 -0
  83. graphdatascience/procedure_surface/api/pathfinding/single_source_delta_session_endpoints.py +68 -0
  84. graphdatascience/procedure_surface/api/pathfinding/single_source_dijkstra_session_endpoints.py +65 -0
  85. graphdatascience/procedure_surface/api/pathfinding/source_target_astar_session_endpoints.py +74 -0
  86. graphdatascience/procedure_surface/api/pathfinding/source_target_dijkstra_endpoints.py +4 -4
  87. graphdatascience/procedure_surface/api/pathfinding/source_target_dijkstra_session_endpoints.py +68 -0
  88. graphdatascience/procedure_surface/api/pathfinding/source_target_yens_session_endpoints.py +71 -0
  89. graphdatascience/procedure_surface/api/pathfinding/spanning_tree_session_endpoints.py +68 -0
  90. graphdatascience/procedure_surface/api/pathfinding/steiner_tree_endpoints.py +1 -1
  91. graphdatascience/procedure_surface/api/pathfinding/steiner_tree_session_endpoints.py +74 -0
  92. graphdatascience/procedure_surface/api/pipeline/node_regression_metric.py +2 -2
  93. graphdatascience/procedure_surface/api/projection_job_handle.py +13 -1
  94. graphdatascience/procedure_surface/api/similarity/__init__.py +16 -0
  95. graphdatascience/procedure_surface/api/similarity/knn_filtered_session_endpoints.py +98 -0
  96. graphdatascience/procedure_surface/api/similarity/knn_session_endpoints.py +98 -0
  97. graphdatascience/procedure_surface/api/similarity/node_similarity_endpoints.py +5 -5
  98. graphdatascience/procedure_surface/api/similarity/node_similarity_filtered_session_endpoints.py +95 -0
  99. graphdatascience/procedure_surface/api/similarity/node_similarity_session_endpoints.py +97 -0
  100. graphdatascience/procedure_surface/api/topological_link_prediction_endpoints.py +2 -2
  101. graphdatascience/procedure_surface/arrow/catalog/catalog_arrow_endpoints.py +35 -5
  102. graphdatascience/procedure_surface/arrow/catalog/graph_backend_arrow.py +8 -2
  103. graphdatascience/procedure_surface/arrow/catalog/graph_ops_arrow.py +13 -2
  104. graphdatascience/procedure_surface/arrow/catalog/graph_sampling_arrow_endpoints.py +13 -2
  105. graphdatascience/procedure_surface/arrow/catalog/node_properties_arrow_endpoints.py +2 -1
  106. graphdatascience/procedure_surface/arrow/catalog/projection_arrow_endpoints.py +48 -15
  107. graphdatascience/procedure_surface/arrow/centrality/articlerank_arrow_endpoints.py +4 -2
  108. graphdatascience/procedure_surface/arrow/centrality/articulationpoints_arrow_endpoints.py +4 -2
  109. graphdatascience/procedure_surface/arrow/centrality/betweenness_arrow_endpoints.py +4 -2
  110. graphdatascience/procedure_surface/arrow/centrality/bridges_arrow_endpoints.py +4 -2
  111. graphdatascience/procedure_surface/arrow/centrality/celf_arrow_endpoints.py +4 -2
  112. graphdatascience/procedure_surface/arrow/centrality/closeness_arrow_endpoints.py +8 -4
  113. graphdatascience/procedure_surface/arrow/centrality/closeness_harmonic_arrow_endpoints.py +4 -2
  114. graphdatascience/procedure_surface/arrow/centrality/degree_arrow_endpoints.py +4 -2
  115. graphdatascience/procedure_surface/arrow/centrality/eigenvector_arrow_endpoints.py +4 -2
  116. graphdatascience/procedure_surface/arrow/centrality/hits_arrow_endpoints.py +4 -2
  117. graphdatascience/procedure_surface/arrow/centrality/pagerank_arrow_endpoints.py +8 -2
  118. graphdatascience/procedure_surface/arrow/community/clique_counting_arrow_endpoints.py +4 -2
  119. graphdatascience/procedure_surface/arrow/community/conductance_arrow_endpoints.py +4 -2
  120. graphdatascience/procedure_surface/arrow/community/hdbscan_arrow_endpoints.py +4 -2
  121. graphdatascience/procedure_surface/arrow/community/k1coloring_arrow_endpoints.py +4 -2
  122. graphdatascience/procedure_surface/arrow/community/kcore_arrow_endpoints.py +4 -2
  123. graphdatascience/procedure_surface/arrow/community/kmeans_arrow_endpoints.py +4 -2
  124. graphdatascience/procedure_surface/arrow/community/labelpropagation_arrow_endpoints.py +4 -2
  125. graphdatascience/procedure_surface/arrow/community/leiden_arrow_endpoints.py +4 -2
  126. graphdatascience/procedure_surface/arrow/community/local_clustering_coefficient_arrow_endpoints.py +4 -2
  127. graphdatascience/procedure_surface/arrow/community/louvain_arrow_endpoints.py +4 -2
  128. graphdatascience/procedure_surface/arrow/community/maxkcut_arrow_endpoints.py +4 -2
  129. graphdatascience/procedure_surface/arrow/community/modularity_arrow_endpoints.py +4 -2
  130. graphdatascience/procedure_surface/arrow/community/modularity_optimization_arrow_endpoints.py +4 -2
  131. graphdatascience/procedure_surface/arrow/community/scc_arrow_endpoints.py +4 -2
  132. graphdatascience/procedure_surface/arrow/community/sllpa_arrow_endpoints.py +4 -2
  133. graphdatascience/procedure_surface/arrow/community/triangle_count_arrow_endpoints.py +10 -8
  134. graphdatascience/procedure_surface/arrow/community/triangles_arrow_endpoints.py +1 -1
  135. graphdatascience/procedure_surface/arrow/community/wcc_arrow_endpoints.py +4 -2
  136. graphdatascience/procedure_surface/arrow/node_embedding/fastpath_arrow_endpoints.py +16 -6
  137. graphdatascience/procedure_surface/arrow/node_embedding/fastrp_arrow_endpoints.py +12 -2
  138. graphdatascience/procedure_surface/arrow/node_embedding/graphsage_predict_arrow_endpoints.py +8 -0
  139. graphdatascience/procedure_surface/arrow/node_embedding/graphsage_session_endpoints.py +12 -10
  140. graphdatascience/procedure_surface/arrow/node_embedding/graphsage_supervised_arrow_endpoints.py +15 -4
  141. graphdatascience/procedure_surface/arrow/node_embedding/graphsage_train_arrow_endpoints.py +4 -0
  142. graphdatascience/procedure_surface/arrow/node_embedding/graphsage_unsupervised_arrow_endpoints.py +15 -4
  143. graphdatascience/procedure_surface/arrow/node_embedding/hashgnn_arrow_endpoints.py +12 -2
  144. graphdatascience/procedure_surface/arrow/node_embedding/node2vec_arrow_endpoints.py +12 -2
  145. graphdatascience/procedure_surface/arrow/pathfinding/all_shortest_path_arrow_endpoints.py +11 -7
  146. graphdatascience/procedure_surface/arrow/pathfinding/bfs_arrow_endpoints.py +4 -2
  147. graphdatascience/procedure_surface/arrow/pathfinding/dfs_arrow_endpoints.py +4 -2
  148. graphdatascience/procedure_surface/arrow/pathfinding/dijkstra_arrow_endpoints.py +4 -2
  149. graphdatascience/procedure_surface/arrow/pathfinding/k_spanning_tree_arrow_endpoints.py +4 -2
  150. graphdatascience/procedure_surface/arrow/pathfinding/longest_path_arrow_endpoints.py +4 -2
  151. graphdatascience/procedure_surface/arrow/pathfinding/max_flow_arrow_endpoints.py +8 -4
  152. graphdatascience/procedure_surface/arrow/pathfinding/max_flow_min_cost_arrow_endpoints.py +4 -2
  153. graphdatascience/procedure_surface/arrow/pathfinding/prize_steiner_tree_arrow_endpoints.py +4 -2
  154. graphdatascience/procedure_surface/arrow/pathfinding/random_walk_arrow_endpoints.py +4 -2
  155. graphdatascience/procedure_surface/arrow/pathfinding/shortest_path_arrow_endpoints.py +12 -12
  156. graphdatascience/procedure_surface/arrow/pathfinding/single_source_bellman_ford_arrow_endpoints.py +4 -2
  157. graphdatascience/procedure_surface/arrow/pathfinding/single_source_delta_arrow_endpoints.py +4 -2
  158. graphdatascience/procedure_surface/arrow/pathfinding/single_source_dijkstra_arrow_endpoints.py +4 -2
  159. graphdatascience/procedure_surface/arrow/pathfinding/source_target_astar_arrow_endpoints.py +4 -2
  160. graphdatascience/procedure_surface/arrow/pathfinding/source_target_dijkstra_arrow_endpoints.py +4 -2
  161. graphdatascience/procedure_surface/arrow/pathfinding/source_target_yens_arrow_endpoints.py +4 -2
  162. graphdatascience/procedure_surface/arrow/pathfinding/spanning_tree_arrow_endpoints.py +4 -2
  163. graphdatascience/procedure_surface/arrow/pathfinding/steiner_tree_arrow_endpoints.py +4 -2
  164. graphdatascience/procedure_surface/arrow/similarity/knn_arrow_endpoints.py +8 -4
  165. graphdatascience/procedure_surface/arrow/similarity/knn_filtered_arrow_endpoints.py +4 -2
  166. graphdatascience/procedure_surface/arrow/similarity/node_similarity_arrow_endpoints.py +7 -5
  167. graphdatascience/procedure_surface/arrow/similarity/node_similarity_filtered_arrow_endpoints.py +3 -3
  168. graphdatascience/procedure_surface/arrow/stream_result_mapper.py +44 -51
  169. graphdatascience/procedure_surface/cypher/catalog/projection_cypher_endpoints.py +5 -4
  170. graphdatascience/procedure_surface/cypher/community/triangle_count_cypher_endpoints.py +5 -5
  171. graphdatascience/procedure_surface/cypher/community/triangles_cypher_endpoints.py +1 -1
  172. graphdatascience/procedure_surface/cypher/node_embedding/fastrp_cypher_endpoints.py +7 -0
  173. graphdatascience/procedure_surface/cypher/node_embedding/graphsage_predict_cypher_endpoints.py +7 -0
  174. graphdatascience/procedure_surface/cypher/node_embedding/graphsage_train_cypher_endpoints.py +26 -0
  175. graphdatascience/procedure_surface/cypher/node_embedding/hashgnn_cypher_endpoints.py +7 -0
  176. graphdatascience/procedure_surface/cypher/node_embedding/node2vec_cypher_endpoints.py +7 -0
  177. graphdatascience/procedure_surface/cypher/result_as_vector_utils.py +25 -0
  178. graphdatascience/procedure_surface/utils/gpu_config.py +3 -0
  179. graphdatascience/procedure_surface/utils/result_utils.py +1 -1
  180. graphdatascience/progress/progress_bar.py +4 -4
  181. graphdatascience/progress/query_progress_provider.py +1 -1
  182. graphdatascience/query_runner/neo4j_query_runner.py +31 -18
  183. graphdatascience/query_runner/query_mode.py +2 -2
  184. graphdatascience/query_runner/query_runner.py +2 -2
  185. graphdatascience/query_runner/query_type.py +2 -2
  186. graphdatascience/resources/imdb/serialize_imdb.py +6 -6
  187. graphdatascience/resources/lastfm/serialize_lastfm.py +5 -5
  188. graphdatascience/retry_utils/neo4j_retry_helper.py +20 -0
  189. graphdatascience/session/algorithm_category.py +2 -2
  190. graphdatascience/session/aura_api.py +5 -0
  191. graphdatascience/session/aura_api_responses.py +30 -15
  192. graphdatascience/session/aura_graph_data_science.py +195 -103
  193. graphdatascience/session/dbms/instance_type_resolver.py +39 -0
  194. graphdatascience/session/dbms/protocol_version.py +2 -2
  195. graphdatascience/session/dbms_connection_info.py +1 -1
  196. graphdatascience/session/gds_sessions.py +50 -53
  197. graphdatascience/session/graph_mapping_context.py +54 -0
  198. graphdatascience/session/graph_mappings_api.py +81 -0
  199. graphdatascience/session/instance_type.py +39 -0
  200. graphdatascience/session/session_target.py +145 -0
  201. graphdatascience/utils.py +22 -0
  202. graphdatascience/version.py +1 -1
  203. {graphdatascience-2.2.dist-info → graphdatascience-2.4.dist-info}/METADATA +4 -5
  204. {graphdatascience-2.2.dist-info → graphdatascience-2.4.dist-info}/RECORD +207 -142
  205. {graphdatascience-2.2.dist-info → graphdatascience-2.4.dist-info}/WHEEL +1 -1
  206. {graphdatascience-2.2.dist-info → graphdatascience-2.4.dist-info}/licenses/LICENSE +0 -0
  207. {graphdatascience-2.2.dist-info → graphdatascience-2.4.dist-info}/top_level.txt +0 -0
@@ -1,11 +1,11 @@
1
1
  from __future__ import annotations
2
2
 
3
- from enum import Enum
3
+ from enum import StrEnum
4
4
 
5
5
  from graphdatascience.arrow_client.authenticated_flight_client import AuthenticatedArrowClient
6
6
 
7
7
 
8
- class ArrowEndpointVersion(Enum):
8
+ class ArrowEndpointVersion(StrEnum):
9
9
  V1 = "v1"
10
10
  V2 = "v2"
11
11
 
@@ -7,7 +7,7 @@ import platform
7
7
  import socket
8
8
  from dataclasses import dataclass
9
9
  from types import TracebackType
10
- from typing import Any, Callable, Iterator, Type, TypeVar
10
+ from typing import Any, Callable, Iterator, Self, Type, TypeVar
11
11
 
12
12
  import certifi
13
13
  from pyarrow import Schema, flight
@@ -274,7 +274,7 @@ class AuthenticatedArrowClient:
274
274
  except OSError:
275
275
  return False
276
276
 
277
- def __enter__(self) -> AuthenticatedArrowClient:
277
+ def __enter__(self) -> Self:
278
278
  return self
279
279
 
280
280
  def __exit__(
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import json
4
4
  import logging
5
5
  from types import TracebackType
6
- from typing import Any, Iterable, Type
6
+ from typing import Any, Iterable, Self, Type
7
7
 
8
8
  import pandas
9
9
  import pyarrow
@@ -83,7 +83,7 @@ class GdsArrowClient:
83
83
 
84
84
  result = self._get_data(graph_name, database, proc, concurrency, config)
85
85
  if list_node_labels:
86
- result.rename(columns={"labels": "nodeLabels"}, inplace=True)
86
+ result = result.rename(columns={"labels": "nodeLabels"})
87
87
 
88
88
  return result
89
89
 
@@ -567,7 +567,7 @@ class GdsArrowClient:
567
567
  arrow_table = self._sanitize_arrow_table(arrow_table)
568
568
  return arrow_table.to_pandas(types_mapper=pandas.ArrowDtype) # type: ignore
569
569
 
570
- def __enter__(self) -> GdsArrowClient:
570
+ def __enter__(self) -> Self:
571
571
  return self
572
572
 
573
573
  def __exit__(
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import json
4
4
  import logging
5
5
  from types import TracebackType
6
- from typing import Any, Type
6
+ from typing import Any, Self, Type
7
7
 
8
8
  import pandas
9
9
  import pyarrow
@@ -13,6 +13,7 @@ from graphdatascience.arrow_client.arrow_endpoint_version import ArrowEndpointVe
13
13
  from graphdatascience.arrow_client.arrow_table_utils import table_from_pandas
14
14
  from graphdatascience.arrow_client.authenticated_flight_client import AuthenticatedArrowClient, ConnectionInfo
15
15
  from graphdatascience.query_runner.termination_flag import TerminationFlag
16
+ from graphdatascience.utils import as_list
16
17
 
17
18
  from ...procedure_surface.api.default_values import ALL_TYPES
18
19
  from ...procedure_surface.utils.config_converter import ConfigConverter
@@ -71,7 +72,7 @@ class GdsArrowClient:
71
72
  str
72
73
  The JobId identifying the export process
73
74
  """
74
- normalized_properties = node_properties if isinstance(node_properties, list) else [node_properties]
75
+ normalized_properties = as_list(node_properties)
75
76
 
76
77
  config = ConfigConverter.convert_to_gds_config(
77
78
  graph_name=graph_name,
@@ -547,7 +548,7 @@ class GdsArrowClient:
547
548
  ack_stream.read()
548
549
  progress_callback(partition.num_rows)
549
550
 
550
- def __enter__(self) -> GdsArrowClient:
551
+ def __enter__(self) -> Self:
551
552
  return self
552
553
 
553
554
  def __exit__(
@@ -111,7 +111,9 @@ class JobClient:
111
111
  ):
112
112
  with attempt:
113
113
  try:
114
- res = client.do_action_with_retry(endpoint, config)
114
+ # a submission is not retried here: a timed-out call may still have landed on
115
+ # the server, so only the status check below decides whether to send it again
116
+ res = list(client.do_action(endpoint, config))
115
117
  return JobIdConfig(**deserialize_single(res)).job_id
116
118
  except FLIGHT_TRANSIENT_EXCEPTIONS as e:
117
119
  try:
@@ -6,6 +6,7 @@ from pandas import DataFrame
6
6
 
7
7
  from graphdatascience.datasets.graph_constructor_func import GraphConstructorFunc
8
8
  from graphdatascience.graph import Graph
9
+ from graphdatascience.utils import as_list
9
10
 
10
11
 
11
12
  class NXLoader:
@@ -41,10 +42,8 @@ class NXLoader:
41
42
  node_labels: list[str]
42
43
  if no_node_labels:
43
44
  node_labels = ["N"]
44
- elif isinstance(labels_attr, str):
45
- node_labels = [labels_attr]
46
- elif isinstance(labels_attr, list):
47
- node_labels = labels_attr
45
+ elif isinstance(labels_attr, (str, list)):
46
+ node_labels = as_list(labels_attr)
48
47
  else:
49
48
  raise ValueError(
50
49
  "`labels` node attributes must be of type `str` or `list[str]`. "
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import logging
4
4
  from abc import ABC, abstractmethod
5
- from typing import Any, Protocol, TypedDict
5
+ from typing import Any, NotRequired, Protocol, TypedDict
6
6
  from warnings import warn
7
7
 
8
8
  import numpy as np
@@ -13,24 +13,18 @@ from graphdatascience.datasets.graph_constructor_func import GraphConstructorFun
13
13
  from graphdatascience.graph import Graph
14
14
 
15
15
 
16
- class _HomogeneousOGBGraphBase(TypedDict):
16
+ class HomogeneousOGBGraph(TypedDict):
17
17
  edge_index: npt.NDArray[np.int64]
18
18
  num_nodes: int
19
+ edge_feat: NotRequired[npt.NDArray[np.float64] | None]
20
+ node_feat: NotRequired[npt.NDArray[np.float64] | None]
19
21
 
20
22
 
21
- class HomogeneousOGBGraph(_HomogeneousOGBGraphBase, total=False):
22
- edge_feat: npt.NDArray[np.float64] | None
23
- node_feat: npt.NDArray[np.float64] | None
24
-
25
-
26
- class _HeterogeneousOGBGraphBase(TypedDict):
23
+ class HeterogeneousOGBGraph(TypedDict):
27
24
  edge_index_dict: dict[tuple[str, str, str], npt.NDArray[np.int64]]
28
25
  num_nodes_dict: dict[str, int]
29
-
30
-
31
- class HeterogeneousOGBGraph(_HeterogeneousOGBGraphBase, total=False):
32
- edge_feat_dict: dict[tuple[str, str, str], npt.NDArray[np.float64]]
33
- node_feat_dict: dict[str, npt.NDArray[np.float64]]
26
+ edge_feat_dict: NotRequired[dict[tuple[str, str, str], npt.NDArray[np.float64]]]
27
+ node_feat_dict: NotRequired[dict[str, npt.NDArray[np.float64]]]
34
28
 
35
29
 
36
30
  class HomogeneousOGBNDataset(Protocol):
@@ -1,4 +1,4 @@
1
- from typing import Annotated, Literal
1
+ from typing import Annotated, Literal, Self
2
2
 
3
3
  from annotated_types import Len
4
4
  from pydantic import BaseModel, Field, PositiveInt, model_validator
@@ -24,7 +24,7 @@ class GraphSAGEConfig(BaseModel):
24
24
  dropout: Dropout | None = Field(default=None, description="Dropout probability applied during training.")
25
25
 
26
26
  @model_validator(mode="after")
27
- def depth_validator(self) -> "GraphSAGEConfig":
27
+ def depth_validator(self) -> Self:
28
28
  if self.hidden_dims is not None:
29
29
  if self.num_neighbors is not None:
30
30
  if len(self.hidden_dims) + 1 != len(self.num_neighbors):
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  from datetime import datetime
4
4
  from types import TracebackType
5
- from typing import Any, Type
5
+ from typing import Any, Self, Type
6
6
 
7
7
  from graphdatascience.graph.graph_backend import GraphBackend
8
8
  from graphdatascience.graph.graph_info import GraphInfo
@@ -19,7 +19,7 @@ class Graph:
19
19
  self._name = name
20
20
  self._backend = backend
21
21
 
22
- def __enter__(self: Graph) -> Graph:
22
+ def __enter__(self) -> Self:
23
23
  return self
24
24
 
25
25
  def __exit__(
@@ -146,7 +146,7 @@ class CypherGraphConstructor(GraphConstructor):
146
146
  # this way we don't duplicate the node property data and its cheaper
147
147
  combined_df: DataFrame = concat(aligned_node_dfs + aligned_rel_dfs, ignore_index=True)
148
148
  # sort the columns to ensure the order is the same (for testing)
149
- combined_df.sort_index(axis="columns", inplace=True)
149
+ combined_df = combined_df.sort_index(axis="columns")
150
150
  # using a list and not a set to preserve the order
151
151
  combined_cols: list[str] = combined_df.columns.tolist()
152
152
 
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import warnings
4
4
  from types import TracebackType
5
- from typing import Any, Literal, Type
5
+ from typing import Any, Literal, Self, Type
6
6
 
7
7
  import neo4j
8
8
  from neo4j import Driver
@@ -972,7 +972,7 @@ class GraphDataScience:
972
972
  self._arrow_client.close()
973
973
  self._query_runner.close()
974
974
 
975
- def __enter__(self) -> GraphDataScience:
975
+ def __enter__(self) -> Self:
976
976
  return self
977
977
 
978
978
  def __exit__(
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from abc import ABC, abstractmethod
4
- from enum import Enum
4
+ from enum import StrEnum
5
5
  from typing import Any
6
6
 
7
7
  from pydantic import AliasChoices, Field, field_validator
@@ -10,6 +10,7 @@ from graphdatascience.graph.graph_api import Graph
10
10
  from graphdatascience.procedure_surface.api.base_result import BaseResult
11
11
  from graphdatascience.procedure_surface.api.catalog.relationships_data_frame import RelationshipsDataFrame
12
12
  from graphdatascience.procedure_surface.api.default_values import ALL_LABELS, ALL_TYPES
13
+ from graphdatascience.utils import as_list
13
14
 
14
15
 
15
16
  class RelationshipsEndpoints(ABC):
@@ -276,12 +277,8 @@ class RelationshipsWriteResult(BaseResult):
276
277
  @field_validator("relationship_properties", mode="before")
277
278
  @classmethod
278
279
  def coerce_relationship_properties(cls, v: Any) -> list[str]:
279
- if v is None:
280
- return []
281
- elif isinstance(v, str):
282
- return [v]
283
- else:
284
- return v # type: ignore
280
+ coerced = as_list(v)
281
+ return [] if coerced is None else coerced
285
282
 
286
283
 
287
284
  class RelationshipsDropResult(BaseResult):
@@ -312,7 +309,7 @@ class CollapsePathResult(BaseResult):
312
309
  configuration: dict[str, Any]
313
310
 
314
311
 
315
- class Aggregation(str, Enum):
312
+ class Aggregation(StrEnum):
316
313
  """
317
314
  Specifies how to aggregate parallel relationships in a graph.
318
315
  """
@@ -4,25 +4,40 @@ from graphdatascience.procedure_surface.api.centrality.articlerank_endpoints imp
4
4
  ArticleRankStatsResult,
5
5
  ArticleRankWriteResult,
6
6
  )
7
+ from graphdatascience.procedure_surface.api.centrality.articlerank_session_endpoints import (
8
+ ArticleRankSessionEndpoints,
9
+ )
7
10
  from graphdatascience.procedure_surface.api.centrality.articulationpoints_endpoints import (
8
11
  ArticulationPointsEndpoints,
9
12
  ArticulationPointsMutateResult,
10
13
  ArticulationPointsStatsResult,
11
14
  ArticulationPointsWriteResult,
12
15
  )
16
+ from graphdatascience.procedure_surface.api.centrality.articulationpoints_session_endpoints import (
17
+ ArticulationPointsSessionEndpoints,
18
+ )
13
19
  from graphdatascience.procedure_surface.api.centrality.betweenness_endpoints import (
14
20
  BetweennessEndpoints,
15
21
  BetweennessMutateResult,
16
22
  BetweennessStatsResult,
17
23
  BetweennessWriteResult,
18
24
  )
25
+ from graphdatascience.procedure_surface.api.centrality.betweenness_session_endpoints import (
26
+ BetweennessSessionEndpoints,
27
+ )
19
28
  from graphdatascience.procedure_surface.api.centrality.bridges_endpoints import BridgesEndpoints
29
+ from graphdatascience.procedure_surface.api.centrality.bridges_session_endpoints import (
30
+ BridgesSessionEndpoints,
31
+ )
20
32
  from graphdatascience.procedure_surface.api.centrality.celf_endpoints import (
21
33
  CelfEndpoints,
22
34
  CelfMutateResult,
23
35
  CelfStatsResult,
24
36
  CelfWriteResult,
25
37
  )
38
+ from graphdatascience.procedure_surface.api.centrality.celf_session_endpoints import (
39
+ CelfSessionEndpoints,
40
+ )
26
41
  from graphdatascience.procedure_surface.api.centrality.closeness_endpoints import (
27
42
  ClosenessEndpoints,
28
43
  ClosenessMutateResult,
@@ -35,71 +50,100 @@ from graphdatascience.procedure_surface.api.centrality.closeness_harmonic_endpoi
35
50
  ClosenessHarmonicStatsResult,
36
51
  ClosenessHarmonicWriteResult,
37
52
  )
53
+ from graphdatascience.procedure_surface.api.centrality.closeness_harmonic_session_endpoints import (
54
+ ClosenessHarmonicSessionEndpoints,
55
+ )
56
+ from graphdatascience.procedure_surface.api.centrality.closeness_session_endpoints import (
57
+ ClosenessSessionEndpoints,
58
+ )
38
59
  from graphdatascience.procedure_surface.api.centrality.degree_endpoints import (
39
60
  DegreeEndpoints,
40
61
  DegreeMutateResult,
41
62
  DegreeStatsResult,
42
63
  DegreeWriteResult,
43
64
  )
65
+ from graphdatascience.procedure_surface.api.centrality.degree_session_endpoints import (
66
+ DegreeSessionEndpoints,
67
+ )
44
68
  from graphdatascience.procedure_surface.api.centrality.eigenvector_endpoints import (
45
69
  EigenvectorEndpoints,
46
70
  EigenvectorMutateResult,
47
71
  EigenvectorStatsResult,
48
72
  EigenvectorWriteResult,
49
73
  )
74
+ from graphdatascience.procedure_surface.api.centrality.eigenvector_session_endpoints import (
75
+ EigenvectorSessionEndpoints,
76
+ )
50
77
  from graphdatascience.procedure_surface.api.centrality.hits_endpoints import (
51
78
  HitsEndpoints,
52
79
  HitsMutateResult,
53
80
  HitsStatsResult,
54
81
  HitsWriteResult,
55
82
  )
83
+ from graphdatascience.procedure_surface.api.centrality.hits_session_endpoints import (
84
+ HitsSessionEndpoints,
85
+ )
56
86
  from graphdatascience.procedure_surface.api.centrality.pagerank_endpoints import (
57
87
  PageRankEndpoints,
58
88
  PageRankMutateResult,
59
89
  PageRankStatsResult,
60
90
  PageRankWriteResult,
61
91
  )
92
+ from graphdatascience.procedure_surface.api.centrality.pagerank_session_endpoints import (
93
+ PageRankSessionEndpoints,
94
+ )
62
95
 
63
96
  __all__ = [
64
97
  "ArticleRankEndpoints",
65
98
  "ArticleRankMutateResult",
99
+ "ArticleRankSessionEndpoints",
66
100
  "ArticleRankStatsResult",
67
101
  "ArticleRankWriteResult",
68
102
  "ArticulationPointsEndpoints",
69
103
  "ArticulationPointsMutateResult",
104
+ "ArticulationPointsSessionEndpoints",
70
105
  "ArticulationPointsStatsResult",
71
106
  "ArticulationPointsWriteResult",
72
107
  "BetweennessEndpoints",
73
108
  "BetweennessMutateResult",
109
+ "BetweennessSessionEndpoints",
74
110
  "BetweennessStatsResult",
75
111
  "BetweennessWriteResult",
76
112
  "BridgesEndpoints",
113
+ "BridgesSessionEndpoints",
77
114
  "CelfEndpoints",
78
115
  "CelfMutateResult",
116
+ "CelfSessionEndpoints",
79
117
  "CelfStatsResult",
80
118
  "CelfWriteResult",
81
119
  "ClosenessEndpoints",
82
120
  "ClosenessHarmonicEndpoints",
83
121
  "ClosenessHarmonicMutateResult",
122
+ "ClosenessHarmonicSessionEndpoints",
84
123
  "ClosenessHarmonicStatsResult",
85
124
  "ClosenessHarmonicWriteResult",
86
125
  "ClosenessMutateResult",
126
+ "ClosenessSessionEndpoints",
87
127
  "ClosenessStatsResult",
88
128
  "ClosenessWriteResult",
89
129
  "DegreeEndpoints",
90
130
  "DegreeMutateResult",
131
+ "DegreeSessionEndpoints",
91
132
  "DegreeStatsResult",
92
133
  "DegreeWriteResult",
93
134
  "EigenvectorEndpoints",
94
135
  "EigenvectorMutateResult",
136
+ "EigenvectorSessionEndpoints",
95
137
  "EigenvectorStatsResult",
96
138
  "EigenvectorWriteResult",
97
139
  "HitsEndpoints",
98
140
  "HitsMutateResult",
141
+ "HitsSessionEndpoints",
99
142
  "HitsStatsResult",
100
143
  "HitsWriteResult",
101
144
  "PageRankEndpoints",
102
145
  "PageRankMutateResult",
146
+ "PageRankSessionEndpoints",
103
147
  "PageRankStatsResult",
104
148
  "PageRankWriteResult",
105
149
  ]
@@ -183,7 +183,7 @@ class ArticleRankEndpoints(ABC):
183
183
  G
184
184
  Graph object to use
185
185
  damping_factor
186
- The damping factor controls the probability of a random jump to a random node
186
+ Probability of a jump to a random node.
187
187
  tolerance
188
188
  Minimum change in scores between iterations.
189
189
  max_iterations
@@ -319,7 +319,7 @@ class ArticleRankEndpoints(ABC):
319
319
  G
320
320
  Graph object to use or a dictionary representing the graph dimensions.
321
321
  damping_factor
322
- The damping factor controls the probability of a random jump to a random node
322
+ Probability of a jump to a random node.
323
323
  tolerance
324
324
  Minimum change in scores between iterations.
325
325
  max_iterations
@@ -0,0 +1,76 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import abstractmethod
4
+
5
+ from graphdatascience.graph.graph_api import Graph
6
+ from graphdatascience.procedure_surface.api.catalog.scaler_config import ScalerConfig
7
+ from graphdatascience.procedure_surface.api.centrality.articlerank_endpoints import ArticleRankEndpoints
8
+ from graphdatascience.procedure_surface.api.default_values import ALL_LABELS, ALL_TYPES
9
+ from graphdatascience.procedure_surface.api.job_handle import JobHandle
10
+
11
+
12
+ class ArticleRankSessionEndpoints(ArticleRankEndpoints):
13
+ """Article Rank endpoints as exposed by a GDS Session."""
14
+
15
+ @abstractmethod
16
+ def compute(
17
+ self,
18
+ G: Graph,
19
+ *,
20
+ damping_factor: float = 0.85,
21
+ tolerance: float = 1.0e-7,
22
+ max_iterations: int = 20,
23
+ scaler: str | dict[str, str | int | float] | ScalerConfig = "NONE",
24
+ relationship_types: list[str] = ALL_TYPES,
25
+ node_labels: list[str] = ALL_LABELS,
26
+ sudo: bool = False,
27
+ log_progress: bool = True,
28
+ username: str | None = None,
29
+ concurrency: int | None = None,
30
+ job_id: str | None = None,
31
+ relationship_weight_property: str | None = None,
32
+ source_nodes: int | list[int] | list[tuple[int, float]] | None = None,
33
+ ) -> JobHandle:
34
+ """
35
+ Starts the computation as a job and returns a handle to it.
36
+
37
+ The computation runs without materializing its result. Use the returned handle to
38
+ mutate, write or stream the result afterwards.
39
+
40
+ Parameters
41
+ ----------
42
+ G
43
+ Graph object to use
44
+ damping_factor
45
+ Probability of a jump to a random node.
46
+ tolerance
47
+ Minimum change in scores between iterations.
48
+ max_iterations
49
+ Maximum number of iterations to run.
50
+ scaler
51
+ The scaler to use. Can be: - A string (e.g., 'MinMax', 'Mean', 'Max', 'Log', 'StdScore', 'Center', 'NONE') - A dictionary with scaler configuration (e.g., {'type': 'Log', 'offset': 1.0}) - - A :class:`~graphdatascience.procedure_surface.api.catalog.scaler_config.ScalerConfig` instance
52
+ relationship_types
53
+ Filter the graph using the given relationship types. Relationships with any of the given types will be included.
54
+ node_labels
55
+ Filter the graph using the given node labels. Nodes with any of the given labels will be included.
56
+ sudo
57
+ Disable the memory guard.
58
+ log_progress
59
+ Display progress logging.
60
+ username
61
+ As an administrator, impersonate a different user for accessing their graphs.
62
+ concurrency
63
+ Number of concurrent threads to use.
64
+ job_id
65
+ Identifier for the computation.
66
+ relationship_weight_property
67
+ Name of the property to be used as weights.
68
+ source_nodes
69
+ node ids to use as starting points. Can be: - single node id (e.g., 42) - list of node id (e.g., [42, 43, 44]) - list of tuples to associate each node with a bias > 0 (e.g., [(42, 0.5), (43, 1.0)])
70
+
71
+ Returns
72
+ -------
73
+ JobHandle
74
+ Handle to the started computation
75
+ """
76
+ pass
@@ -0,0 +1,59 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import abstractmethod
4
+
5
+ from graphdatascience.graph.graph_api import Graph
6
+ from graphdatascience.procedure_surface.api.centrality.articulationpoints_endpoints import (
7
+ ArticulationPointsEndpoints,
8
+ )
9
+ from graphdatascience.procedure_surface.api.default_values import ALL_LABELS, ALL_TYPES
10
+ from graphdatascience.procedure_surface.api.job_handle import JobHandle
11
+
12
+
13
+ class ArticulationPointsSessionEndpoints(ArticulationPointsEndpoints):
14
+ """ArticulationPoints endpoints as exposed by a GDS Session."""
15
+
16
+ @abstractmethod
17
+ def compute(
18
+ self,
19
+ G: Graph,
20
+ *,
21
+ relationship_types: list[str] = ALL_TYPES,
22
+ node_labels: list[str] = ALL_LABELS,
23
+ sudo: bool = False,
24
+ log_progress: bool = True,
25
+ username: str | None = None,
26
+ concurrency: int | None = None,
27
+ job_id: str | None = None,
28
+ ) -> JobHandle:
29
+ """
30
+ Starts the computation as a job and returns a handle to it.
31
+
32
+ The computation runs without materializing its result. Use the returned handle to
33
+ mutate, write or stream the result afterwards.
34
+
35
+ Parameters
36
+ ----------
37
+ G
38
+ Graph object to use
39
+ relationship_types
40
+ Filter the graph using the given relationship types. Relationships with any of the given types will be included.
41
+ node_labels
42
+ Filter the graph using the given node labels. Nodes with any of the given labels will be included.
43
+ sudo
44
+ Disable the memory guard.
45
+ log_progress
46
+ Display progress logging.
47
+ username
48
+ As an administrator, impersonate a different user for accessing their graphs.
49
+ concurrency
50
+ Number of concurrent threads to use.
51
+ job_id
52
+ Identifier for the computation.
53
+
54
+ Returns
55
+ -------
56
+ JobHandle
57
+ Handle to the started computation
58
+ """
59
+ pass
@@ -0,0 +1,68 @@
1
+ from __future__ import annotations
2
+
3
+ from abc import abstractmethod
4
+
5
+ from graphdatascience.graph.graph_api import Graph
6
+ from graphdatascience.procedure_surface.api.centrality.betweenness_endpoints import (
7
+ BetweennessEndpoints,
8
+ )
9
+ from graphdatascience.procedure_surface.api.default_values import ALL_LABELS, ALL_TYPES
10
+ from graphdatascience.procedure_surface.api.job_handle import JobHandle
11
+
12
+
13
+ class BetweennessSessionEndpoints(BetweennessEndpoints):
14
+ """Betweenness endpoints as exposed by a GDS Session."""
15
+
16
+ @abstractmethod
17
+ def compute(
18
+ self,
19
+ G: Graph,
20
+ *,
21
+ sampling_size: int | None = None,
22
+ sampling_seed: int | None = None,
23
+ relationship_types: list[str] = ALL_TYPES,
24
+ node_labels: list[str] = ALL_LABELS,
25
+ sudo: bool = False,
26
+ log_progress: bool = True,
27
+ username: str | None = None,
28
+ concurrency: int | None = None,
29
+ job_id: str | None = None,
30
+ relationship_weight_property: str | None = None,
31
+ ) -> JobHandle:
32
+ """
33
+ Starts the computation as a job and returns a handle to it.
34
+
35
+ The computation runs without materializing its result. Use the returned handle to
36
+ mutate, write or stream the result afterwards.
37
+
38
+ Parameters
39
+ ----------
40
+ G
41
+ Graph object to use
42
+ sampling_size
43
+ Number of source nodes to consider for computing centrality scores.
44
+ sampling_seed
45
+ Seed value for the random number generator that selects source nodes.
46
+ relationship_types
47
+ Filter the graph using the given relationship types. Relationships with any of the given types will be included.
48
+ node_labels
49
+ Filter the graph using the given node labels. Nodes with any of the given labels will be included.
50
+ sudo
51
+ Disable the memory guard.
52
+ log_progress
53
+ Display progress logging.
54
+ username
55
+ As an administrator, impersonate a different user for accessing their graphs.
56
+ concurrency
57
+ Number of concurrent threads to use.
58
+ job_id
59
+ Identifier for the computation.
60
+ relationship_weight_property
61
+ Name of the property to be used as weights.
62
+
63
+ Returns
64
+ -------
65
+ JobHandle
66
+ Handle to the started computation
67
+ """
68
+ pass