Closed michaelweinold closed 2 months ago
(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)
panel==1.4.2 pyodide==0.26.2 bw2data==4.0.dev51 bw2io==0.9.dev34 bw2calc==2.0.dev20
A life-cycle assessment calculation with our Brightway package, which works fine in Pyodide, simply throws an error in a Panel Pyodide site.
This runs fine on eg. jupyterlite.readthedocs.org:
import micropip await micropip.install('bw2data==4.0.dev51', keep_going = True) await micropip.install('bw2io==0.9.dev34', keep_going = True) await micropip.install('bw2calc==2.0.dev20', keep_going = True) os.environ["BRIGHTWAY_DIR"] = "/tmp/" def load_useeio_database(): try: bd.projects.delete_project('USEEIO-1.1', delete_dir=True) except: pass bi.install_project(project_key="USEEIO-1.1", overwrite_existing=True) bd.projects.set_current("USEEIO-1.1") def perform_lca(): useeio = bd.Database('USEEIO-1.1') list_prod = [node for node in useeio if 'product' in node['type']] some_prod = list_prod[42] lca = bc.LCA( demand={some_prod: 100}, method = bd.methods.random() ) lca.lci() lca.lcia() return lca.score load_useeio_database() perform_lca()
While this Panel app:
# %% import panel as pn import os import bw2io as bi import bw2calc as bc import bw2data as bd os.environ["BRIGHTWAY_DIR"] = "/tmp/" def load_useeio_database(event): try: bd.projects.delete_project('USEEIO-1.1', delete_dir=True) except: pass bi.install_project(project_key="USEEIO-1.1", overwrite_existing=True) bd.projects.set_current("USEEIO-1.1") def perform_lca(event): useeio = bd.Database('USEEIO-1.1') list_prod = [node for node in useeio if 'product' in node['type']] some_prod = list_prod[42] lca = bc.LCA( demand={some_prod: 100}, method = bd.methods.random() ) lca.lci() lca.lcia() number_lca_score.value = lca.score button_load = pn.widgets.Button(name='Load USEEIO') button_load.on_click(load_useeio_database) button_lca = pn.widgets.Button(name='Perform LCA') button_lca.on_click(perform_lca) number_lca_score = pn.indicators.Number(name='LCA Score', value=0) pn.Column(button_load, button_lca, number_lca_score).servable()
Causes the below error when converted to Pyodide with
panel convert app.py --to pyodide-worker --out test --requirements requirements.txt
Proof of the calculations working fine on a JupyterLite Pyodide kernel:
...potentially related:
I believe the data clone error is fixed on main, I'll tag a Panel 1.5.0 RC1 release later today you can try.
ALL software version info
(this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)
Description of expected behavior and the observed behavior
A life-cycle assessment calculation with our Brightway package, which works fine in Pyodide, simply throws an error in a Panel Pyodide site.
Complete, minimal, self-contained example code that reproduces the issue
This runs fine on eg. jupyterlite.readthedocs.org:
While this Panel app:
Causes the below error when converted to Pyodide with
Stack traceback and/or browser JavaScript console output
JavaScript console output
```pyodide.asm.js:10 Uncaught (in promise) PythonError: Traceback (most recent call last): File "/lib/python312.zip/_pyodide/_base.py", line 596, in eval_code_async await CodeRunner( File "/lib/python312.zip/_pyodide/_base.py", line 410, in run_async coroutine = eval(self.code, globals, locals) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "Screenshots or screencasts of the bug in action
Proof of the calculations working fine on a JupyterLite Pyodide kernel: