holoviz / panel

Panel: The powerful data exploration & web app framework for Python
https://panel.holoviz.org
BSD 3-Clause "New" or "Revised" License
4.63k stars 505 forks source link

Pyodide in docs not working: #7077

Closed MarcSkovMadsen closed 6 days ago

MarcSkovMadsen commented 1 month ago

I just tried to run pyodide in the page https://panel.holoviz.org/tutorials/basic/build_streaming_dashboard.html.

I never loads. And it never tells the user why it does not load.

When inspecting the browser console I see

Error: [Service Worker] Fetching resource https://cdn.holoviz.org/panel/1.4.5/dist/wheels/bokeh-3.4.2-py3-none-any.whl failed with response: 403
    at PyodideServiceWorker.js:51:13

It seems it tries to load https://cdn.holoviz.org/panel/1.4.5/dist/wheels/bokeh-3.4.2-py3-none-any.whl and that this file does not exist.

I also see

pyodide.asm.js:9 
 Uncaught (in promise) 
PythonError: Traceback (most recent call last):
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 82, in _fetch_bytes
    return await fetch_bytes(self.url, fetch_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/_compat_in_pyodide.py", line 30, in fetch_bytes
    result_bytes = await (await pyfetch(url, **kwargs)).bytes()
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python311.zip/pyodide/http.py", line 309, in pyfetch
    raise OSError(e.message) from None
OSError: Failed to fetch

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/lib/python311.zip/_pyodide/_base.py", line 573, in eval_code_async
    await CodeRunner(
  File "/lib/python311.zip/_pyodide/_base.py", line 395, in run_async
    await coroutine
  File "<exec>", line 2, in <module>
  File "/lib/python3.11/site-packages/micropip/_commands/install.py", line 142, in install
    await transaction.gather_requirements(requirements)
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 204, in gather_requirements
    await asyncio.gather(*requirement_promises)
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 217, in add_requirement
    await self.add_wheel(wheel, extras=set(), specifier="")
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 383, in add_wheel
    await wheel.download(self.fetch_kwargs)
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 98, in download
    data = await self._fetch_bytes(fetch_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lib/python3.11/site-packages/micropip/transaction.py", line 90, in _fetch_bytes
    raise ValueError(
ValueError: Can't fetch wheel from 'https://cdn.holoviz.org/panel/1.4.5/dist/wheels/bokeh-3.4.2-py3-none-any.whl'. One common reason for this is when the server blocks Cross-Origin Resource Sharing (CORS). Check if the server is sending the correct 'Access-Control-Allow-Origin' header.

    at new_error (pyodide.asm.js:9:10014)
    at pyodide.asm.wasm:0x158e62
    at pyodide.asm.wasm:0x15ff9e
    at _PyEM_TrampolineCall_JS (pyodide.asm.js:9:120223)
    at pyodide.asm.wasm:0x1a3494
    at pyodide.asm.wasm:0x28a2bd
    at pyodide.asm.wasm:0x1e431e
    at pyodide.asm.wasm:0x1a397d
    at pyodide.asm.wasm:0x1a3c3e
    at pyodide.asm.wasm:0x1a3ce0
    at pyodide.asm.wasm:0x2689a4
    at pyodide.asm.wasm:0x26e800
    at pyodide.asm.wasm:0x1a3e08
    at pyodide.asm.wasm:0x1a3a98
    at pyodide.asm.wasm:0x15f76b
    at Module.callPyObjectKwargs (pyodide.asm.js:9:64297)
    at Module.callPyObject (pyodide.asm.js:9:65365)
    at wrapper (pyodide.asm.js:9:32855)
philippjfr commented 1 month ago

Hmm, not sure why it's still using those longer URLs. Just copied the bokeh wheel into that location (you may have to clear your cache once) but in future it should always load these from https://cdn.holoviz.org/panel/wheels/.

MarcSkovMadsen commented 1 month ago

I did a hard refresh. Now there is another issue when clicking the pyodide run button.

image

MarcSkovMadsen commented 1 month ago

I tried this site https://panel.holoviz.org/tutorials/basic/build_animation.html

There I get

Access to fetch at 'https://assets.holoviz.org/panel/tutorials/turbines.csv.gz' from origin 'https://panel.holoviz.org' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
philippjfr commented 1 month ago

Can't reproduce.

philippjfr commented 1 month ago

Oops, yes, I can.

philippjfr commented 1 month ago

Not sure why it's loading data from there in the first place, all datasets should come from https://datasets.holoviz.org

philippjfr commented 6 days ago

Fixed, though there's some funkiness with the button(s) that I just resolved.