awslabs/dgl-ke

dgl.__version__ >= 0.8 breaks on partition.py

lroberts7 opened this issue · 2 comments

I noted this in a comment:
https://github.com/awslabs/dgl-ke/pull/268/files#diff-6fa7773ef2017429e0385fdbff10e2c9b5021e282a503eb7e47eeb93f651eb18

The version upgrade in dgl
#268
caused the dgl.transform method in partition.py to raise an error here:

part_dict = dgl.transform.metis_partition(g, num_parts, 1)

if the environment has a morerecent version of dgl.

Dgl version 0.8 changed the name to transforms (added an s) -> https://github.com/dmlc/dgl/releases/tag/0.8.0

A fix would be to add an if/else block based on the dgl version and call either attribute. I used the search box in github to search this repository and this appears to be the only use of the dgl.transform

Note there aren't any unit tests on this as it's a simple call out to dgl but if there are suggestions around adding a unit test please let me know. Also here is a stacktrace of the issue:

$ dglke_partition -k 1 --data_path '/Users/lroberts/datascience/dgl/dgl-ke/data/codebase'
load dataset..
Reading train triples....
Finished. Read 483142 train triples.
Reading valid triples....
Finished. Read 50000 valid triples.
Reading test triples....
Finished. Read 59071 test triples.
construct graph...
/opt/homebrew/lib/python3.10/site-packages/dgl/_deprecate/graph.py:1023: DGLWarning: multigraph will be deprecated.DGL will treat all graphs as multigraph in the future.
  dgl_warning("multigraph will be deprecated." \
partition graph...
Traceback (most recent call last):
  File "/opt/homebrew/bin/dglke_partition", line 33, in <module>
    sys.exit(load_entry_point('dglke==0.1.0.dev0', 'console_scripts', 'dglke_partition')())
  File "/opt/homebrew/lib/python3.10/site-packages/dglke-0.1.0.dev0-py3.10.egg/dglke/partition.py", line 119, in main
AttributeError: module 'dgl' has no attribute 'transform'. Did you mean: 'transforms'?

$ python3
Python 3.10.8 (main, Oct 13 2022, 09:48:40) [Clang 14.0.0 (clang-1400.0.29.102)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

import dgl
print(dgl.version)
0.9.1

closed via -> #270