Skip to content

Commit

Permalink
Improve errors from pyodide by using filename
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Nov 5, 2024
1 parent 03430c8 commit aff1622
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions gui/src/app/Scripting/Analysis/AnalysisPyWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const AnalysisPyWindow: FunctionComponent<AnalysisWindowProps> = ({
loadsDraws: true,
showsPlots: true,
producesData: false,
filenameForErrors: FileNames.ANALYSISPYFILE,
},
files,
});
Expand Down
1 change: 1 addition & 0 deletions gui/src/app/Scripting/DataGeneration/DataPyWindow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const DataPyWindow: FunctionComponent<Props> = () => {
loadsDraws: false,
showsPlots: false,
producesData: true,
filenameForErrors: FileNames.DATAPYFILE,
},
});
},
Expand Down
5 changes: 4 additions & 1 deletion gui/src/app/Scripting/pyodide/pyodideWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ const run = async (
}

setStatus("running");
pyodide.runPython(script, { globals });
await pyodide.runPythonAsync(script, {
globals,
filename: spPySettings.filenameForErrors,
});
succeeded = true;
} catch (e: any) {
console.error(e);
Expand Down
1 change: 1 addition & 0 deletions gui/src/app/Scripting/pyodide/pyodideWorkerTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export type PyodideRunSettings = Partial<{
loadsDraws: boolean;
showsPlots: boolean;
producesData: boolean;
filenameForErrors: string;
}>;

export type MessageToPyodideWorker = {
Expand Down

0 comments on commit aff1622

Please sign in to comment.