-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Description
What happened?
Os: windows 11,
dspy Version: 3.0.4
Deno:
deno 2.5.6 (stable, release, x86_64-pc-windows-msvc)
v8 14.0.365.5-rusty
typescript 5.9.2
In the deno script runner.js, when creating a file path with mkdir, existing directory are handled using an error catch like this:
} catch (e) {
if (!(e && e.message && e.message.includes('File exists'))) {
console.log("[DEBUG] Error creating directory in Pyodide file system:", cur, "|", e.message);
}
}
where the script assumes that the error message would contain 'File exists', which is not the case for my version of deno (message is empty for this error).
A more robust approach would be to just test if the directory exists using a function like this:
function directoryExists(path) {
try {
const entry = pyodide.FS.analyzePath(path);
return entry.exists; // True if it's a directory
} catch (e) {
console.log("Error checking directory existence in Pyodide:", e);
return false; // If an error occurs (e.g., path doesn't exist), return false
}
}
I have attached the full updated script that works in my case.
Steps to reproduce
When using the code interpreter with file loading:
ex:
dspy.PythonInterpreter({}, enable_read_paths=files_path).execute(expression)
files_path could be any file path and expression can be any expression.
The problem is on
Os: windows 11,
Deno:
deno 2.5.6 (stable, release, x86_64-pc-windows-msvc)
v8 14.0.365.5-rusty
typescript 5.9.2
DSPy version
3.0.4