1

I want to perform ML in the browser with "autosklearn" via Pyodide. I think Im supposed to load micropip and then use that to load autosklearn from PyPI. But Im getting a CORS error and not sure how Im supposed to go about this. Pyodide and PyPI shouldn't have any CORS restrictions right?

Heres how Im loading the initial packages

pyodide = await loadPyodide({
    indexURL: 'https://cdn.jsdelivr.net/pyodide/v0.18.1/full/',
  });
await pyodide.loadPackage(['scikit-learn', 'micropip']);

Heres the browser code

pyodide.runPython(
    `
      import micropip
      micropip.install('autosklearn')
      import autosklearn.classification
    `,
  );

And here is my error. Notice the CORS error enter image description here

Leon
  • 5,701
  • 3
  • 38
  • 38

1 Answers1

2

Autosklearn is not compatible with Pyodide. That package requires modules, such as requests, which cannot run in a browser due to browser sandbox security restrictions.

The CORS error in your screenshot is caused by a page not found (404) error.

There is no easy solution for importing auto-sklearn. That package would need to be modified to not use features that do not exist in a browser such as sockets.

John Hanley
  • 74,467
  • 6
  • 95
  • 159
  • Thank you, John. How come autosklearn works in Jupyter though? Wouldnt it need to behave the exact same way e.g. requesting the autosklearn package over the internet? – Leon May 27 '22 at 14:10
  • @Leon - Jupyter does not run in the browser. Only an interface runs in the browser. The work is done by a service (web server) that the browser connects to. – John Hanley May 27 '22 at 19:24
  • You can use typical Jupyter modules through MyBinder.org in your browser. Those have normal Python-backed kernels and run on temporary remote computers. Not in web assembly on your computer. For using some packages, you may need to use a configuration file to make sure it is installed via conda/mamba or pip in the image used to launch. A lot you can install after the sessions is already running. Pyodide,pyscript., and JupyterLite are all very experimental and developing fast. – Wayne May 28 '22 at 19:45