Skip to content

Commit af13bfe

Browse files
authored
Merge pull request #808 from RasmusOrsoe/remove_awk_and_timer
Remove `awkward` and `timer` from dependencies
2 parents 9b1d49c + 3b6f23a commit af13bfe

File tree

3 files changed

+18
-23
lines changed

3 files changed

+18
-23
lines changed

examples/02_data/01_read_dataset.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
"""Example of reading events from Dataset class."""
22

3-
from timer import timer
4-
5-
import awkward
63
import sqlite3
74
import time
8-
import torch.multiprocessing
9-
import torch.utils.data
5+
import torch
106
from torch_geometric.data.batch import Batch
117
from tqdm import tqdm
8+
import pandas as pd
9+
import os
1210

1311
from graphnet.constants import TEST_PARQUET_DATA, TEST_SQLITE_DATA
1412
from graphnet.data.constants import FEATURES, TRUTH
@@ -47,8 +45,10 @@ def main(backend: str) -> None:
4745
num_workers = 30
4846
wait_time = 0.00 # sec.
4947

50-
# Define graph representation
51-
graph_definition = KNNGraph(detector=IceCubeDeepCore())
48+
# Define data representation
49+
data_representation = KNNGraph(
50+
detector=IceCubeDeepCore(), input_feature_names=features
51+
)
5252

5353
for table in [pulsemap, truth_table]:
5454
# Get column names from backend
@@ -57,9 +57,11 @@ def main(backend: str) -> None:
5757
cursor = conn.execute(f"SELECT * FROM {table} LIMIT 1")
5858
names = list(map(lambda x: x[0], cursor.description))
5959
else:
60-
ak = awkward.from_parquet(path, lazy=True)
61-
names = ak[table].fields
62-
del ak
60+
df = pd.DataFrame(os.path.join(path, f"{table}*.parquet"))
61+
names = df.columns.tolist()
62+
# ak = awkward.from_parquet(path, lazy=True)
63+
# names = ak[table].fields
64+
# del ak
6365

6466
# Print
6567
logger.info(f"Available columns in {table}")
@@ -73,7 +75,7 @@ def main(backend: str) -> None:
7375
features=features,
7476
truth=truth,
7577
truth_table=truth_table,
76-
graph_definition=graph_definition,
78+
data_representation=data_representation,
7779
)
7880
assert isinstance(dataset, Dataset)
7981

@@ -91,13 +93,11 @@ def main(backend: str) -> None:
9193
shuffle=True,
9294
num_workers=num_workers,
9395
collate_fn=Batch.from_data_list,
94-
# persistent_workers=True,
9596
prefetch_factor=2,
9697
)
9798

98-
with timer("torch dataloader"):
99-
for batch in tqdm(dataloader, unit=" batches", colour="green"):
100-
time.sleep(wait_time)
99+
for batch in tqdm(dataloader, unit=" batches", colour="green"):
100+
time.sleep(wait_time)
101101

102102
logger.info(str(batch))
103103
logger.info(batch.size())

examples/02_data/04_ensemble_dataset.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
"""Example of combining multiple Datasets using EnsembleDataset."""
22

33
import time
4-
from timer import timer
5-
import torch.multiprocessing
6-
import torch.utils.data
4+
import torch
75
from torch_geometric.data.batch import Batch
86
from tqdm import tqdm
97

@@ -74,9 +72,8 @@ def main() -> None:
7472
prefetch_factor=2,
7573
)
7674

77-
with timer("torch dataloader"):
78-
for batch in tqdm(dataloader, unit=" batches", colour="green"):
79-
time.sleep(wait_time)
75+
for batch in tqdm(dataloader, unit=" batches", colour="green"):
76+
time.sleep(wait_time)
8077

8178
for i in range(batch_size):
8279
logger.info(f"Event {i} came from {batch['dataset_path'][i]}")

setup.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
]
1111

1212
INSTALL_REQUIRES = [
13-
"awkward>=1.8,<2.0",
1413
"colorlog>=6.6",
1514
"configupdater",
1615
"dill>=0.3",
@@ -23,7 +22,6 @@
2322
"scikit_learn>=1.0",
2423
"scipy>=1.7",
2524
"sqlalchemy>=1.4",
26-
"timer>=0.2",
2725
"tqdm>=4.64",
2826
"wandb>=0.12",
2927
"polars >=0.19",

0 commit comments

Comments
 (0)