Skip to content

Commit ca8f37b

Browse files
update links for datasets I had prior to the website going down
1 parent 48d89e9 commit ca8f37b

File tree

3 files changed

+62
-20
lines changed

3 files changed

+62
-20
lines changed

torch_geometric_temporal/dataset/metr_la.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
from torch.utils.data.distributed import DistributedSampler
1010
from typing import Tuple
1111
from ..signal import StaticGraphTemporalSignal
12-
12+
import requests
13+
from tqdm import tqdm
1314

1415
class METRLADatasetLoader(object):
1516
"""A traffic forecasting dataset based on Los Angeles
@@ -35,13 +36,24 @@ def __init__(self, raw_data_dir=os.path.join(os.getcwd(), "data"), index: bool =
3536
self.IndexDataset = IndexDataset
3637

3738
def _download_url(self, url, save_path): # pragma: no cover
38-
context = ssl._create_unverified_context()
39-
with urllib.request.urlopen(url, context=context) as dl_file:
40-
with open(save_path, "wb") as out_file:
41-
out_file.write(dl_file.read())
39+
# Check if file is in data folder from working directory, otherwise download
40+
if not os.path.isfile(
41+
os.path.join(self.raw_data_dir,save_path)
42+
):
43+
print("Downloading to", save_path, flush=True)
44+
45+
response = requests.get(url, stream=True)
46+
file_size = int(response.headers.get('content-length', 0))
47+
48+
with open(os.path.join(self.raw_data_dir, save_path), "wb") as file, tqdm(
49+
total=file_size, unit="B", unit_scale=True, unit_divisor=1024
50+
) as progress_bar:
51+
for chunk in response.iter_content(chunk_size=33554432):
52+
file.write(chunk)
53+
progress_bar.update(len(chunk))
4254

4355
def _read_web_data(self):
44-
url = "https://graphmining.ai/temporal_datasets/METR-LA.zip"
56+
url = "https://anl.app.box.com/shared/static/plgsv3te0akmqluiuqva34su60nn93c2"
4557

4658
# Check if zip file is in data folder from working directory, otherwise download
4759
if not os.path.isfile(

torch_geometric_temporal/dataset/pems_bay.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from torch.utils.data.distributed import DistributedSampler
1010
from torch.utils.data import DataLoader
1111
from typing import Tuple
12+
import requests
13+
from tqdm import tqdm
1214

1315
class PemsBayDatasetLoader(object):
1416
"""A traffic forecasting dataset as described in Diffusion Convolution Layer Paper.
@@ -39,13 +41,25 @@ def __init__(self, raw_data_dir: str =os.path.join(os.getcwd(), "data"),index: b
3941
self.IndexDataset = IndexDataset
4042

4143
def _download_url(self, url, save_path): # pragma: no cover
42-
context = ssl._create_unverified_context()
43-
with urllib.request.urlopen(url, context=context) as dl_file:
44-
with open(save_path, "wb") as out_file:
45-
out_file.write(dl_file.read())
46-
44+
45+
# Check if file is in data folder from working directory, otherwise download
46+
if not os.path.isfile(
47+
os.path.join(self.raw_data_dir,save_path)
48+
):
49+
print("Downloading to", save_path, flush=True)
50+
51+
response = requests.get(url, stream=True)
52+
file_size = int(response.headers.get('content-length', 0))
53+
54+
with open(os.path.join(self.raw_data_dir, save_path), "wb") as file, tqdm(
55+
total=file_size, unit="B", unit_scale=True, unit_divisor=1024
56+
) as progress_bar:
57+
for chunk in response.iter_content(chunk_size=33554432):
58+
file.write(chunk)
59+
progress_bar.update(len(chunk))
60+
4761
def _read_web_data(self):
48-
url = "https://graphmining.ai/temporal_datasets/PEMS-BAY.zip"
62+
url = "https://anl.app.box.com/shared/static/7ealcaw862pm12sglyt5g71743eu7s5l"
4963

5064
# Check if zip file is in data folder from working directory, otherwise download
5165
if not os.path.isfile(

torch_geometric_temporal/dataset/windmilllarge.py

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
from ..signal import StaticGraphTemporalSignal
66
import torch
77
from torch.utils.data import DataLoader
8-
8+
import os
9+
import requests
10+
from tqdm import tqdm
911

1012
class WindmillOutputLargeDatasetLoader(object):
1113
"""Hourly energy output of windmills from a European country
@@ -18,21 +20,35 @@ class WindmillOutputLargeDatasetLoader(object):
1820
Defaults to False.
1921
"""
2022

21-
def __init__(self, index=False):
23+
def __init__(self, raw_data_dir=os.path.join(os.getcwd(), "data"), index=False):
24+
self.raw_data_dir = raw_data_dir
2225
self._read_web_data()
2326
self.index = index
24-
2527
if index:
2628
from ..signal.index_dataset import IndexDataset
2729
self.IndexDataset = IndexDataset
2830

2931

3032
def _read_web_data(self):
31-
url = "https://graphmining.ai/temporal_datasets/windmill_output.json"
32-
context = ssl._create_unverified_context()
33-
self._dataset = json.loads(
34-
urllib.request.urlopen(url, context=context).read().decode()
35-
)
33+
if not os.path.isfile(
34+
os.path.join(self.raw_data_dir, "windmill_output.json")
35+
):
36+
url = "https://anl.app.box.com/shared/static/wgwb75lt3ty3pv5a15y9bilx1mjhcq59"
37+
save_path = f"{self.raw_data_dir}/windmill_output.json"
38+
print("Downloading to", save_path, flush=True)
39+
40+
response = requests.get(url, stream=True)
41+
file_size = int(response.headers.get('content-length', 0))
42+
43+
with open(os.path.join(self.raw_data_dir, save_path), "wb") as file, tqdm(
44+
total=file_size, unit="B", unit_scale=True, unit_divisor=1024
45+
) as progress_bar:
46+
for chunk in response.iter_content(chunk_size=33554432):
47+
file.write(chunk)
48+
progress_bar.update(len(chunk))
49+
50+
with open(f"{self.raw_data_dir}/windmill_output.json", 'r') as f:
51+
self._dataset = json.load(f)
3652

3753
def _get_edges(self):
3854
self._edges = np.array(self._dataset["edges"]).T

0 commit comments

Comments
 (0)