Skip to content

Commit

Permalink
Add processed flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaurav S Deshmukh committed Sep 21, 2023
1 parent ffac10b commit 964dfcd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def __init__(self, root, prop_csv):
# Create processed path if it doesn't exist
self.processed_path = Path(self.processed_dir)
self.processed_path.mkdir(exist_ok=True)
self.process_flag = False

# Read csv
self.prop_csv = prop_csv
Expand Down Expand Up @@ -124,6 +125,9 @@ def process_data(self, z_cutoffs, node_features, edge_features, pad=False,

# Save data objects
torch.save(data_objects, self.processed_path / f"data_{i}.pt")

# Set process flag to true
self.process_flag = True

def len(self):
"""Return size of the dataset."""
Expand All @@ -133,6 +137,11 @@ def get(self, i):
"""Fetch the processed graph(s) at the i-th index."""
data_objects = torch.load(self.processed_path / f"data_{i}.pt")
return data_objects

def processed_status(self):
"""Check if the dataset is processed."""
return self.process_flag


if __name__ == "__main__":
# Get path to root directory
Expand Down

0 comments on commit 964dfcd

Please sign in to comment.