feat: Create Individual Virtual Env for the Kernel#74
Conversation
…al env TODO: file up- and download does not work yet due to the 'workspace' dir not being mapped correctly
…g as we do not implement multi-user-support. For this, things are prepared, though.
We first create a base venv that is not to be deleted and can be re-used easily. There we install all default packages. Then, we create another, kernel-specific, venv without any additional packages. Instead, we create a link that points to the packages installed in the base image. The base image is intended to stay immutable. All newly installed packages end up in the kernel-specific venv. While they are lost on restart, the packages inside the base image are not.
…) from rdkit as well (should work for all PIL.Image content, I think)
|
Hi @ricklamers, answering here to you comment in #73:
Actually, the approach with the |
This is a follow/up of #73. I originally planned to re-open that one, but this seems impossible. The change addresses #6 and #62 - at least partially.
The idea is as follows:
We first create a base venv that is not to be deleted and can be re-used easily. There we install all default packages. (Thus, the very first start after applying the change is still slow).
Then, whenever a kernel is invoked, we create another, kernel-specific, venv without any additional packages. Instead, we create a link that points to the packages installed in the base image by installing a .pth file inside its site_packages dir. This way, the derived venv has access to all packages that have been installed in the base image. The Python binary from the derived venv is used to finally start the IPython kernel. The base image is intended to stay immutable and will not be actively used. If an additional package is needed, the corresponding !pip install PACKAGE call can be executed and packages do neither pollute the system environment nor the base venv. All newly installed packages end upon the kernel-specific venv. While they are lost on exit/restart (we delete the derived venv when the kernel exists), the packages inside the base image are not.
The overall idea is coming from https://stackoverflow.com/a/75545634.
An example prompt for this is
I think (!), this could be a good baseline for addressing #67 as well. - At least, running kernels with separate environments are possible this way.