dspy icon indicating copy to clipboard operation
dspy copied to clipboard

fix(dsp): prevent cache instantiation when cache is disabled

Open stevenhoelscher opened this issue 2 years ago • 1 comments

The environment variable DSP_CACHEBOOL does not completely disable the filesystem cache.

As a result, joblib.Memory is still instantiated, which will try to create a directory on the filesystem.

In an environment where a user does not have write access to the DSP_CACHEDIR, this will throw a surprising exception despite DSP_CACHEBOOL being set to false.

File "/var/lang/lib/python3.11/site-packages/dsp/modules/cache_utils.py", line 27, in <module>
    CacheMemory = Memory(location=cachedir, verbose=0)
  File "/var/lang/lib/python3.11/site-packages/joblib/memory.py", line 1020, in __init__
    self.store_backend = _store_backend_factory(
  File "/var/lang/lib/python3.11/site-packages/joblib/memory.py", line 132, in _store_backend_factory
    obj.configure(location, verbose=verbose,
  File "/var/lang/lib/python3.11/site-packages/joblib/_store_backends.py", line 452, in configure
    mkdirp(self.location)
  File "/var/lang/lib/python3.11/site-packages/joblib/disk.py", line 61, in mkdirp
    os.makedirs(d)

stevenhoelscher avatar Apr 16 '24 16:04 stevenhoelscher

Thanks @stevenhoelscher for the PR! This looks good and maintains the cache correctly. Is the PR ready to merge or pending the change you've mentioned here?

arnavsinghvi11 avatar May 06 '24 01:05 arnavsinghvi11