pyodide WASM integration
Pyodide 0.27.0 runs the parser/ package in the browser. See Python processing pipeline and Schedule generation.
Pieces#
| Piece | Location | Job |
|---|---|---|
| Init + bridge | website/utils/pyodide.ts |
Load runtime, install wheel, call functions |
| Wheel | website/public/parser/jiit_timetable_parser-0.1.0-py3-none-any.whl |
create_time_table, compare APIs |
| Status hook | usePyodideStatus |
loading / loaded / error |
Module-level flags keep a single instance:
pyodideInstance, pyodideLoading, pyodideLoaded, pyodideError, listeners
Init#
flowchart TD
A{already loaded?} -->|yes| Ret[return instance]
A -->|loading| Wait[poll until done]
A -->|no| LoadJS[inject pyodide.js from jsDelivr]
LoadJS --> LoadWASM["loadPyodide indexURL v0.27.0/full, fullStdLib false"]
LoadWASM --> Micropip[loadPackage micropip]
Micropip --> Wheel["install origin + /parser/jiit_timetable_parser-0.1.0-py3-none-any.whl"]
Wheel --> Imp["from main import create_time_table, compare_timetables, create_and_compare_timetable"]
Imp --> Done[pyodideLoaded = true]CDN: https://cdn.jsdelivr.net/pyodide/v0.27.0/full/. Workbox CacheFirst stores it for a year in production.
The old path fetched /_creator.py and called named functions from JS. That file and website/public/modules/BE62_creator.py / BE128_creator.py still exist in public/ (the SW precaches them) but initializePyodide no longer executes them.
Campus dispatch (Python)#
flowchart LR
JS[callTimeTableCreator] --> CT[create_time_table]
CT --> R{campus, year}| Campus | Year 1 | Year 2+ |
|---|---|---|
| 62 | time_table_creator |
time_table_creator_v2 |
| 128 | bando_year1 |
banado |
| BCA | creator_year1 |
creator |
JS does not pick the function name anymore.
Call path#
sequenceDiagram participant H as HomeContent participant B as callTimeTableCreator participant P as Pyodide H->>B: campus, year, json, batch, electives B->>P: globals.get create_time_table B->>P: toPy each arg P-->>B: result.toJs() B-->>H: YourTietable
Exports:
callTimeTableCreator(campus, year, args)callCompareTimetables(tt1, tt2)used by the compare pagecallCompareAndCreate(params_list)wrapscreate_and_compare_timetablecallPythonFunction(name, args)deprecated
Status#
flowchart LR Init[initializePyodide] --> N[notifyListeners] N --> Hook[usePyodideStatus] Hook --> UI[HomeContent waits if needed]
HomeContent calls initializePyodide() on mount. Submit waits if loaded is still false.
Wheel layout#
parser/
├── main.py
├── models/ ClassInfo, Subject, enums
├── utils/ batch, subject, location, time
└── modules/
├── tt_parsers/ sector_62, sector_128, BCA
└── compare_tt/ compare_timetables
Rebuild with uv run python -m build --wheel in parser/ and copy the wheel into website/public/parser/.