Skip to content

Commit

Permalink
Update MG version (#154)
Browse files Browse the repository at this point in the history
* Bump MG version to 2.3.1
  • Loading branch information
jmatak authored Jul 14, 2022
1 parent 5152624 commit 157601a
Show file tree
Hide file tree
Showing 29 changed files with 100 additions and 54 deletions.
67 changes: 34 additions & 33 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@ std::tuple<std::unordered_set<std::uint64_t>, std::unordered_set<std::uint64_t>>
std::unordered_set<std::uint64_t> affected_bcc_nodes;
std::unordered_set<std::uint64_t> affected_bcc_articulation_points;

const std::pair<std::uint64_t, std::uint64_t> updated_edge_inner(
{graph.GetInnerNodeId(updated_edge.first), graph.GetInnerNodeId(updated_edge.second)});

for (std::size_t i = 0; i < edges_by_bcc.size(); i++) {
if (std::any_of(edges_by_bcc[i].begin(), edges_by_bcc[i].end(), [updated_edge](auto &edge) {
return edge.from == updated_edge.first && edge.to == updated_edge.second; // if edge in BCC
if (std::any_of(edges_by_bcc[i].begin(), edges_by_bcc[i].end(), [updated_edge_inner](auto &edge) {
return edge.from == updated_edge_inner.first && edge.to == updated_edge_inner.second; // if edge in BCC
})) {
for (const auto node : nodes_by_bcc[i]) {
affected_bcc_nodes.insert(node);
affected_bcc_nodes.insert(graph.GetMemgraphNodeId(node));
}
for (const auto node : articulation_points_by_bcc) {
if (affected_bcc_nodes.count(node)) affected_bcc_articulation_points.insert(node);
Expand Down Expand Up @@ -542,4 +545,10 @@ std::unordered_map<std::uint64_t, double> OnlineBC::NodeUpdate(const Operation o

return this->node_bc_scores;
}

void OnlineBC::Reset() {
this->node_bc_scores.clear();
this->initialized = false;
}

} // namespace online_bc
Original file line number Diff line number Diff line change
Expand Up @@ -250,5 +250,8 @@ class OnlineBC {
///@return {node ID, BC score} pairs
std::unordered_map<std::uint64_t, double> NodeUpdate(const Operation operation, const std::uint64_t updated_node,
const bool normalize = true);

///@brief Resets the state of the algorithm (initialization and previously calculated node_bc_scores).
void Reset();
};
} // namespace online_bc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void Update(mgp_list *args, mgp_graph *memgraph_graph, mgp_result *result, mgp_m
auto prior_graph =
mg_generate::BuildGraph(graph_nodes_ids, prior_edges_ids, mg_graph::GraphType::kUndirectedGraph);

node_bc_scores = algorithm.Set(*graph, normalize, threads);
node_bc_scores = algorithm.Get(*prior_graph, normalize);

for (const auto created_edge : created_edges) {
prior_edges_ids.push_back(created_edge);
Expand Down Expand Up @@ -260,6 +260,8 @@ extern "C" int mgp_init_module(struct mgp_module *module, struct mgp_memory *mem
}
}

algorithm.Reset();

return 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ queries:
MERGE (a: Node {id: 3}) MERGE (b: Node {id: 4}) CREATE (a)-[:RELATION]->(b);
MERGE (a: Node {id: 3}) MERGE (b: Node {id: 5}) CREATE (a)-[:RELATION]->(b);
MERGE (a: Node {id: 4}) MERGE (b: Node {id: 5}) CREATE (a)-[:RELATION]->(b);
CALL betweenness_centrality_online.set() YIELD *;

cleanup: |-
CALL mg.load('betweenness_centrality_online') YIELD *;
24 changes: 17 additions & 7 deletions e2e/test_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ class TestConstants:
QUERY = "query"
TEST_FILE = "test.yml"
TEST_MODULE_DIR_SUFFIX = "_test"
TEST_GROUP_DIR_SUFFIX = "_group"

ONLINE_TEST_E2E_SETUP = "setup"
ONLINE_TEST_E2E_CLEANUP = "cleanup"
ONLINE_TEST_E2E_INPUT_QUERIES = "queries"
ONLINE_TEST_SUBDIR_PREFIX = "test_online"

ABSOLUTE_TOLERANCE = 1e-3


def _node_to_dict(data):
labels = data.labels if hasattr(data, "labels") else data._labels
Expand All @@ -53,18 +52,29 @@ def prepare_tests():
tests = []

test_path = Path().cwd()

for module_test_dir in test_path.iterdir():
if not module_test_dir.is_dir() or not module_test_dir.name.endswith(
TestConstants.TEST_MODULE_DIR_SUFFIX
):
continue

for test_dir in module_test_dir.iterdir():
if not test_dir.is_dir():
for test_or_group_dir in module_test_dir.iterdir():
if not test_or_group_dir.is_dir():
continue
tests.append(
pytest.param(test_dir, id=f"{module_test_dir.stem}-{test_dir.stem}")
)

if test_or_group_dir.name.endswith(TestConstants.TEST_GROUP_DIR_SUFFIX):
for test_dir in test_or_group_dir.iterdir():
if not test_dir.is_dir():
continue

tests.append(
pytest.param(test_dir, id=f"{module_test_dir.stem}-{test_or_group_dir.stem}-{test_dir.stem}")
)
else:
tests.append(
pytest.param(test_or_group_dir, id=f"{module_test_dir.stem}-{test_or_group_dir.stem}")
)
return tests


Expand Down
40 changes: 30 additions & 10 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ HELP_MESSAGE = """\
For usage info run: python3 setup -h
"""


class BuildType(Enum):
DEBUG = "Debug"
RELEASE = "Release"
Expand All @@ -42,20 +43,29 @@ def get_arguments():
)
subparsers = parser.add_subparsers(help="sub-command help", dest="action")

build_args_parser = argparse.ArgumentParser(description="Build arguments", add_help=False)
build_args_parser = argparse.ArgumentParser(
description="Build arguments", add_help=False
)
build_args_parser.add_argument(
"-p", "--path", help="Path to query modules directory", required=False
)
build_args_parser.add_argument(
"--type", help="Build type", type=BuildType, choices=list(BuildType), required=False
"--type",
help="Build type",
type=BuildType,
choices=list(BuildType),
required=False,
)
build_args_parser.add_argument("--gpu", help="GPU Algorithms", action="store_true")
build_args_parser.add_argument(
"--gpu", help="GPU Algorithms", action='store_true'
"--cpp-build-flags",
nargs="+",
help="CMake flags for the cpp part (without -D)",
required=False,
)
build_args_parser.add_argument(
"--cpp-build-flags", nargs="+", help="CMake flags for the cpp part (without -D)", required=False
build_parser = subparsers.add_parser(
"build", help="Build memgraph-mage", parents=[build_args_parser]
)
build_parser = subparsers.add_parser("build", help="Build memgraph-mage", parents=[build_args_parser])

query_modules_parser = subparsers.add_parser(
"modules_storage", help="Add path of mage/dist to memgraph.conf "
Expand All @@ -75,7 +85,9 @@ def get_arguments():
default=MAGE_BUILD_DIRECTORY,
)

subparsers.add_parser("all", help="Set up memgraph-mage for usage", parents=[build_args_parser])
subparsers.add_parser(
"all", help="Set up memgraph-mage for usage", parents=[build_args_parser]
)

return parser.parse_args()

Expand Down Expand Up @@ -176,12 +188,20 @@ def build(args):
os.chdir(project_dir)
rs_build_mode = "release"
if args.type is not None:
if args.type == BuildType.DEBUG: rs_build_mode = "debug"
if args.type == BuildType.RELEASE: rs_build_mode = "release"
if args.type == BuildType.DEBUG:
rs_build_mode = "debug"
if args.type == BuildType.RELEASE:
rs_build_mode = "release"
rs_build_flags = ["--release"]
if args.type is not None and args.type == BuildType.DEBUG:
rs_build_flags = []
subprocess.run(["cargo", "build"] + rs_build_flags)

# Build Rust query modules
subprocess.run(
["cargo", "build"] + rs_build_flags,
check=True,
env=dict(os.environ, CARGO_NET_GIT_FETCH_WITH_CLI="true"),
)

release_dir = os.path.join(project_dir, "target", "%s" % rs_build_mode)
os.chdir(release_dir)
Expand Down

0 comments on commit 157601a

Please sign in to comment.