Skip to content

Commit 4415acf

Browse files
author
Marc Damie
committed
Add a light dataset option to reduce disk space usage
1 parent f85d22b commit 4415acf

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

fedivertex/main.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ class GraphLoader:
2525
}
2626
UNDIRECTED_GRAPHS = ["federation"]
2727

28-
def __init__(
29-
self,
30-
url="https://www.kaggle.com/datasets/marcdamie/fediverse-graph-dataset/croissant/download",
31-
):
28+
def __init__(self, light_version=True):
29+
self.light_version = light_version
30+
if self.light_version:
31+
url = (
32+
"https://www.kaggle.com/datasets/marcdamie/fediverse-graph-dataset-reduced/croissant/download",
33+
)
34+
else:
35+
url = (
36+
"https://www.kaggle.com/datasets/marcdamie/fediverse-graph-dataset/croissant/download",
37+
)
3238
try:
3339
self.dataset = mlc.Dataset(jsonld=url)
3440
except json.JSONDecodeError as err:
@@ -58,6 +64,12 @@ def _check_input(self, software: str, graph_type: str) -> NoneType:
5864
f"{graph_type} is not a valid graph type for {software}. Valid types: {self.VALID_GRAPH_TYPES[software]}"
5965
)
6066

67+
if self.light_version and software == "mastodon" and graph_type == "federation":
68+
raise ValueError(
69+
f"The graph {software} {graph_type} is not included in the light version of Fedivertex\n"
70+
"To download the full version, generate the dataset loader as follows: `GraphLoader(light_version=False)`"
71+
)
72+
6173
def _fetch_date_index(self, software: str, graph_type: str, index: int) -> str:
6274
"""Returns the i-th date available for a given graph type.
6375
The dates are sorted increasingly.

0 commit comments

Comments
 (0)