Skip to content

Commit

Permalink
print errors if users sample from mutable graph. (dmlc#649)
Browse files Browse the repository at this point in the history
* give warning.

* fix.

* update error msg.
  • Loading branch information
zheng-da authored and BarclayII committed Jun 12, 2019
1 parent 059b1a6 commit 8059fa6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/dgl/contrib/sampling/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ class NeighborSampler(NodeFlowSampler):
``len(seed_nodes) // batch_size`` (if ``seed_nodes`` is None, then it is equal
to the set of all nodes in the graph).
Note: NeighborSampler currently only supprts immutable graphs.
Parameters
----------
g : DGLGraph
Expand Down Expand Up @@ -296,6 +298,8 @@ def __init__(
g, batch_size, seed_nodes, shuffle, num_workers * 2 if prefetch else 0,
ThreadPrefetchingWrapper)

assert g.is_readonly, "NeighborSampler doesn't support mutable graphs. " + \
"Please turn it into an immutable graph with DGLGraph.readonly"
assert node_prob is None, 'non-uniform node probability not supported'
assert isinstance(expand_factor, Integral), 'non-int expand_factor not supported'

Expand Down Expand Up @@ -330,6 +334,8 @@ class LayerSampler(NodeFlowSampler):
The NodeFlow loader returns a list of NodeFlows.
The size of the NodeFlow list is the number of workers.
Note: LayerSampler currently only supprts immutable graphs.
Parameters
----------
g : DGLGraph
Expand Down Expand Up @@ -380,6 +386,8 @@ def __init__(
g, batch_size, seed_nodes, shuffle, num_workers * 2 if prefetch else 0,
ThreadPrefetchingWrapper)

assert g.is_readonly, "LayerSampler doesn't support mutable graphs. " + \
"Please turn it into an immutable graph with DGLGraph.readonly"
assert node_prob is None, 'non-uniform node probability not supported'

self._num_workers = int(num_workers)
Expand Down

0 comments on commit 8059fa6

Please sign in to comment.