Cbphcr commited on
Commit
c2a70ef
·
verified ·
1 Parent(s): d6552eb

Adapt Pyodide os.link signature

Browse files
Files changed (1) hide show
  1. gradio-lite-worker.js +2 -2
gradio-lite-worker.js CHANGED
@@ -312,11 +312,11 @@ def unload_local_modules(target_dir_path: str = "."):
312
  for module_name in loaded_modules.values():
313
  if module_name is not None and module_name in sys.modules:
314
  del sys.modules[module_name]
315
- `;importScripts("https://cdn.jsdelivr.net/pyodide/v0.26.1/full/pyodide.js");let p,_,O,N,R,A;async function W(e,t){console.debug("Loading Pyodide."),t("Loading Pyodide"),p=await loadPyodide({stdout:console.debug,stderr:console.error}),console.debug("Pyodide is loaded."),console.debug("Loading micropip"),t("Loading micropip"),await p.loadPackage("micropip"),_=p.pyimport("micropip"),console.debug("micropip is loaded.");const o=[e.gradioWheelUrl,e.gradioClientWheelUrl];console.debug("Loading Gradio wheels.",o),t("Loading Gradio wheels"),await p.loadPackage(["ssl","setuptools"]),await _.add_mock_package("ffmpy","0.3.0"),await _.install.callKwargs(["huggingface-hub==0.25.2","filelock==3.16.1","typing-extensions>=4.8.0","markdown-it-py[linkify]~=2.2.0","anyio==3.*","fastapi<0.111.0",...o],{keep_going:!0}),console.debug("Gradio wheels are loaded."),console.debug("Mocking os module methods."),t("Mock os module methods"),await p.runPythonAsync(`
316
  import os
317
 
318
  os.link = lambda src, dst: None
319
- `),console.debug("os module methods are mocked."),console.debug("Importing gradio package."),t("Importing gradio package"),await p.runPythonAsync("import gradio"),console.debug("gradio package is imported."),console.debug("Defining a ASGI wrapper function."),t("Defining a ASGI wrapper function"),await p.runPythonAsync(`
320
  # Based on Shiny's App.call_pyodide().
321
  # https://github.com/rstudio/py-shiny/blob/v0.3.3/shiny/_app.py#L224-L258
322
  async def _call_asgi_app_from_js(app_id, scope, receive, send):
 
312
  for module_name in loaded_modules.values():
313
  if module_name is not None and module_name in sys.modules:
314
  del sys.modules[module_name]
315
+ `;importScripts("https://cdn.jsdelivr.net/pyodide/v0.26.1/full/pyodide.js");let p,_,O,N,R,A;async function W(e,t){console.debug("Loading Pyodide."),t("Loading Pyodide"),p=await loadPyodide({stdout:console.debug,stderr:console.error}),console.debug("Pyodide is loaded."),console.debug("Loading micropip"),t("Loading micropip"),await p.loadPackage("micropip"),_=p.pyimport("micropip"),console.debug("micropip is loaded.");const o=[e.gradioWheelUrl,e.gradioClientWheelUrl];console.debug("Loading Gradio wheels.",o),t("Loading Gradio wheels"),await p.loadPackage(["ssl","setuptools"]),await _.add_mock_package("ffmpy","0.3.0"),await _.install.callKwargs(["typing-extensions>=4.8.0","markdown-it-py[linkify]~=2.2.0","anyio==3.*","fastapi<0.111.0"],{keep_going:!0}),await _.install.callKwargs(o,{keep_going:!0}),console.debug("Gradio wheels are loaded."),console.debug("Mocking os module methods."),t("Mock os module methods"),await p.runPythonAsync(`
316
  import os
317
 
318
  os.link = lambda src, dst: None
319
+ `),console.debug("os module methods are mocked."),console.debug("Importing gradio package."),t("Importing gradio package"),await p.runPythonAsync("import os\n_pyodide_os_link = os.link\nos.link = lambda source, dest, *args, **kwargs: _pyodide_os_link(source, dest)"),await p.runPythonAsync("import gradio"),console.debug("gradio package is imported."),console.debug("Defining a ASGI wrapper function."),t("Defining a ASGI wrapper function"),await p.runPythonAsync(`
320
  # Based on Shiny's App.call_pyodide().
321
  # https://github.com/rstudio/py-shiny/blob/v0.3.3/shiny/_app.py#L224-L258
322
  async def _call_asgi_app_from_js(app_id, scope, receive, send):