enh: code execution settings

This commit is contained in:
Timothy Jaeryang Baek
2025-02-17 16:25:50 -08:00
parent 3df6fa7ccb
commit 2f75eef499
15 changed files with 478 additions and 213 deletions

View File

@@ -20,6 +20,9 @@
import PyodideWorker from '$lib/workers/pyodide.worker?worker';
import CodeEditor from '$lib/components/common/CodeEditor.svelte';
import SvgPanZoom from '$lib/components/common/SVGPanZoom.svelte';
import { config } from '$lib/stores';
import { executeCode } from '$lib/apis/utils';
import { toast } from 'svelte-sonner';
const i18n = getContext('i18n');
const dispatch = createEventDispatcher();
@@ -120,7 +123,20 @@
};
const executePython = async (code) => {
executePythonAsWorker(code);
if ($config?.code?.engine === 'jupyter') {
const output = await executeCode(localStorage.token, code).catch((error) => {
toast.error(`${error}`);
return null;
});
if (output) {
stdout = output.stdout;
stderr = output.stderr;
result = output.result;
}
} else {
executePythonAsWorker(code);
}
};
const executePythonAsWorker = async (code) => {