Skip to content

ENH: Consolidate JUPYTERLAB and JUPYTER_NOTEBOOK Env's into JUPYTER #748

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/integrations/dask/DaskArray.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"ENVIRONMENT: Env.JUPYTERLAB\n"
"ENVIRONMENT: Env.JUPYTER\n"
]
}
],
Expand Down
31 changes: 17 additions & 14 deletions itkwidgets/integrations/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@


class Env(Enum):
JUPYTER_NOTEBOOK = 'notebook'
JUPYTERLAB = 'lab'
JUPYTER = 'jupyter'
JUPYTERLITE = 'lite'
SAGEMAKER = 'sagemaker'
HYPHA = 'hypha'
Expand All @@ -24,9 +23,7 @@ def find_env():
parent_header = get_ipython().parent_header
username = parent_header['header']['username']
if username == '':
return Env.JUPYTERLAB
elif username == 'username':
return Env.JUPYTER_NOTEBOOK
return Env.JUPYTER
else:
return Env.SAGEMAKER
except:
Expand All @@ -39,15 +36,21 @@ def find_env():

if ENVIRONMENT is not Env.JUPYTERLITE and ENVIRONMENT is not Env.HYPHA:
if ENVIRONMENT is not Env.COLAB:
if ENVIRONMENT is Env.JUPYTER_NOTEBOOK:
notebook_version = importlib_metadata.version('notebook')
if version.parse(notebook_version) < version.parse('7'):
raise RuntimeError('itkwidgets 1.0a51 and newer requires Jupyter notebook>=7.')
elif ENVIRONMENT is Env.JUPYTERLAB:
lab_version = importlib_metadata.version('jupyterlab')
if version.parse(lab_version) < version.parse('4'):
raise RuntimeError('itkwidgets 1.0a51 and newer requires jupyterlab>=4.')

if ENVIRONMENT is Env.JUPYTER:
try:
notebook_version = importlib_metadata.version('notebook')
if version.parse(notebook_version) < version.parse('7'):
raise RuntimeError('itkwidgets 1.0a51 and newer requires Jupyter notebook>=7.')
except importlib_metadata.PackageNotFoundError:
# notebook may not be available
pass
try:
lab_version = importlib_metadata.version('jupyterlab')
if version.parse(lab_version) < version.parse('4'):
raise RuntimeError('itkwidgets 1.0a51 and newer requires jupyterlab>=4.')
except importlib_metadata.PackageNotFoundError:
# jupyterlab may not be available
pass
try:
import_module("imjoy-jupyterlab-extension")
except ModuleNotFoundError:
Expand Down