Open bollwyvl opened 1 year ago
As
jedi
is part of the pyodide standard distribution it may be rather hacky to work around it getting installed, due to issues like jupyterlite/jupyterlite#904, but may be worth it for doign 10% less work for... nothing.
I saw a comment like this in jupyterlite/jupyterlite#911 as well, but unless I'm misunderstanding how pyolite
and pyodide
interact, I don't think a package being part of the 'pyodide standard distribution' means that it gets installed automatically. The only reason things like import matplotlib
or import jedi
work in the pyodide
online console is that, similarly to jupyterlite, it parses the imports and automatically installs standard packages that are being imported:
it parses the imports and automatically installs standard packages that are being imported:
Right, iirc even code like the following would trigger the install?
if False:
import matplotlib
Right: unless it's made optional upstream in IPython
(unlikely), the approach we'd need today:
import jedi
in IPython
fetch
hack wouldn't workThis would theoretically be something we could hoist up to lite plugin settings, e.g.
"jupyter-config-data": {
"litePluginSettings": {
"@jupyterlite/pyolite-kernel-extension:kernel": {
"disablePyPIFallback": true,
"repodata": {
"jedi": null
}
}
}
}
this would then allow piplite
to answer the response for a pre-packaged wheel.
Right, iirc even code like the following would trigger the install?
if False: import matplotlib
Yes, I think it purely, statically looks forimport
statements and imports everything it finds that's in the standard distribution:
patch pyodide's knowledge of its packages really early
- as this is inside the worker, our
fetch
hack wouldn't work
I think the only reason you install pyodide
's version is because you run code through loadPackagesFromImports
before running it, no? So you could just remove any package you don't want to install from pyodide
from the list to import, like I did here to fix jupyterlite/jupyterlite#904:
https://github.com/jobovy/jupyterlite/compare/quiet-prerun...quiet-prerun-purge-galpy
Right, but 99% of the time, the user wants that feature.
Right, but 99% of the time, the user wants that feature.
Yes, that's why I just remove galpy
from the list in my case and still automatically install everything else. Here you could similarly remove jedi
from the list of packages to ever install from pyodide
and install your shim instead?
Right, except this is for the kernel itself, so there are some timing issues. We further allow folk to use a custom pyodide, and don't/won't ship all 200mb.
Typically if we do some hack like this, we try to make it useful for downstreams as well (this is why we have piplite
in the first place, to decouple the names of packages from the typescript code... almost)
While I was thinking this over:
repodata.json
has a critical advantage vs its conda
namesake and the Warehouse JSON API, namely that it includes the imports
supported by the distribution (e.g. pillow
provides PIL
)pkginfo
to generate one JSON file repodata.json
, and (basically) extract the names inside the packagespip installed
, they would get picked up by the auto-import mechanism, without sacrificing debuggability when things failThis wouldn't change the public API at all, and notebooks would still have to import whatever
, but is probably enough of a carrot to look into how we might solve both the jedi
patch, while encouraging site owners to provide well-known versions of the wheels their content will use.
Problem
pyodide_kernel
requires many packages to be fully downloaded (if not already cached) and installed before giving the user the ability to do interactive computing.Proposed Solution
Investigate additional packages which could be avoided, either by shim or patch.
Additional context
With jupyterlite/jupyterlite#913, we'd be down to 724 modules.
A standout are the 97
jedi
andparso
packages: at present,jedi
integration is turned off, presumably as it is so slow as to appear broken. At any rate, we're still paying 1.7mb on the wire to download these two packages.As
jedi
is part of the pyodide standard distribution it may be rather hacky to work around it getting installed, due to issues like jupyterlite/jupyterlite#904, but may be worth it for doign 10% less work for... nothing.