-
Notifications
You must be signed in to change notification settings - Fork 0
Description
The cachehitrate parameter in RequestedFiles_HitrateBased is currently used as a boolean despite being an integer.
lapis.caching/lapis/caching/files.py
Lines 86 to 98 in 8f4f614
| class RequestedFile_HitrateBased(RequestedFile): | |
| """ | |
| Represents a requested file in hitrate based caching. | |
| The cachehitrate flag is somewhat messed up currently. | |
| **Its use should be reworked when remodeling the connection module.** | |
| """ | |
| __slots__ = "cachehitrate" | |
| def __init__(self, filename: str, filesize: int, cachehitrate: int): | |
| super().__init__(filename, filesize) | |
| """flag whether the file is cached, 1 if it is cached, 0 if it is not cached""" | |
| self.cachehitrate = cachehitrate |
Since the meaning of a rate implies a percentage, this either needs a renaming or checking if the application of cachehitrate in terms of a rate does not change expectation, e.g. in the HitrateStorage and FileBasedHitrateStorage implementation.
Here the cachehitrate is used in two different ways,
- as a boolean in the
transfermethod forFileBasedHitrateStorage
lapis.caching/lapis/caching/storageelement.py
Lines 361 to 367 in 8f4f614
| if file.cachehitrate: | |
| await self.connection.transfer(total=file.filesize) | |
| await sampling_required.put(self.connection) | |
| else: | |
| print("wants to read from remote") | |
| print("file is not cached but cache is file source, this should not occur") | |
| raise ValueError |
- as a multiplicative factor in the
findmethod forFileBasedHitrateStorage
lapis.caching/lapis/caching/storageelement.py
Line 377 in 8f4f614
| return LookUpInformation(file.filesize * file.cachehitrate, self) |
- as a multiplicative factor in
transferforHitrateStorage(however, this class is out of date already)
lapis.caching/lapis/caching/storageelement.py
Line 285 in 8f4f614
| hitrate_size = self._hitrate * file.filesize |
As the current implementation already ensures correct functioning also with rates, I would propose to actually interpret it as it is named already. This means the following should be done:
- adaptation of docstrings to remove mentioning of interpretation as a flag
- adaptation of typehints
- unit tests to ensure that everything works as expected