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

Adding metadata getter methods to datasets API #3821

Merged
merged 8 commits into from
Sep 8, 2023

Conversation

nv-rliu
Copy link
Contributor

@nv-rliu nv-rliu commented Aug 23, 2023

Closes #3820

This PR adds simple getter methods to the dataset class, which allows users to easily get information about datasets without need to access the metadata dict or look in the directory.

from cugraph.datasets import karate

# users now call
karate.number_of_nodes()

# instead of 
karate.metadata['number_of_nodes']

@nv-rliu nv-rliu added feature request New feature or request improvement Improvement / enhancement to an existing function non-breaking Non-breaking change and removed feature request New feature or request labels Aug 23, 2023
@copy-pr-bot
Copy link

copy-pr-bot bot commented Aug 30, 2023

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@rlratzel
Copy link
Contributor

/ok to test

@nv-rliu nv-rliu self-assigned this Sep 6, 2023
@nv-rliu nv-rliu added this to the 23.10 milestone Sep 6, 2023
@rlratzel
Copy link
Contributor

rlratzel commented Sep 6, 2023

/ok to test

@nv-rliu nv-rliu marked this pull request as ready for review September 7, 2023 13:56
@nv-rliu nv-rliu requested a review from a team as a code owner September 7, 2023 13:56
@eriknw
Copy link
Contributor

eriknw commented Sep 7, 2023

/ok to test

Copy link
Member

@alexbarghi-nv alexbarghi-nv left a comment

Choose a reason for hiding this comment

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

👍

@alexbarghi-nv
Copy link
Member

/merge

@rapids-bot rapids-bot bot merged commit 6779e89 into rapidsai:branch-23.10 Sep 8, 2023
57 checks passed
Comment on lines +331 to +338
@pytest.mark.parametrize("dataset", ALL_DATASETS)
def test_object_getters(dataset):
assert dataset.is_directed() == dataset.metadata["is_directed"]
assert dataset.is_multigraph() == dataset.metadata["is_multigraph"]
assert dataset.is_symmetric() == dataset.metadata["is_symmetric"]
assert dataset.number_of_nodes() == dataset.metadata["number_of_nodes"]
assert dataset.number_of_vertices() == dataset.metadata["number_of_nodes"]
assert dataset.number_of_edges() == dataset.metadata["number_of_edges"]
Copy link
Contributor

Choose a reason for hiding this comment

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

This really isn't testing much more than if the APIs are returning the metadata dict, and could start failing if we ever intentionally change the implementation to return something that's still valid but doesn't match the metadata dict exactly.

A better test would be if you verified is_directed and others are actually True or False based on if the datasets are directed or not, etc.

rlratzel pushed a commit to rlratzel/cugraph that referenced this pull request Sep 8, 2023
Closes rapidsai#3820

This PR adds simple getter methods to the `dataset` class, which allows users to easily get information about datasets without need to access the `metadata` dict or look in the directory.

```python
from cugraph.datasets import karate

# users now call
karate.number_of_nodes()

# instead of
karate.metadata['number_of_nodes']
```

Authors:
  - ralph (https://github.com/nv-rliu)

Approvers:
  - Alex Barghi (https://github.com/alexbarghi-nv)

URL: rapidsai#3821
@nv-rliu nv-rliu deleted the datasets-getter-methods branch October 17, 2023 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEA]: Add getters to Datasets API to easily get metadata information
4 participants