Skip to content

Commit

Permalink
♻️ Make ipylab an optional dependency (#282)
Browse files Browse the repository at this point in the history
* ♻️ Make ipylab an optional dependency

* 💚 Fix tests
  • Loading branch information
falexwolf authored May 6, 2024
1 parent 98974e1 commit 8b8afd5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 17 deletions.
10 changes: 0 additions & 10 deletions nbproject/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@
"""
__version__ = "0.10.1"

# init jupyter lab frontend immediately on import
# nothing happens if this is not jupyter lab
from .dev._jupyter_lab_commands import _init_frontend

# trying to init ipylab JupyterFrontEnd can lead to errors on jupyter notebook
try:
_init_frontend()
except: # noqa: E722
pass

from . import dev
from ._header import header
from ._meta import meta
Expand Down
4 changes: 0 additions & 4 deletions nbproject/_header.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ def header(
# We assume Jupyter Lab as an environment for now
if env is None:
env = "lab"
# this logs "jupyter lab" in vscode and hence, is confusing
# logger.info("Assuming editor is Jupyter Lab.")

try:
nb = read_notebook(filepath) # type: ignore
Expand All @@ -117,8 +115,6 @@ def header(

# initialize
if "nbproject" not in nb.metadata:
logger.info("Attaching notebook metadata")

if env in ("lab", "notebook"):
_save_notebook(env)
nb = read_notebook(filepath) # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions nbproject/dev/_jupyter_lab_commands.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from pathlib import Path
from time import sleep

from ipylab import JupyterFrontEnd

from nbproject._is_run_from_ipython import is_run_from_ipython

app = None


def _init_frontend():
from ipylab import JupyterFrontEnd

global app
if app is None and is_run_from_ipython:
app = JupyterFrontEnd()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ dependencies = [
"pyyaml",
"packaging",
"orjson",
"ipylab",
"importlib-metadata",
"stdlib_list; python_version < '3.10'",
"lamin_utils>=0.5.0",
Expand All @@ -38,6 +37,7 @@ dev = [
"nbformat",
"nbproject_test >= 0.4.5",
"laminci",
"ipylab",
]

[project.scripts]
Expand Down

0 comments on commit 8b8afd5

Please sign in to comment.