Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

make 'cached_path' work offline #4253

Merged
merged 6 commits into from
May 18, 2020
Merged

Conversation

epwalsh
Copy link
Member

@epwalsh epwalsh commented May 18, 2020

This also does some additional clean up to file_utils.py, in particular renaming the internal functions of the module with a leading underscore so that they won't be included in the API docs.

epwalsh and others added 2 commits May 18, 2020 15:20
Co-authored-by: Michael Schmitz <michael@schmitztech.com>
)
latest_cached = _find_latest_cached(url, cache_dir)
if latest_cached:
return latest_cached
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth logging something here? Users probably will not hit this often.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the warning right above?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No--my bad. Should we log the filepath of the file that will be used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Do you think INFO or WARNING level would be more appropriate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

INFO?

Copy link
Member

@schmmd schmmd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While I don't think this addresses the problem in #4234 (I believe the poster is running models on a system that has never had internet connectivity--I followed up with a solution), this seems like a great feature. It's always bothered me that we cannot use our cache while offline. While it's an edge case, it's super annoying when it happens (e.g. developing while traveling).

@schmmd
Copy link
Member

schmmd commented May 18, 2020

@epwalsh I would take "closes #4234" out of the description.

latest_cached = _find_latest_cached(url, cache_dir)
if latest_cached:
return latest_cached
logger.error(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a nit, but I prefer to have an else clause. I had trouble reading this in the CR because of this (an how Python handles blocks with spacing)--but admittedly it's just personal preference.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yea that's totally fine with me, I'm just used to certain linters raising a fit about "unnecessary else clause". I guess either flake8 doesn't care or we're explicitly ignoring that in our .flake8

@epwalsh epwalsh merged commit 7d71398 into allenai:master May 18, 2020
@epwalsh epwalsh deleted the file-utils-offline branch May 18, 2020 23:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants