-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When creating subgraphs (CREATE) the commit is now also serialised ac…
…ross multiple workers. This is required because in specific instances it could happend that neo4j dropped some CREATES (only with relationships). Adds test to verify. Fixes #20.
- Loading branch information
Showing
5 changed files
with
65 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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 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,8 @@ | ||
ENTITY("Entity"): | ||
NODE("Test"): | ||
+ uid = Entity.uid | ||
|
||
|
||
ENTITY("Relationship"): | ||
RELATIONSHIP(MATCH("Test", uid=Relationship.to), "FROM", MATCH("Test", uid=Relationship.from)): | ||
MERGE_RELATIONSHIPS(RELATIONSHIP(MATCH("Test", uid=Relationship.from), "TO", MATCH("Test", uid=Relationship.to))): |
This file contains 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,44 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
""" | ||
Integration tests for testing the synchronous conversion of relations. Related to issue #20. | ||
authors: Julian Minder | ||
""" | ||
|
||
import pytest | ||
|
||
import pandas as pd | ||
import logging | ||
import numpy as np | ||
|
||
from rel2graph import Converter, IteratorIterator, register_attribute_postprocessor, Attribute, register_subgraph_preprocessor, GlobalSharedState, register_subgraph_postprocessor | ||
from rel2graph.utils import load_file | ||
from rel2graph.relational_modules.pandas import PandasDataFrameIterator | ||
from rel2graph.neo4j import match_relationships, push, pull | ||
from rel2graph.common_modules import MERGE_RELATIONSHIPS | ||
|
||
from helpers import * | ||
|
||
|
||
# As this issue is related to multiple workers, we repeat the test multiple times | ||
@pytest.mark.parametrize('execution_number', range(10)) | ||
def test_concurrent_relationships(execution_number, session, uri, auth): | ||
schema = load_file("tests/integration/resources/schema_concurrency.yaml") | ||
|
||
entities = pd.DataFrame({"uid": range(40)}) | ||
|
||
# 120 relations between 20 entities | ||
relations = pd.DataFrame({"from": list(range(20))*6, "to": [i+20 for i in range(20) for _ in range(6)]}) | ||
unique_pairs = len(relations.drop_duplicates()) | ||
print(unique_pairs) | ||
|
||
iterator = IteratorIterator([PandasDataFrameIterator(entities, "Entity"), PandasDataFrameIterator(relations, "Relationship")]) | ||
|
||
converter = Converter(schema, iterator, uri, auth, num_workers=12, batch_size=10) | ||
converter(skip_relationships=False) | ||
|
||
|
||
assert num_relationships(session) == 120+unique_pairs | ||
assert num_nodes(session) == 40 |
This file contains 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