-
Notifications
You must be signed in to change notification settings - Fork 55
Catalog Endpoints Part 1 #926
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
DarthMax
wants to merge
25
commits into
neo4j:main
Choose a base branch
from
DarthMax:catalog_endpoints
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
7b1bb98
Implement graph.list for arrow
DarthMax 3d97f96
Implement remote projection for arrow endpoints
DarthMax 37f6d3f
Implement graph.filter for arrow endpoints
DarthMax 0dfc1aa
Implement graph.drop for arrow endpoints
DarthMax d69d58b
AuthenticatedArrowClient accepts dictionaries as action payload
DarthMax f5bf427
Minor cleanups
DarthMax 0646005
Introduce shared GdsBaseModel
DarthMax 221c983
Fix arrow test cleanup
DarthMax ca21bd3
Expose correct env variables
DarthMax 81ac881
Try to fix projection tests
DarthMax 548a7a3
Try to fix projection tests
DarthMax 7fa5945
Try to fix projection tests
DarthMax de20406
Try to fix projection tests
DarthMax 690ca3c
Try to fix projection tests
DarthMax 27d37bc
Try to fix projection tests
DarthMax d524e86
Try to fix projection tests
DarthMax c67f23c
Try to fix projection tests
DarthMax b5513fe
Try to fix projection tests
DarthMax 21cf2cf
Try to fix projection tests
DarthMax c2c3ae5
Try to fix projection tests
DarthMax d256325
Try to fix projection tests
DarthMax 8604ca2
Try to fix projection tests
DarthMax 75f6a2e
Try to fix projection tests
DarthMax 3686581
Try to fix projection tests
DarthMax 61d04e4
Try to fix projection tests
DarthMax File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
graphdatascience/procedure_surface/api/catalog_endpoints.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
from __future__ import annotations | ||
|
||
import re | ||
from abc import ABC, abstractmethod | ||
from datetime import datetime | ||
from typing import Any, List, Optional, Union | ||
|
||
from pydantic import Field, field_validator | ||
|
||
from graphdatascience import Graph | ||
from graphdatascience.procedure_surface.utils.GdsBaseModel import GdsBaseModel | ||
|
||
|
||
class CatalogEndpoints(ABC): | ||
@abstractmethod | ||
def list(self, G: Optional[Union[Graph, str]] = None) -> List[GraphListResult]: | ||
"""List graphs in the graph catalog. | ||
|
||
Args: | ||
G (Optional[Union[Graph, str]], optional): Graph object or name to filter results. | ||
If None, list all graphs. Defaults to None. | ||
|
||
Returns: | ||
List[GraphListResult]: List of graph metadata objects containing information like | ||
graph name, node count, relationship count, etc. | ||
""" | ||
pass | ||
|
||
@abstractmethod | ||
def drop(self, G: Union[Graph, str], fail_if_missing: Optional[bool] = None) -> Optional[GraphListResult]: | ||
"""Drop a graph from the graph catalog. | ||
|
||
Args: | ||
G (Union[Graph, str]): Graph object or name to drop. | ||
fail_if_missing (Optional[bool], optional): Whether to fail if the graph is missing. Defaults to None. | ||
|
||
Returns: | ||
GraphListResult: Graph metadata object containing information like | ||
graph name, node count, relationship count, etc. | ||
""" | ||
|
||
@abstractmethod | ||
def filter( | ||
self, | ||
G: Graph, | ||
graph_name: str, | ||
node_filter: str, | ||
relationship_filter: str, | ||
concurrency: Optional[int] = None, | ||
job_id: Optional[str] = None, | ||
) -> GraphFilterResult: | ||
"""Create a subgraph of a graph based on a filter expression. | ||
|
||
Args: | ||
G (Graph): Graph object to filter on | ||
graph_name (str): Name of subgraph to create | ||
node_filter (str): Filter expression for nodes | ||
relationship_filter (str): Filter expression for relationships | ||
concurrency (Optional[int], optional): Number of concurrent threads to use. Defaults to None. | ||
job_id (Optional[str], optional): Unique identifier for the filtering job. Defaults to None. | ||
|
||
Returns: | ||
GraphFilterResult: Filter result containing information like | ||
graph name, node count, relationship count, etc. | ||
""" | ||
pass | ||
|
||
|
||
class GraphListResult(GdsBaseModel): | ||
graph_name: str | ||
database: str | ||
database_location: str | ||
configuration: dict[str, Any] | ||
memory_usage: str | ||
size_in_bytes: int | ||
node_count: int | ||
relationship_count: int | ||
creation_time: datetime | ||
modification_time: datetime | ||
graph_schema: dict[str, Any] = Field(alias="schema") | ||
schema_with_orientation: dict[str, Any] | ||
degree_distribution: Optional[dict[str, Any]] = None | ||
|
||
@field_validator("creation_time", "modification_time", mode="before") | ||
@classmethod | ||
def strip_timezone(cls, value: Any) -> Any: | ||
if isinstance(value, str): | ||
return re.sub(r"\[.*\]$", "", value) | ||
return value | ||
|
||
|
||
class GraphFilterResult(GdsBaseModel): | ||
graph_name: str | ||
from_graph_name: str | ||
node_filter: str | ||
relationship_filter: str | ||
node_count: int | ||
relationship_count: int | ||
project_millis: int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, project is very implementation dependent, for Cypher+Plugin it will be native projection, Arrow+Session -> remote projection, Arrow + Plugin?? that is why I skipped that.