Skip to content

TensorflowGNN transformer #353

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
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ jobs:
poetry install --all-extras
poe install-pyg-cpu
poe install-dgl
poe install-tfgnn
- name: Run Tests
run: |
export TF_USE_LEGACY_KERAS="1"
poetry run pytest -vvv -m "not slow and not ubuntu and not docker"
- name: Use the Upload Artifact GitHub Action
uses: actions/upload-artifact@v4
Expand Down Expand Up @@ -131,6 +133,8 @@ jobs:
run: |
poetry install --all-extras
poe install-pyg-cpu
poe install-tfgnn
export TF_USE_LEGACY_KERAS="1"
poetry run pytest -vvv -m "not slow and not ubuntu and not docker"
- name: Save Memgraph Logs
uses: actions/upload-artifact@v4
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ poetry install # No extras
poetry install -E arrow # Support for the CSV, Parquet, ORC and IPC/Feather/Arrow formats
poetry install -E dgl # DGL support (also includes torch)
poetry install -E docker # Docker support
poetry install -E tfgnn # TFGNN support
```

To run the tests, make sure you have an [active Memgraph instance](https://memgraph.com/docs/getting-started), and execute one of the following commands:
Expand All @@ -100,6 +101,7 @@ If you’ve installed only certain extras, it’s also possible to run their ass
poetry run pytest . -k "arrow"
poetry run pytest . -k "dgl"
poetry run pytest . -k "docker"
poetry run pytest . -k "tfgnn"
```

## Development (how to build)
Expand Down
1 change: 1 addition & 0 deletions gqlalchemy/transformations/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
NUM_NODES = "num_nodes"
DEFAULT_NODE_LABEL = "NODE"
DEFAULT_EDGE_TYPE = "RELATIONSHIP"
TFGNN_ID = "tfgnn_id"
12 changes: 10 additions & 2 deletions gqlalchemy/transformations/export/graph_transporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
except ModuleNotFoundError:
PyGTranslator = None

try:
from gqlalchemy.transformations.translators.tfgnn_translator import TFGNNTranslator
except ModuleNotFoundError:
TFGNNTranslator = None


class GraphTransporter(Transporter):
"""Here is a possible example for using this module:
Expand All @@ -52,7 +57,7 @@ def __init__(
>>> transporter = GraphTransporter("dgl")
graph = transporter.export()
Args:
graph_type: dgl, pyg or nx
graph_type: dgl, pyg, nx or tfgnn
"""
super().__init__()
self.graph_type = graph_type.upper()
Expand All @@ -64,8 +69,11 @@ def __init__(
self.translator = PyGTranslator(host, port, username, password, encrypted, client_name, lazy)
elif self.graph_type == GraphType.NX.name:
self.translator = NxTranslator(host, port, username, password, encrypted, client_name, lazy)
elif self.graph_type == GraphType.TFGNN.name:
raise_if_not_imported(dependency=TFGNNTranslator, dependency_name="tensorflow-gnn")
self.translator = TFGNNTranslator(host, port, username, password, encrypted, client_name, lazy)
else:
raise ValueError("Unknown export option. Currently supported are DGL, PyG and NetworkX.")
raise ValueError("Unknown export option. Currently supported are DGL, PyG, NetworkX and TFGNN.")

def export(self):
"""Creates graph instance for the wanted export option."""
Expand Down
2 changes: 1 addition & 1 deletion gqlalchemy/transformations/graph_type.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from enum import Enum

GraphType = Enum("GraphType", ["DGL", "PYG", "NX"])
GraphType = Enum("GraphType", ["DGL", "PYG", "NX", "TFGNN"])
Loading