graphdatascience 2.2__py3-none-any.whl → 2.3__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.
- graphdatascience/arrow_client/authenticated_flight_client.py +2 -2
- graphdatascience/arrow_client/v1/gds_arrow_client.py +3 -3
- graphdatascience/arrow_client/v2/gds_arrow_client.py +2 -2
- graphdatascience/datasets/ogb_loader.py +7 -13
- graphdatascience/embedding/config.py +2 -2
- graphdatascience/graph/graph_api.py +2 -2
- graphdatascience/graph_construction/cypher_graph_constructor.py +1 -1
- graphdatascience/graph_data_science.py +2 -2
- graphdatascience/procedure_surface/api/catalog/relationships_endpoints.py +2 -2
- graphdatascience/procedure_surface/api/centrality/hits_endpoints.py +2 -2
- graphdatascience/procedure_surface/api/node_embedding/fastpath_endpoints.py +18 -3
- graphdatascience/procedure_surface/api/pipeline/node_regression_metric.py +2 -2
- graphdatascience/procedure_surface/api/projection_job_handle.py +13 -1
- graphdatascience/procedure_surface/api/topological_link_prediction_endpoints.py +2 -2
- graphdatascience/procedure_surface/arrow/catalog/catalog_arrow_endpoints.py +35 -5
- graphdatascience/procedure_surface/arrow/catalog/graph_backend_arrow.py +8 -2
- graphdatascience/procedure_surface/arrow/catalog/graph_ops_arrow.py +13 -2
- graphdatascience/procedure_surface/arrow/catalog/graph_sampling_arrow_endpoints.py +13 -2
- graphdatascience/procedure_surface/arrow/catalog/projection_arrow_endpoints.py +22 -3
- graphdatascience/procedure_surface/arrow/node_embedding/fastpath_arrow_endpoints.py +12 -4
- graphdatascience/procedure_surface/arrow/stream_result_mapper.py +44 -51
- graphdatascience/procedure_surface/cypher/catalog/projection_cypher_endpoints.py +5 -4
- graphdatascience/procedure_surface/utils/result_utils.py +1 -1
- graphdatascience/progress/progress_bar.py +4 -4
- graphdatascience/progress/query_progress_provider.py +1 -1
- graphdatascience/query_runner/neo4j_query_runner.py +1 -1
- graphdatascience/query_runner/query_mode.py +2 -2
- graphdatascience/query_runner/query_runner.py +2 -2
- graphdatascience/resources/imdb/serialize_imdb.py +6 -6
- graphdatascience/resources/lastfm/serialize_lastfm.py +5 -5
- graphdatascience/session/aura_api.py +5 -0
- graphdatascience/session/aura_api_responses.py +30 -15
- graphdatascience/session/aura_graph_data_science.py +9 -1
- graphdatascience/session/dbms/instance_type_resolver.py +39 -0
- graphdatascience/session/dbms_connection_info.py +1 -1
- graphdatascience/session/gds_sessions.py +50 -53
- graphdatascience/session/graph_mapping_context.py +54 -0
- graphdatascience/session/graph_mappings_api.py +81 -0
- graphdatascience/session/instance_type.py +39 -0
- graphdatascience/session/session_target.py +145 -0
- graphdatascience/version.py +1 -1
- {graphdatascience-2.2.dist-info → graphdatascience-2.3.dist-info}/METADATA +4 -5
- {graphdatascience-2.2.dist-info → graphdatascience-2.3.dist-info}/RECORD +46 -41
- {graphdatascience-2.2.dist-info → graphdatascience-2.3.dist-info}/WHEEL +1 -1
- {graphdatascience-2.2.dist-info → graphdatascience-2.3.dist-info}/licenses/LICENSE +0 -0
- {graphdatascience-2.2.dist-info → graphdatascience-2.3.dist-info}/top_level.txt +0 -0
|
@@ -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) ->
|
|
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"}
|
|
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) ->
|
|
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
|
|
@@ -547,7 +547,7 @@ class GdsArrowClient:
|
|
|
547
547
|
ack_stream.read()
|
|
548
548
|
progress_callback(partition.num_rows)
|
|
549
549
|
|
|
550
|
-
def __enter__(self) ->
|
|
550
|
+
def __enter__(self) -> Self:
|
|
551
551
|
return self
|
|
552
552
|
|
|
553
553
|
def __exit__(
|
|
@@ -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
|
|
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
|
|
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) ->
|
|
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
|
|
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"
|
|
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) ->
|
|
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
|
|
4
|
+
from enum import StrEnum
|
|
5
5
|
from typing import Any
|
|
6
6
|
|
|
7
7
|
from pydantic import AliasChoices, Field, field_validator
|
|
@@ -312,7 +312,7 @@ class CollapsePathResult(BaseResult):
|
|
|
312
312
|
configuration: dict[str, Any]
|
|
313
313
|
|
|
314
314
|
|
|
315
|
-
class Aggregation(
|
|
315
|
+
class Aggregation(StrEnum):
|
|
316
316
|
"""
|
|
317
317
|
Specifies how to aggregate parallel relationships in a graph.
|
|
318
318
|
"""
|
|
@@ -17,7 +17,7 @@ class HitsEndpoints(ABC):
|
|
|
17
17
|
self,
|
|
18
18
|
G: Graph,
|
|
19
19
|
*,
|
|
20
|
-
mutate_property: str
|
|
20
|
+
mutate_property: str,
|
|
21
21
|
hits_iterations: int = 20,
|
|
22
22
|
auth_property: str = "auth",
|
|
23
23
|
hub_property: str = "hub",
|
|
@@ -176,7 +176,7 @@ class HitsEndpoints(ABC):
|
|
|
176
176
|
self,
|
|
177
177
|
G: Graph,
|
|
178
178
|
*,
|
|
179
|
-
write_property: str
|
|
179
|
+
write_property: str,
|
|
180
180
|
hits_iterations: int = 20,
|
|
181
181
|
auth_property: str = "auth",
|
|
182
182
|
hub_property: str = "hub",
|
|
@@ -32,7 +32,8 @@ class FastPathEndpoints(ABC):
|
|
|
32
32
|
mutate_property: str,
|
|
33
33
|
embedding_dimension: int,
|
|
34
34
|
lookback_horizon: int,
|
|
35
|
-
num_time_anchors: int,
|
|
35
|
+
num_time_anchors: int | None = None,
|
|
36
|
+
time_anchor_interval: float | None = None,
|
|
36
37
|
*,
|
|
37
38
|
event_node_categorical_properties: list[str] = [],
|
|
38
39
|
relationship_types: list[str] = ALL_TYPES,
|
|
@@ -69,6 +70,10 @@ class FastPathEndpoints(ABC):
|
|
|
69
70
|
Maximum age of events (relative to the observation time) that are processed.
|
|
70
71
|
num_time_anchors
|
|
71
72
|
Number of grid points used to discretize elapsed time.
|
|
73
|
+
Exactly one of `num_time_anchors` and `time_anchor_interval` must be specified.
|
|
74
|
+
time_anchor_interval
|
|
75
|
+
Time interval between anchor embeddings in the grid.
|
|
76
|
+
Exactly one of `num_time_anchors` and `time_anchor_interval` must be specified.
|
|
72
77
|
event_node_categorical_properties
|
|
73
78
|
Event node properties holding categorical values.
|
|
74
79
|
relationship_types
|
|
@@ -114,7 +119,8 @@ class FastPathEndpoints(ABC):
|
|
|
114
119
|
event_node_label: str,
|
|
115
120
|
embedding_dimension: int,
|
|
116
121
|
lookback_horizon: int,
|
|
117
|
-
num_time_anchors: int,
|
|
122
|
+
num_time_anchors: int | None = None,
|
|
123
|
+
time_anchor_interval: float | None = None,
|
|
118
124
|
*,
|
|
119
125
|
event_node_categorical_properties: list[str] = [],
|
|
120
126
|
relationship_types: list[str] = ALL_TYPES,
|
|
@@ -149,6 +155,10 @@ class FastPathEndpoints(ABC):
|
|
|
149
155
|
Maximum age of events (relative to the observation time) that are processed.
|
|
150
156
|
num_time_anchors
|
|
151
157
|
Number of grid points used to discretize elapsed time.
|
|
158
|
+
Exactly one of `num_time_anchors` and `time_anchor_interval` must be specified.
|
|
159
|
+
time_anchor_interval
|
|
160
|
+
Time interval between anchor embeddings in the grid.
|
|
161
|
+
Exactly one of `num_time_anchors` and `time_anchor_interval` must be specified.
|
|
152
162
|
event_node_categorical_properties
|
|
153
163
|
Event node properties holding categorical values.
|
|
154
164
|
relationship_types
|
|
@@ -195,7 +205,8 @@ class FastPathEndpoints(ABC):
|
|
|
195
205
|
write_property: str,
|
|
196
206
|
embedding_dimension: int,
|
|
197
207
|
lookback_horizon: int,
|
|
198
|
-
num_time_anchors: int,
|
|
208
|
+
num_time_anchors: int | None = None,
|
|
209
|
+
time_anchor_interval: float | None = None,
|
|
199
210
|
*,
|
|
200
211
|
event_node_categorical_properties: list[str] = [],
|
|
201
212
|
relationship_types: list[str] = ALL_TYPES,
|
|
@@ -233,6 +244,10 @@ class FastPathEndpoints(ABC):
|
|
|
233
244
|
Maximum age of events (relative to the observation time) that are processed.
|
|
234
245
|
num_time_anchors
|
|
235
246
|
Number of grid points used to discretize elapsed time.
|
|
247
|
+
Exactly one of `num_time_anchors` and `time_anchor_interval` must be specified.
|
|
248
|
+
time_anchor_interval
|
|
249
|
+
Time interval between anchor embeddings in the grid.
|
|
250
|
+
Exactly one of `num_time_anchors` and `time_anchor_interval` must be specified.
|
|
236
251
|
event_node_categorical_properties
|
|
237
252
|
Event node properties holding categorical values.
|
|
238
253
|
relationship_types
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
from enum import
|
|
1
|
+
from enum import StrEnum
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
class NodeRegressionMetric(
|
|
4
|
+
class NodeRegressionMetric(StrEnum):
|
|
5
5
|
MEAN_SQUARED_ERROR = "MEAN_SQUARED_ERROR"
|
|
6
6
|
ROOT_MEAN_SQUARED_ERROR = "ROOT_MEAN_SQUARED_ERROR"
|
|
7
7
|
MEAN_ABSOLUTE_ERROR = "MEAN_ABSOLUTE_ERROR"
|
|
@@ -12,6 +12,7 @@ from graphdatascience.procedure_surface.api.job_not_finished_error import JobNot
|
|
|
12
12
|
from graphdatascience.procedure_surface.arrow.catalog.graph_backend_arrow import ArrowGraphBackend
|
|
13
13
|
from graphdatascience.query_runner.termination_flag import TerminationFlag
|
|
14
14
|
from graphdatascience.retry_utils.retry_config import ExponentialWaitConfig, RetryConfigV2, StopConfig
|
|
15
|
+
from graphdatascience.session.graph_mapping_context import GraphMappingContext
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
class ProjectionJobHandle:
|
|
@@ -21,12 +22,14 @@ class ProjectionJobHandle:
|
|
|
21
22
|
graph_name: str,
|
|
22
23
|
job_id: str,
|
|
23
24
|
termination_flag: TerminationFlag,
|
|
25
|
+
graph_mapping_context: GraphMappingContext | None = None,
|
|
24
26
|
):
|
|
25
27
|
self._arrow_client = arrow_client
|
|
26
28
|
self._job_client = JobClient()
|
|
27
29
|
self._graph_name = graph_name
|
|
28
30
|
self._job_id = job_id
|
|
29
31
|
self._termination_flag = termination_flag
|
|
32
|
+
self._graph_mapping_context = graph_mapping_context
|
|
30
33
|
|
|
31
34
|
def job_id(self) -> str:
|
|
32
35
|
return self._job_id
|
|
@@ -69,4 +72,13 @@ class ProjectionJobHandle:
|
|
|
69
72
|
|
|
70
73
|
summary = self._job_client.get_summary(self._arrow_client, self._job_id)
|
|
71
74
|
|
|
72
|
-
|
|
75
|
+
if self._graph_mapping_context and self.status().succeeded():
|
|
76
|
+
self._graph_mapping_context.register(self._graph_name)
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
Graph(
|
|
80
|
+
self._graph_name,
|
|
81
|
+
ArrowGraphBackend(self._graph_name, self._arrow_client, self._graph_mapping_context),
|
|
82
|
+
),
|
|
83
|
+
summary,
|
|
84
|
+
)
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from abc import ABC, abstractmethod
|
|
4
|
-
from enum import
|
|
4
|
+
from enum import StrEnum
|
|
5
5
|
|
|
6
6
|
from neo4j.graph import Node
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
class Direction(
|
|
9
|
+
class Direction(StrEnum):
|
|
10
10
|
"""
|
|
11
11
|
The direction of relationships to consider when computing a topological link prediction.
|
|
12
12
|
"""
|
|
@@ -43,6 +43,7 @@ from graphdatascience.procedure_surface.arrow.catalog.relationship_arrow_endpoin
|
|
|
43
43
|
from graphdatascience.procedure_surface.utils.config_converter import ConfigConverter
|
|
44
44
|
from graphdatascience.query_runner.query_runner import QueryRunner
|
|
45
45
|
from graphdatascience.query_runner.termination_flag import TerminationFlag
|
|
46
|
+
from graphdatascience.session.graph_mapping_context import GraphMappingContext
|
|
46
47
|
from graphdatascience.session.remote_ops.write_protocols import WriteProtocol
|
|
47
48
|
|
|
48
49
|
|
|
@@ -54,10 +55,12 @@ class CatalogArrowEndpoints(CatalogEndpoints):
|
|
|
54
55
|
arrow_client: AuthenticatedArrowClient,
|
|
55
56
|
query_runner: QueryRunner | None = None,
|
|
56
57
|
show_progress: bool = False,
|
|
58
|
+
graph_mapping_context: GraphMappingContext | None = None,
|
|
57
59
|
):
|
|
58
60
|
self._arrow_client = arrow_client
|
|
59
61
|
self._query_runner = query_runner
|
|
60
|
-
self.
|
|
62
|
+
self._graph_mapping_context = graph_mapping_context
|
|
63
|
+
self._graph_ops = GraphOpsArrow(arrow_client, graph_mapping_context)
|
|
61
64
|
self._show_progress = show_progress
|
|
62
65
|
self._write_protocol: WriteProtocol | None = None
|
|
63
66
|
if query_runner is not None:
|
|
@@ -68,7 +71,12 @@ class CatalogArrowEndpoints(CatalogEndpoints):
|
|
|
68
71
|
"""
|
|
69
72
|
Provides access to the project endpoints.
|
|
70
73
|
"""
|
|
71
|
-
return ProjectArrowEndpoints(
|
|
74
|
+
return ProjectArrowEndpoints(
|
|
75
|
+
self._arrow_client,
|
|
76
|
+
self._query_runner,
|
|
77
|
+
self._show_progress,
|
|
78
|
+
graph_mapping_context=self._graph_mapping_context,
|
|
79
|
+
)
|
|
72
80
|
|
|
73
81
|
def get(self, graph_name: str) -> Graph:
|
|
74
82
|
if not self.list(graph_name):
|
|
@@ -109,6 +117,8 @@ class CatalogArrowEndpoints(CatalogEndpoints):
|
|
|
109
117
|
self._show_progress,
|
|
110
118
|
)
|
|
111
119
|
constructor.run(nodes, relationships)
|
|
120
|
+
if self._graph_mapping_context:
|
|
121
|
+
self._graph_mapping_context.register(graph_name)
|
|
112
122
|
return get_graph(graph_name, self._arrow_client)
|
|
113
123
|
|
|
114
124
|
def drop(self, G: Graph | str | List[Graph | str], fail_if_missing: bool = True) -> List[GraphInfo]:
|
|
@@ -164,6 +174,8 @@ class CatalogArrowEndpoints(CatalogEndpoints):
|
|
|
164
174
|
job_id = JobClient.run_job_and_wait(
|
|
165
175
|
self._arrow_client, "v2/graph.project.filter", config, show_progress=self._show_progress
|
|
166
176
|
)
|
|
177
|
+
if self._graph_mapping_context:
|
|
178
|
+
self._graph_mapping_context.register(graph_name)
|
|
167
179
|
|
|
168
180
|
return GraphWithFilterResult(
|
|
169
181
|
get_graph(graph_name, self._arrow_client),
|
|
@@ -207,7 +219,13 @@ class CatalogArrowEndpoints(CatalogEndpoints):
|
|
|
207
219
|
|
|
208
220
|
started_job_id = JobClient.run_job(self._arrow_client, "v2/graph.project.filter", config)
|
|
209
221
|
|
|
210
|
-
return ProjectionJobHandle(
|
|
222
|
+
return ProjectionJobHandle(
|
|
223
|
+
self._arrow_client,
|
|
224
|
+
graph_name,
|
|
225
|
+
started_job_id,
|
|
226
|
+
TerminationFlag.create(),
|
|
227
|
+
graph_mapping_context=self._graph_mapping_context,
|
|
228
|
+
)
|
|
211
229
|
|
|
212
230
|
def generate(
|
|
213
231
|
self,
|
|
@@ -252,6 +270,8 @@ class CatalogArrowEndpoints(CatalogEndpoints):
|
|
|
252
270
|
job_id = JobClient.run_job_and_wait(
|
|
253
271
|
self._arrow_client, "v2/graph.generate", config, show_progress=show_progress
|
|
254
272
|
)
|
|
273
|
+
if self._graph_mapping_context:
|
|
274
|
+
self._graph_mapping_context.register(graph_name)
|
|
255
275
|
|
|
256
276
|
return GraphWithGenerationStats(
|
|
257
277
|
get_graph(graph_name, self._arrow_client),
|
|
@@ -303,7 +323,13 @@ class CatalogArrowEndpoints(CatalogEndpoints):
|
|
|
303
323
|
|
|
304
324
|
started_job_id = JobClient.run_job(self._arrow_client, "v2/graph.generate", config)
|
|
305
325
|
|
|
306
|
-
return ProjectionJobHandle(
|
|
326
|
+
return ProjectionJobHandle(
|
|
327
|
+
self._arrow_client,
|
|
328
|
+
graph_name,
|
|
329
|
+
started_job_id,
|
|
330
|
+
TerminationFlag.create(),
|
|
331
|
+
graph_mapping_context=self._graph_mapping_context,
|
|
332
|
+
)
|
|
307
333
|
|
|
308
334
|
def list(self, G: Graph | str | None = None) -> list[GraphInfoWithDegrees]:
|
|
309
335
|
graph_name: str | None = None
|
|
@@ -320,7 +346,11 @@ class CatalogArrowEndpoints(CatalogEndpoints):
|
|
|
320
346
|
|
|
321
347
|
@property
|
|
322
348
|
def sample(self) -> GraphSamplingEndpoints:
|
|
323
|
-
return GraphSamplingArrowEndpoints(
|
|
349
|
+
return GraphSamplingArrowEndpoints(
|
|
350
|
+
self._arrow_client,
|
|
351
|
+
show_progress=self._show_progress,
|
|
352
|
+
graph_mapping_context=self._graph_mapping_context,
|
|
353
|
+
)
|
|
324
354
|
|
|
325
355
|
@property
|
|
326
356
|
def node_labels(self) -> NodeLabelEndpoints:
|
|
@@ -3,6 +3,7 @@ from graphdatascience.graph import Graph
|
|
|
3
3
|
from graphdatascience.graph.graph_backend import GraphBackend
|
|
4
4
|
from graphdatascience.graph.graph_info import GraphInfo, GraphInfoWithDegrees
|
|
5
5
|
from graphdatascience.procedure_surface.arrow.catalog.graph_ops_arrow import GraphOpsArrow
|
|
6
|
+
from graphdatascience.session.graph_mapping_context import GraphMappingContext
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
def get_graph(name: str, arrow_client: AuthenticatedArrowClient) -> Graph:
|
|
@@ -12,9 +13,14 @@ def get_graph(name: str, arrow_client: AuthenticatedArrowClient) -> Graph:
|
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
class ArrowGraphBackend(GraphBackend):
|
|
15
|
-
def __init__(
|
|
16
|
+
def __init__(
|
|
17
|
+
self,
|
|
18
|
+
name: str,
|
|
19
|
+
arrow_client: AuthenticatedArrowClient,
|
|
20
|
+
graph_mapping_context: GraphMappingContext | None = None,
|
|
21
|
+
) -> None:
|
|
16
22
|
self._name = name
|
|
17
|
-
self._graph_ops = GraphOpsArrow(arrow_client)
|
|
23
|
+
self._graph_ops = GraphOpsArrow(arrow_client, graph_mapping_context)
|
|
18
24
|
|
|
19
25
|
def graph_info(self) -> GraphInfoWithDegrees:
|
|
20
26
|
results = self._graph_ops.list(self._name)
|
|
@@ -1,12 +1,20 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
1
3
|
from graphdatascience.arrow_client.authenticated_flight_client import AuthenticatedArrowClient
|
|
2
4
|
from graphdatascience.arrow_client.v2.data_mapper_utils import deserialize
|
|
3
5
|
from graphdatascience.graph.graph_info import GraphInfo, GraphInfoWithDegrees
|
|
4
6
|
from graphdatascience.procedure_surface.utils.config_converter import ConfigConverter
|
|
7
|
+
from graphdatascience.session.graph_mapping_context import GraphMappingContext
|
|
5
8
|
|
|
6
9
|
|
|
7
10
|
class GraphOpsArrow:
|
|
8
|
-
def __init__(
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
arrow_client: AuthenticatedArrowClient,
|
|
14
|
+
graph_mapping_context: GraphMappingContext | None = None,
|
|
15
|
+
):
|
|
9
16
|
self._arrow_client = arrow_client
|
|
17
|
+
self._graph_mapping_context = graph_mapping_context
|
|
10
18
|
|
|
11
19
|
def list(self, graph_name: str | None = None) -> list[GraphInfoWithDegrees]:
|
|
12
20
|
payload = {"graphName": graph_name} if graph_name else {}
|
|
@@ -21,6 +29,9 @@ class GraphOpsArrow:
|
|
|
21
29
|
deserialized_results = deserialize(result)
|
|
22
30
|
|
|
23
31
|
if len(deserialized_results) == 1:
|
|
24
|
-
|
|
32
|
+
graph_info = GraphInfo(**deserialized_results[0])
|
|
33
|
+
if self._graph_mapping_context:
|
|
34
|
+
self._graph_mapping_context.unregister(graph_name)
|
|
35
|
+
return graph_info
|
|
25
36
|
else:
|
|
26
37
|
return None
|
|
@@ -15,14 +15,21 @@ from graphdatascience.procedure_surface.arrow.catalog.graph_backend_arrow import
|
|
|
15
15
|
from graphdatascience.procedure_surface.arrow.catalog.graph_ops_arrow import GraphOpsArrow
|
|
16
16
|
from graphdatascience.procedure_surface.arrow.endpoints_helper_base import EndpointsHelperBase
|
|
17
17
|
from graphdatascience.procedure_surface.utils.config_converter import ConfigConverter
|
|
18
|
+
from graphdatascience.session.graph_mapping_context import GraphMappingContext
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
class GraphSamplingArrowEndpoints(GraphSamplingEndpoints):
|
|
21
|
-
def __init__(
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
arrow_client: AuthenticatedArrowClient,
|
|
25
|
+
show_progress: bool = False,
|
|
26
|
+
graph_mapping_context: GraphMappingContext | None = None,
|
|
27
|
+
):
|
|
22
28
|
self._arrow_client = arrow_client
|
|
23
29
|
self._show_progress = show_progress
|
|
30
|
+
self._graph_mapping_context = graph_mapping_context
|
|
24
31
|
self._helper = EndpointsHelperBase(arrow_client, show_progress=show_progress)
|
|
25
|
-
self._graph_ops = GraphOpsArrow(arrow_client)
|
|
32
|
+
self._graph_ops = GraphOpsArrow(arrow_client, graph_mapping_context)
|
|
26
33
|
|
|
27
34
|
def rwr(
|
|
28
35
|
self,
|
|
@@ -69,6 +76,8 @@ class GraphSamplingArrowEndpoints(GraphSamplingEndpoints):
|
|
|
69
76
|
job_id = JobClient.run_job_and_wait(
|
|
70
77
|
self._arrow_client, "v2/graph.sample.rwr", config, show_progress=show_progress
|
|
71
78
|
)
|
|
79
|
+
if self._graph_mapping_context:
|
|
80
|
+
self._graph_mapping_context.register(graph_name)
|
|
72
81
|
|
|
73
82
|
return GraphWithSamplingResult(
|
|
74
83
|
get_graph(graph_name, self._arrow_client),
|
|
@@ -120,6 +129,8 @@ class GraphSamplingArrowEndpoints(GraphSamplingEndpoints):
|
|
|
120
129
|
job_id = JobClient.run_job_and_wait(
|
|
121
130
|
self._arrow_client, "v2/graph.sample.cnarw", config, show_progress=show_progress
|
|
122
131
|
)
|
|
132
|
+
if self._graph_mapping_context:
|
|
133
|
+
self._graph_mapping_context.register(graph_name)
|
|
123
134
|
|
|
124
135
|
return GraphWithSamplingResult(
|
|
125
136
|
get_graph(graph_name, self._arrow_client),
|
|
@@ -16,6 +16,7 @@ from graphdatascience.procedure_surface.arrow.catalog.graph_ops_arrow import Gra
|
|
|
16
16
|
from graphdatascience.query_runner import QueryRunner
|
|
17
17
|
from graphdatascience.query_runner.termination_flag import TerminationFlag
|
|
18
18
|
from graphdatascience.session.dbms.protocol_resolver import ProtocolVersionResolver
|
|
19
|
+
from graphdatascience.session.graph_mapping_context import GraphMappingContext
|
|
19
20
|
from graphdatascience.session.remote_ops.project_protocols import ProjectProtocol
|
|
20
21
|
from graphdatascience.session.remote_ops.projection_runner import ProjectionRunner
|
|
21
22
|
|
|
@@ -28,10 +29,12 @@ class ProjectArrowEndpoints:
|
|
|
28
29
|
arrow_client: AuthenticatedArrowClient,
|
|
29
30
|
query_runner: QueryRunner | None = None,
|
|
30
31
|
show_progress: bool = False,
|
|
32
|
+
graph_mapping_context: GraphMappingContext | None = None,
|
|
31
33
|
):
|
|
32
34
|
self._arrow_client = arrow_client
|
|
33
35
|
self._query_runner = query_runner
|
|
34
|
-
self.
|
|
36
|
+
self._graph_mapping_context = graph_mapping_context
|
|
37
|
+
self._graph_ops = GraphOpsArrow(arrow_client, graph_mapping_context)
|
|
35
38
|
self._show_progress = show_progress
|
|
36
39
|
if query_runner is not None:
|
|
37
40
|
protocol_version = ProtocolVersionResolver(query_runner).resolve()
|
|
@@ -107,6 +110,8 @@ class ProjectArrowEndpoints:
|
|
|
107
110
|
)
|
|
108
111
|
|
|
109
112
|
job_result = ProjectionResult(**JobClient.get_summary(self._arrow_client, job_id))
|
|
113
|
+
if self._graph_mapping_context:
|
|
114
|
+
self._graph_mapping_context.register(graph_name)
|
|
110
115
|
|
|
111
116
|
return GraphWithProjectResult(get_graph(graph_name, self._arrow_client), job_result)
|
|
112
117
|
|
|
@@ -151,7 +156,13 @@ class ProjectArrowEndpoints:
|
|
|
151
156
|
self._project_protocol.get_status(actual_job_id, projection_query_runner)
|
|
152
157
|
projection_query_runner.close()
|
|
153
158
|
|
|
154
|
-
return ProjectionJobHandle(
|
|
159
|
+
return ProjectionJobHandle(
|
|
160
|
+
self._arrow_client,
|
|
161
|
+
graph_name,
|
|
162
|
+
actual_job_id,
|
|
163
|
+
TerminationFlag.create(),
|
|
164
|
+
graph_mapping_context=self._graph_mapping_context,
|
|
165
|
+
)
|
|
155
166
|
|
|
156
167
|
def native(
|
|
157
168
|
self,
|
|
@@ -234,6 +245,8 @@ class ProjectArrowEndpoints:
|
|
|
234
245
|
|
|
235
246
|
summary = JobClient.get_summary(self._arrow_client, job_id)
|
|
236
247
|
job_result = StoreProjectionResult(projectMillis=project_millis, **summary)
|
|
248
|
+
if self._graph_mapping_context:
|
|
249
|
+
self._graph_mapping_context.register(graph_name)
|
|
237
250
|
|
|
238
251
|
return GraphWithProjectResult(get_graph(graph_name, self._arrow_client), job_result)
|
|
239
252
|
|
|
@@ -282,7 +295,13 @@ class ProjectArrowEndpoints:
|
|
|
282
295
|
self._project_protocol.get_status(actual_job_id, projection_query_runner)
|
|
283
296
|
projection_query_runner.close()
|
|
284
297
|
|
|
285
|
-
return ProjectionJobHandle(
|
|
298
|
+
return ProjectionJobHandle(
|
|
299
|
+
self._arrow_client,
|
|
300
|
+
graph_name,
|
|
301
|
+
actual_job_id,
|
|
302
|
+
TerminationFlag.create(),
|
|
303
|
+
graph_mapping_context=self._graph_mapping_context,
|
|
304
|
+
)
|
|
286
305
|
|
|
287
306
|
|
|
288
307
|
class ProjectionResult(BaseResult):
|