Open jprafael opened 11 months ago
It was because the NoOpEviction
class was being imported from the distributed_cahe
module which has the implementation for RedisEviction
as well
I have created a PR where the RedisEviction is put into a separate module to avoid that import.
Hi @a9raag!
I landed here searching for a solution to this problem, so I guess it's still not solved. :disappointed:
I have not much context about this project, but checking the code I'd say that the problem is in this line, where we are importing the RedisCacheStorage
class, but also loads the module and try to install redis.
As the class is only loaded to check a condition, would it be possible to change that condition to avoid importing the class at the very top level? I don't know if it's possible to find another way to decide if the condition is true, or check first if eviction_manager == "redis"
and only then doing the import of the class to check the other part in the condition.
Thanks!
@a9raag I've created this PR trying to solve the issue. As scalar
is the name given to the CacheBase
class to decide which class it should instance, I think checking it would be equivalent, but without loading classes. But I was not able to test it, what do you think? Could it work?
@a9raag any chance to merge @leio10's pr to fix this issue?
@marioluan i have merged it to dev branch
Thanks @SimFG!! :heart: In order to completely fix the issue we need this change to be released. Are you planning to release a new version soon? :grimacing:
Current Behavior
Importing gptcache fails in environments where redis is not installed (because its not declared as a required dependency) and it can't be installed (e.g. read only filesystem such as AWS lambda).
Expected Behavior
gptcache shouldn't attempt to install packages on the user's behalf. mandatory packages should be declared in requirements.txt/setup.py and optional features should be enabled only when said packages are available, raising an error at runtime if that functionality is attempted without the required packages
Steps To Reproduce
Environment
Anything else?
No response