Unverified Commit 659b9289 authored by yxy235's avatar yxy235 Committed by GitHub
Browse files

[GraphBolt] Move `get_attributes` function to internal. (#6634)


Co-authored-by: default avatarUbuntu <ubuntu@ip-172-31-0-133.us-west-2.compute.internal>
parent e9c339b2
...@@ -6,6 +6,7 @@ from typing import Dict, Tuple, Union ...@@ -6,6 +6,7 @@ from typing import Dict, Tuple, Union
import torch import torch
from ..base import CSCFormatBase, etype_str_to_tuple from ..base import CSCFormatBase, etype_str_to_tuple
from ..internal import get_attributes
from ..sampled_subgraph import SampledSubgraph from ..sampled_subgraph import SampledSubgraph
__all__ = ["FusedSampledSubgraphImpl", "SampledSubgraphImpl"] __all__ = ["FusedSampledSubgraphImpl", "SampledSubgraphImpl"]
...@@ -140,16 +141,7 @@ class SampledSubgraphImpl(SampledSubgraph): ...@@ -140,16 +141,7 @@ class SampledSubgraphImpl(SampledSubgraph):
def _sampled_subgraph_str(sampled_subgraph: SampledSubgraph, classname) -> str: def _sampled_subgraph_str(sampled_subgraph: SampledSubgraph, classname) -> str:
final_str = classname + "(" final_str = classname + "("
def _get_attributes(_obj) -> list: attributes = get_attributes(sampled_subgraph)
attributes = [
attribute
for attribute in dir(_obj)
if not attribute.startswith("__")
and not callable(getattr(_obj, attribute))
]
return attributes
attributes = _get_attributes(sampled_subgraph)
attributes.reverse() attributes.reverse()
for name in attributes: for name in attributes:
......
...@@ -109,3 +109,14 @@ def copy_or_convert_data( ...@@ -109,3 +109,14 @@ def copy_or_convert_data(
if is_feature and data.dim() == 1: if is_feature and data.dim() == 1:
data = data.reshape(-1, 1) data = data.reshape(-1, 1)
save_data(data, output_path, output_format) save_data(data, output_path, output_format)
def get_attributes(_obj) -> list:
"""Get attributes of the class."""
attributes = [
attribute
for attribute in dir(_obj)
if not attribute.startswith("__")
and not callable(getattr(_obj, attribute))
]
return attributes
...@@ -10,6 +10,7 @@ from dgl.heterograph import DGLBlock ...@@ -10,6 +10,7 @@ from dgl.heterograph import DGLBlock
from dgl.utils import recursive_apply from dgl.utils import recursive_apply
from .base import CSCFormatBase, etype_str_to_tuple from .base import CSCFormatBase, etype_str_to_tuple
from .internal import get_attributes
from .sampled_subgraph import SampledSubgraph from .sampled_subgraph import SampledSubgraph
__all__ = ["DGLMiniBatch", "MiniBatch"] __all__ = ["DGLMiniBatch", "MiniBatch"]
...@@ -574,17 +575,7 @@ class MiniBatch: ...@@ -574,17 +575,7 @@ class MiniBatch:
def _minibatch_str(minibatch: MiniBatch) -> str: def _minibatch_str(minibatch: MiniBatch) -> str:
final_str = "" final_str = ""
# Get all attributes in the class except methods. # Get all attributes in the class except methods.
attributes = get_attributes(minibatch)
def _get_attributes(_obj) -> list:
attributes = [
attribute
for attribute in dir(_obj)
if not attribute.startswith("__")
and not callable(getattr(_obj, attribute))
]
return attributes
attributes = _get_attributes(minibatch)
attributes.reverse() attributes.reverse()
# Insert key with its value into the string. # Insert key with its value into the string.
for name in attributes: for name in attributes:
...@@ -617,17 +608,7 @@ def _minibatch_str(minibatch: MiniBatch) -> str: ...@@ -617,17 +608,7 @@ def _minibatch_str(minibatch: MiniBatch) -> str:
def _dgl_minibatch_str(dglminibatch: DGLMiniBatch) -> str: def _dgl_minibatch_str(dglminibatch: DGLMiniBatch) -> str:
final_str = "" final_str = ""
# Get all attributes in the class except methods. # Get all attributes in the class except methods.
attributes = get_attributes(dglminibatch)
def _get_attributes(_obj) -> list:
attributes = [
attribute
for attribute in dir(_obj)
if not attribute.startswith("__")
and not callable(getattr(_obj, attribute))
]
return attributes
attributes = _get_attributes(dglminibatch)
attributes.reverse() attributes.reverse()
# Insert key with its value into the string. # Insert key with its value into the string.
for name in attributes: for name in attributes:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment