laminlabs / nbproject

Light-weight Jupyter notebook tracker.
https://lamin.ai/docs/nbproject
Apache License 2.0
34 stars 0 forks source link

Custom kernel venv - cannot find notebook/server #248

Open jggatter opened 1 year ago

jggatter commented 1 year ago

Hi,

I'm looking to report a potential bug I encountered when using a custom ipython kernel that uses a venv python3.10.8 installation.

Problem

A month ago I installed nbproject to use header() in a notebook (https://github.com/laminlabs/lndb-benchmarks/pull/16). Within the Jupyter NotebookApp, I was unable to get header to print, instead receiving the following error:

🔶 It looks like you are running jupyter lab but don't have jupyter-server module installed.Please install it via pip install jupyter-server
🔶 Can not find any servers running.
ℹ️ Can't infer the name of the current notebook, you are probably not inside a Jupyter notebook. Please call `header(filepath='your-file.ipynb')`.

The kernel I was using was a custom one I installed that sources from my venv Python installation, not a conda env. I have reproduced the error on both macOS and Fedora.

Now a month later, I have reproduced it in VSCode on Fedora: vscode-nbproject Note the error message here (and now when rerunning in the original notebook) is a bit different:

🔶 Can not find the notebook in any server session.
ℹ️ Can't infer the name of the current notebook, you are probably not inside a Jupyter notebook. Please call `header(filepath='your-file.ipynb')`.

I am not sure if the problem is due to me using a custom kernel or venv.

Steps to reproduce

# Install python 3.10.8

python3 -m venv venv-lamindb
source venv-lamindb/bin/activate

git clone https://github.com/laminlabs/lamindb
cd lamindb/
python3 -m pip install -e .

git clone https://github.com/laminlabs/lndb-benchmarks.git
git checkout primary-keys
git pull

python3 -m pip install jupyter
ipython-kernel install --name "lamindb" --user
jupyter notebook  # Or use VSCode JupyterNotebook extension

Then:

  1. Create new notebook
  2. "Kernel" -> "Change kernel" -> "lamindb"
  3. Restart kernel
  4. Confirm python is sourced from venv: !which python
  5. from nbproject import header; header() Uninstall kernel using jupyter kernelspec uninstall lamindb

A solution is not priority for me as there is of course the workaround of using the filepath kwarg. Of course for easy reproducibility on other machines, a solution without filepath would be greatly appreciated. Please let me know if I can provide any further information!

Thank you, James

Koncopd commented 1 year ago

Thank you for reporting the problem, i will check.