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

[GraphBolt] Move get_attributes utils. #7601

Merged
merged 3 commits into from
Jul 28, 2024
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
8 changes: 6 additions & 2 deletions python/dgl/graphbolt/impl/ondisk_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@
calculate_dir_hash,
check_dataset_change,
copy_or_convert_data,
get_attributes,
read_data,
read_edges,
)
from ..internal_utils import download, extract_archive, gb_warning
from ..internal_utils import (
download,
extract_archive,
gb_warning,
get_attributes,
)
from ..itemset import HeteroItemSet, ItemSet
from ..sampling_graph import SamplingGraph
from .fused_csc_sampling_graph import (
Expand Down
2 changes: 1 addition & 1 deletion python/dgl/graphbolt/impl/sampled_subgraph_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import torch

from ..base import CSCFormatBase, etype_str_to_tuple
from ..internal import get_attributes
from ..internal_utils import get_attributes
from ..sampled_subgraph import SampledSubgraph

__all__ = ["SampledSubgraphImpl"]
Expand Down
26 changes: 0 additions & 26 deletions python/dgl/graphbolt/internal/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,32 +144,6 @@ def copy_or_convert_data(
save_data(data, output_path, output_format)


def get_nonproperty_attributes(_obj) -> list:
"""Get attributes of the class except for the properties."""
attributes = [
attribute
for attribute in dir(_obj)
if not attribute.startswith("__")
and (
not hasattr(type(_obj), attribute)
or not isinstance(getattr(type(_obj), attribute), property)
)
and not callable(getattr(_obj, attribute))
]
return attributes


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


def read_edges(dataset_dir, edge_fmt, edge_path):
"""Read egde data from numpy or csv."""
assert edge_fmt in [
Expand Down
26 changes: 26 additions & 0 deletions python/dgl/graphbolt/internal_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,32 @@ def recursive_apply_reduce_all(data, fn, *args, **kwargs):
return fn(data, *args, **kwargs)


def get_nonproperty_attributes(_obj) -> list:
"""Get attributes of the class except for the properties."""
attributes = [
attribute
for attribute in dir(_obj)
if not attribute.startswith("__")
and (
not hasattr(type(_obj), attribute)
or not isinstance(getattr(type(_obj), attribute), property)
)
and not callable(getattr(_obj, attribute))
]
return attributes


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


def download(
url,
path=None,
Expand Down
7 changes: 5 additions & 2 deletions python/dgl/graphbolt/minibatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
import torch

from .base import CSCFormatBase, etype_str_to_tuple, expand_indptr
from .internal import get_attributes, get_nonproperty_attributes
from .internal_utils import recursive_apply
from .internal_utils import (
get_attributes,
get_nonproperty_attributes,
recursive_apply,
)
from .sampled_subgraph import SampledSubgraph

__all__ = ["MiniBatch"]
Expand Down
Loading