@@ -5,7 +5,7 @@ declare global {
5
5
interface Window {
6
6
pyodide : PyodideInterface ;
7
7
scenario_json : string ;
8
- BASE_URL : string ;
8
+ model_identifier : string ;
9
9
}
10
10
}
11
11
@@ -23,7 +23,7 @@ async function loadPyodideAndPackages(pathname: string) {
23
23
self . onmessage = async ( event ) => {
24
24
// The data passed in from the main thread must contain these fields.
25
25
// TODO: Type this properly
26
- const { id, python, pathname, scenario_json, BASE_URL } = event . data ;
26
+ const { id, python, pathname, scenario_json, model_identifier } = event . data ;
27
27
28
28
// Load packages
29
29
try {
@@ -38,11 +38,8 @@ self.onmessage = async (event) => {
38
38
// So, on the TypeScript side (pyodide.ts) we can do `from js import
39
39
// scenario_json`.
40
40
self . scenario_json = scenario_json ;
41
- // The BASE_URL is more tricky because it must be accessed from the Python
42
- // package itself. We need to set this as a global variable here, which lets
43
- // us do `import pyodide_js; pyodide_js.globals.get("BASE_URL")` (in the
44
- // `cache.py` file).
45
- let model_identifier = BASE_URL . split ( "/" ) . slice ( - 2 , - 1 ) [ 0 ] ;
41
+ // model_identifier sets the DEMOLAND environment variable in the Python
42
+ // code. That's how we can access the model identifier in the Python code.
46
43
self . pyodide . globals . set ( "DEMOLAND" , model_identifier ) ;
47
44
48
45
try {
0 commit comments