Skip to content

Commit

Permalink
comment on road grade; exception handling on unpickling
Browse files Browse the repository at this point in the history
  • Loading branch information
liljonnystyle committed Jul 9, 2020
1 parent f63cc37 commit c2836e8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions flow/energy_models/base_energy.py
Expand Up @@ -10,6 +10,9 @@ class BaseEnergyModel(metaclass=ABCMeta):
vehicle type: whether EV or Combustion Engine, Toyota Prius or Tacoma
or non-Toyota vehicles. Non-Toyota vehicles are set by default
to be an averaged-size vehicle.
Note: road grade is included as an input parameter, but the
functional dependence on road grade is not yet implemented.
"""

def __init__(self):
Expand Down
9 changes: 8 additions & 1 deletion flow/energy_models/toyota_energy.py
Expand Up @@ -14,8 +14,15 @@ def __init__(self, filename):
# download file from s3 bucket
s3 = boto3.client('s3')
s3.download_file('toyota.restricted', filename, 'temp.pkl')

with open('temp.pkl', 'rb') as file:
self.toyota_energy = pickle.load(file)
try:
self.toyota_energy = pickle.load(file)
except TypeError:
print('Must use Python version 3.6.8 to unpickle')
# delete pickle file
os.remove(file)
raise

# delete pickle file
os.remove(file)
Expand Down

0 comments on commit c2836e8

Please sign in to comment.