Skip to content

Conversation

@jl-wynen
Copy link
Member

@jl-wynen jl-wynen commented Aug 8, 2025

The main change here is the addition of @cache in get_path. See scipp/esssans#206.

I decided to put this into ESSreduce to allow the instrument packages to take advantage of it. It would be nice to place it further upstream but I don't see a good package for it. And the performance impact is most relevant for the instrument packages because they rely more on data files for their tests.

Comment on lines +42 to +43
@cache # noqa: B019
def get_path(self, name: str, unzip: bool = False) -> Path:
Copy link
Member

Choose a reason for hiding this comment

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

Are there cases where caching is bad, either because the file was corrupted or deleted? I am more thinking of the use case of users running tutorials, not the unit tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Depends. There are a couple of scenarios:

  • If the file is bad when calling get_path, it redownloads the file.
  • If the download fails, it raises an exception and the result is not cached. So calling get_path again, attempts the download again.
  • Likewise, if the download succeeds but file access fails, we can an exception and the result is not cached.
  • If the first call to get_path succeeds and the file gets corrupted or removed afterwards, a second call to get_path will simply return the same path without any checks.

Did I miss a scenario?

Only the last case is a problem. But is it really a relevant problem? The files are fairly well hidden and it is unlikely for people to touch them accidentally.

@jl-wynen jl-wynen merged commit f4d0008 into main Aug 11, 2025
4 checks passed
@jl-wynen jl-wynen deleted the pooch-registry branch August 11, 2025 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants