Skip to content
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

new: preserve_adb_keys in PyG to ArangoDB #11

Merged
merged 70 commits into from
Sep 21, 2022
Merged

Conversation

aMahanna
Copy link
Member

@aMahanna aMahanna commented Aug 3, 2022

Warrants a 1.1.0 release

Open In Colab

Note: For notebook testing purposes:

  • Use !pip install git+https://github.com/arangoml/pyg-adapter.git@feature/adbpyg-map instead of !pip install adbpyg-adapter==1.1.0
  • Use !git clone -b feature/adbpyg-map --single-branch https://github.com/arangoml/pyg-adapter.git instead of !git clone -b 1.1.0 --single-branch https://github.com/arangoml/pyg-adapter.git

What's new

Introduces the preserve_adb_keys parameter in ArangoDB to PyG. When set to True, will store the ArangoDB vertex & edge _key values in the (newly created) PyG graph. When calling PyG to ArangoDB, PyG graphs that have a _key or _id property will have their vertex & edge IDs persisted. See below for an example

Additional Changes

  1. Feature: New supported metagraph value type for ArangoDB to PyG & PyG to ArangoDB: Set[str]
  2. Bug: In PyG to ArangoDB, when explicit_metagraph=True, omitted PyG node & edge properties were still being brought over into ArangoDB (this has been fixed)
  3. encapsulate some PyG to ArangoDB & ArangoDB to PyG logic in new helper methods: __set_adb_data(),__set_pyg_data()
  4. code cleanup
  5. docstring updates
  6. test assertion logic refactor (the existing validation logic was out of date, as we were not accounting for the various supported values in our ArangoDB & PyG Metagraphs)
  7. new: pytest_exception_interact in conftest.py for post-failure ArangoDB cleanup
  8. new test cases
  9. new 1.1.0 notebook

Demo (preserve_adb_keys)

# With `preserve_adb_keys=True`, the adapter will preserve the ArangoDB vertex & edge _key values into the (newly created) PyG graph.
# Users can then re-import their PyG graph into ArangoDB using the same _key values 
pyg_g = adbpyg_adapter.arangodb_graph_to_pyg("imdb", preserve_adb_keys=True)

# pyg_g["Movies"]["_key"] --> ["1", "2", ..., "1682"]
# pyg_g["Users"]["_key"] --> ["1", "2", ..., "943"]
# pyg_g[("Users", "Ratings", "Movies")]["_key"] --> ["2732620466", ..., "2730643624"]

# Let's add a new PyG User Node by updating the _key property
pyg_g["Users"]["_key"].append("new-user-here-944")

# Note: Prior to the re-import, we must manually set the number of nodes in the PyG graph, since the `arangodb_graph_to_pyg` API creates featureless node data
pyg_g["Movies"].num_nodes = len(pyg_g["Movies"]["_key"]) # 1682
pyg_g["Users"].num_nodes = len(pyg_g["Users"]["_key"]) # 944 (prev. 943)

# Re-import PyG graph into ArangoDB
adbpyg_adapter.pyg_to_arangodb("imdb", pyg_g, on_duplicate="update")

Demo (Set[str] as a metagraph value)

metagraph = {
    "nodeTypes": {
        "v0": {"x", "y"}, # equivalent to {"x": "x", "y": "y"}
    },
    "edgeTypes": {
        ("v0", "e0", "v0"): {"edge_attr"},
    },
}

adbpyg_adapter.pyg_to_arangodb("FakeData", data, metagraph, explicit_metagraph=False)

metagraph = {
    "vertexCollections": {
        "v0": {"x", "y"}, # equivalent to {"x": "x", "y": "y"}
    },
    "edgeCollections": {
        "e0": {"edge_attr"},
    },
}

pyg_g = adbpyg_adapter.arangodb_to_pyg("FakeData", metagraph)

adbpyg_adapter/adapter.py Outdated Show resolved Hide resolved
@aMahanna aMahanna changed the title do not merge: preserve_adb_keys in PyG to ArangoDB new: preserve_adb_keys in PyG to ArangoDB Aug 4, 2022
Copy link

@joerg84 joerg84 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the entry Changelog is missing

@aMahanna
Copy link
Member Author

I believe the entry Changelog is missing

@joerg84

No need, as the release.yml action will auto-generate a Changelog entry using commit messages upon triggering a new release (in this case it would be 1.1.0).

Example: #9

@cw00dw0rd cw00dw0rd merged commit a3676a3 into master Sep 21, 2022
@cw00dw0rd cw00dw0rd deleted the feature/adbpyg-map branch September 21, 2022 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants