From d4e32f1b8cf02676c3d2107451783e7fe83320a9 Mon Sep 17 00:00:00 2001 From: m-atalla Date: Thu, 6 Jul 2023 17:47:39 +0200 Subject: [PATCH 1/6] update flake8 repository URL and isort version to 5.12.0 --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 718d8668..95285a6d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,7 +50,7 @@ repos: hooks: - id: yamlfmt - repo: https://github.com/timothycrosley/isort - rev: 5.7.0 + rev: 5.12.0 hooks: - id: isort - repo: https://github.com/psf/black @@ -58,7 +58,7 @@ repos: hooks: - id: black language_version: python3.8 - - repo: https://gitlab.com/pycqa/flake8 + - repo: https://github.com/pycqa/flake8 rev: 3.8.4 hooks: - id: flake8 From fe2d25f49cbbedd8798b088fb29bfbab824d1a11 Mon Sep 17 00:00:00 2001 From: m-atalla Date: Thu, 6 Jul 2023 17:48:31 +0200 Subject: [PATCH 2/6] update dgl version to 1.1.1 --- programl/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programl/requirements.txt b/programl/requirements.txt index db4d6937..28f0f482 100644 --- a/programl/requirements.txt +++ b/programl/requirements.txt @@ -1,5 +1,5 @@ absl-py>=0.11.0 -dgl>=0.6.1,<=0.9.1 +dgl==1.1.1 grpcio>=1.33.2 networkx>=2.4 numpy>=1.19.3 From 751623a29f734be85042ee253b6589e0b92470e3 Mon Sep 17 00:00:00 2001 From: m-atalla Date: Thu, 6 Jul 2023 17:49:26 +0200 Subject: [PATCH 3/6] update psutil to version 5.8.0 --- tools/perf_monitor/requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/perf_monitor/requirements.txt b/tools/perf_monitor/requirements.txt index c271188b..5fdaf887 100644 --- a/tools/perf_monitor/requirements.txt +++ b/tools/perf_monitor/requirements.txt @@ -1,2 +1,2 @@ GPUtil==1.4.0 -psutil==5.4.5 +psutil==5.8.0 From 20fc2a662d3673bd1370c82581edfa2eddb17120 Mon Sep 17 00:00:00 2001 From: m-atalla Date: Thu, 6 Jul 2023 21:10:55 +0200 Subject: [PATCH 4/6] add to_dgl_tes to bazel build --- tests/BUILD | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/BUILD b/tests/BUILD index 211ec444..ba238258 100644 --- a/tests/BUILD +++ b/tests/BUILD @@ -134,3 +134,13 @@ py_test( "//tests/plugins", ], ) + +py_test( + name = "to_dgl_test", + srcs = ["to_dgl_test.py"], + deps = [ + "//programl", + "//tests:test_main", + "//tests/plugins", + ], +) From 4b85fc85a225c09beb9180aedf5e4ef1167f23c9 Mon Sep 17 00:00:00 2001 From: m-atalla Date: Thu, 6 Jul 2023 21:18:04 +0200 Subject: [PATCH 5/6] fix dgl upstream API changes and add test --- programl/transform_ops.py | 4 ++-- tests/to_dgl_test.py | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/to_dgl_test.py diff --git a/programl/transform_ops.py b/programl/transform_ops.py index 6c76734b..e0e24d8b 100644 --- a/programl/transform_ops.py +++ b/programl/transform_ops.py @@ -22,7 +22,7 @@ import dgl import networkx as nx -from dgl.heterograph import DGLHeteroGraph +from dgl import DGLGraph from networkx.readwrite import json_graph as nx_json from programl.exceptions import GraphTransformError @@ -168,7 +168,7 @@ def to_dgl( timeout: int = 300, executor: Optional[ExecutorLike] = None, chunksize: Optional[int] = None, -) -> Union[DGLHeteroGraph, Iterable[DGLHeteroGraph]]: +) -> Union[DGLGraph, Iterable[DGLGraph]]: """Convert one or more Program Graphs to `DGLGraphs `_. diff --git a/tests/to_dgl_test.py b/tests/to_dgl_test.py new file mode 100644 index 00000000..371cca55 --- /dev/null +++ b/tests/to_dgl_test.py @@ -0,0 +1,32 @@ +import pytest +from dgl import DGLGraph + +import programl as pg +from tests.test_main import main + +pytest_plugins = ["tests.plugins.llvm_program_graph"] + + +@pytest.fixture(scope="session") +def graph() -> pg.ProgramGraph: + return pg.from_cpp("int A() { return 0; }") + + +def test_to_dgl_simple_graph(graph: pg.ProgramGraph): + graphs = list(pg.to_dgl([graph])) + assert len(graphs) == 1 + assert isinstance(graphs[0], DGLGraph) + + +def test_to_dgl_simple_graph_single_input(graph: pg.ProgramGraph): + dgl_graph = pg.to_dgl(graph) + assert isinstance(dgl_graph, DGLGraph) + + +def test_to_dgl_two_inputs(graph: pg.ProgramGraph): + graphs = list(pg.to_dgl([graph, graph])) + assert len(graphs) == 2 + + +if __name__ == "__main__": + main() From c11d89d7d495c271d66386d625fcb1dd05c50259 Mon Sep 17 00:00:00 2001 From: m-atalla Date: Thu, 6 Jul 2023 22:00:12 +0200 Subject: [PATCH 6/6] update to use from_networkx since the input is nx graph --- programl/transform_ops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programl/transform_ops.py b/programl/transform_ops.py index e0e24d8b..420e1171 100644 --- a/programl/transform_ops.py +++ b/programl/transform_ops.py @@ -201,7 +201,7 @@ def to_dgl( """ def _run_one(nx_graph): - return dgl.DGLGraph(nx_graph) + return dgl.from_networkx(nx_graph) if isinstance(graphs, ProgramGraph): return _run_one(to_networkx(graphs))