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

updated dgl dependency #268

Merged
merged 3 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/dglke/dataloader/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def ConstructGraph(dataset, args):
n_entities = dataset.n_entities

coo = sp.sparse.coo_matrix((np.ones(len(src)), (src, dst)), shape=[n_entities, n_entities])
g = dgl.DGLGraph(coo, readonly=True, multigraph=True, sort_csr=True)
g = dgl._deprecate.graph.DGLGraph(coo, readonly=True, multigraph=True, sort_csr=True)
g.edata['tid'] = F.tensor(etype_id, F.int64)
if args.has_edge_importance:
e_impts = F.tensor(dataset.train[3], F.float32)
Expand Down Expand Up @@ -418,7 +418,7 @@ def create_sampler(self, batch_size, neg_sample_size=2, neg_chunk_size=None, mod
exclude_positive=exclude_positive,
return_false_neg=False)

class ChunkNegEdgeSubgraph(dgl.DGLGraph):
class ChunkNegEdgeSubgraph(dgl._deprecate.graph.DGLGraph):
"""Wrapper for negative graph

Parameters
Expand Down
2 changes: 1 addition & 1 deletion python/dglke/models/ke_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def attach_graph(self, g, etid_field='tid', ntid_filed='ntid'):
"""
self._etid_field = etid_field
self._ntid_filed = ntid_filed
assert isinstance(g, dgl.DGLGraph)
assert isinstance(g, dgl._deprecate.graph.DGLGraph)
self._g = g

def load(self, model_path):
Expand Down
2 changes: 1 addition & 1 deletion python/dglke/partition.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def main():
src, etype_id, dst = dataset.train
coo = sp.sparse.coo_matrix((np.ones(len(src)), (src, dst)),
shape=[dataset.n_entities, dataset.n_entities])
g = dgl.DGLGraph(coo, readonly=True, multigraph=True, sort_csr=True)
g = dgl._deprecate.graph.DGLGraph(coo, readonly=True, multigraph=True, sort_csr=True)
g.edata['tid'] = F.tensor(etype_id, F.int64)

print('partition graph...')
Expand Down
2 changes: 1 addition & 1 deletion python/dglke/tests/test_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class dotdict(dict):

def generate_rand_graph(n, func_name):
arr = (sp.sparse.random(n, n, density=0.1, format='coo') != 0).astype(np.int64)
g = dgl.DGLGraph(arr, readonly=True)
g = dgl._deprecate.graph.DGLGraph(arr, readonly=True)
num_rels = 10
entity_emb = F.uniform((g.number_of_nodes(), 10), F.float32, F.cpu(), 0, 1)
if func_name == 'RotatE':
Expand Down
4 changes: 2 additions & 2 deletions python/dglke/tests/test_topk.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def check_topk_score2(score_model, exclude_mode):
th.full((num_entity*2,), 2, dtype=th.long),
th.full((num_entity*2,), 3, dtype=th.long)],
dim=0)
g = dgl.graph((src, dst))
g = dgl._deprecate.graph.DGLGraph((src, dst))
g.edata['tid'] = etype

_check_topk_score2(score_model, g, num_entity, num_rels, exclude_mode)
Expand Down Expand Up @@ -1261,4 +1261,4 @@ def test_gnn_model_topk_emb(device='cpu'):
test_rescal_model_topk_emb(device=0)
#test_transr_model_topk_emb()
test_rotate_model_topk_emb(device=0)
test_gnn_model_topk_emb(device=0)
test_gnn_model_topk_emb(device=0)
4 changes: 2 additions & 2 deletions tests/scripts/task_kg_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ conda activate ${DGLBACKEND}-ci
# test
if [ "$2" == "cpu" ]; then
pip3 uninstall dgl
pip3 install dgl==0.4.3post2
pip3 install dgl>=0.5.0,<=0.9.1
else
pip3 uninstall dgl
pip3 install dgl-cu102==0.4.3post2
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a comment about what is the latest dgl version that works with this patch. As we are using dgl._deprecate.graph.DGLGraph, this interface may be deleted in some date.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you @classicsong , I have added a minimum and maximum dependency for the tests

Copy link
Contributor

@lroberts7 lroberts7 Dec 7, 2022

Choose a reason for hiding this comment

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

This breaks the partition method (here: https://github.com/awslabs/dgl-ke/blob/master/python/dglke/partition.py#L119 ) because dgl switched the attribute name from dgl.transform to dgl.transforms in version 0.8.

Copy link
Contributor

Choose a reason for hiding this comment

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

https://github.com/dmlc/dgl/releases/tag/0.8.0 under Graph Dataset and Transforms section

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm using version 0.9.1 of dgl and got this error. A reasonable work around for this would be to switch using the Version class in packaging.version.Version on version 0.8. I'll open a CR for this, (unless someone from this project indicates a preferred alternate way or says this shouldn't be done).

pip3 install dgl-cu102>=0.5.0,<=0.9.1
fi

pushd $KG_DIR> /dev/null
Expand Down