Skip to content

Commit

Permalink
Merge pull request #244 from flatironinstitute/improve-pyodide-errors
Browse files Browse the repository at this point in the history
Improve errors from pyodide by using filename
  • Loading branch information
WardBrian authored Nov 5, 2024
2 parents 03430c8 + aff1622 commit a8f439c
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 a8f439c

Please sign in to comment.