Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache validation ignore pyaerocom version; use mtime instead of ctime #1243

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions pyaerocom/io/cachehandler_ungridded.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,27 @@
head = pickle.load(in_handle)
if not isinstance(head, dict):
raise CacheReadError("Invalid cache file")
pya_version = "pyaerocom_version"
for k, v in head.items():
if not k in current:
raise CacheReadError(f"Invalid cache header key: {k}")
elif not v == current[k]:
logger.info(f"{k} is outdated (value: {v}). Current value: {current[k]}")
return False
else:
if k == pya_version:
continue
elif v != current[k]:
logger.info(f"{k} is outdated (value: {v}). Current value: {current[k]}")
return False

Check warning on line 161 in pyaerocom/io/cachehandler_ungridded.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/io/cachehandler_ungridded.py#L160-L161

Added lines #L160 - L161 were not covered by tests
if current[pya_version] != head[pya_version]:
logger.info(

Check warning on line 163 in pyaerocom/io/cachehandler_ungridded.py

View check run for this annotation

Codecov / codecov/patch

pyaerocom/io/cachehandler_ungridded.py#L163

Added line #L163 was not covered by tests
f"cache generated with pyaerocom {head[pya_version]}, current is {current[pya_version]}"
)
return True

def cache_meta_info(self):
"""Dictionary containing relevant caching meta-info"""
try:
newestp = max(glob.iglob(os.path.join(self.src_data_dir, "*")), key=os.path.getctime)
newest_date = os.path.getctime(newestp)
newestp = max(glob.iglob(os.path.join(self.src_data_dir, "*")), key=os.path.getmtime)
newest_date = os.path.getmtime(newestp)
newest = os.path.basename(newestp)

except Exception:
Expand Down