Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

cache:use temp dir by default

Yusupc476bf75802d
diff --git a/dsp/modules/cache_utils.py b/dsp/modules/cache_utils.py
index a7e2bde2f..558d60104 100644
--- a/dsp/modules/cache_utils.py
+++ b/dsp/modules/cache_utils.py
@@ -1,6 +1,6 @@
import os
from functools import wraps
-from pathlib import Path
+from tempfile import mkdtemp
from joblib import Memory
@@ -23,7 +23,7 @@ def noop_decorator(arg=None, *noop_args, **noop_kwargs):
return decorator
-cachedir = os.environ.get('DSP_CACHEDIR') or os.path.join(Path.home(), 'cachedir_joblib')
+cachedir = os.environ.get('DSP_CACHEDIR') or mkdtemp()
CacheMemory = Memory(location=cachedir, verbose=0)
cachedir2 = os.environ.get('DSP_NOTEBOOK_CACHEDIR')
@@ -33,7 +33,6 @@ NotebookCacheMemory.cache = noop_decorator
if cachedir2:
NotebookCacheMemory = Memory(location=cachedir2, verbose=0)
-
if not cache_turn_on:
CacheMemory = dotdict()
CacheMemory.cache = noop_decorator