Skip to content

Commit

Permalink
Make cache_df work without path Klimatbyran#682
Browse files Browse the repository at this point in the history
* Make default path a valid string.
* Remove obsolete error handling for no path.
  • Loading branch information
joakimbits committed Sep 24, 2024
1 parent 06e1102 commit 5627a2d
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions data/issues/emissions/cache_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pandas as pd


def cache_df(f: type(pd.read_excel) = None, path: str = None, freq: str = '1Y'):
def cache_df(f: type(pd.read_excel) = None, path: str = '', freq: str = '1Y'):
"""
Cache the DataFrame to an intermediate file and use it if created within the same period.
Expand Down Expand Up @@ -72,9 +72,6 @@ def cache_df(f: type(pd.read_excel) = None, path: str = None, freq: str = '1Y'):
def caching_f(*args, **kwargs):
input_path = kwargs.get('path') or (args[0] if args else path)

if not input_path:
raise ValueError("Path parameter is required either as a decorator argument or function argument.")

# Create a hash of the path for the cache file
path_hash = hashlib.md5(input_path.encode()).hexdigest()
df_file = f'cache_df_{f.__name__}_{path_hash}.feather'
Expand Down

0 comments on commit 5627a2d

Please sign in to comment.