Skip to content

Commit

Permalink
Catch error when trying to load parquet file of size 0
Browse files Browse the repository at this point in the history
  • Loading branch information
c-schrade authored Apr 19, 2024
1 parent e31bf4a commit f1f85f8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions algo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import pickle
import torch
import os
from pyarrow.lib import ArrowInvalid

import operator_lib.util as util

Expand Down Expand Up @@ -159,12 +160,15 @@ def load_data(filename_dict, data_list, initial_time, first_data_time, last_trai

if os.path.exists(data_path):
data_list = []
df = pd.read_parquet(data_path)
df.index = pd.to_datetime(df.index)
data_series = pd.Series(data=df['power_values'], index=df.index)
data_series = df[~df.index.duplicated(keep='first')]
for i in range(len(data_series.index)):
data_list.append([data_series.index[i], float(data_series.iloc[i])])
try:
df = pd.read_parquet(data_path)
df.index = pd.to_datetime(df.index)
data_series = pd.Series(data=df['power_values'], index=df.index)
data_series = df[~df.index.duplicated(keep='first')]
for i in range(len(data_series.index)):
data_list.append([data_series.index[i], float(data_series.iloc[i])])
except ArrowInvalid:
print("Data buffer could not be loaded! This might be caused by not having any data in the buffer yet.")

if os.path.exists(initial_time_path):
with open(initial_time_path, 'rb') as f:
Expand Down

0 comments on commit f1f85f8

Please sign in to comment.