diff --git a/pyproject.toml b/pyproject.toml index fb429e1..f411f1a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -40,6 +40,9 @@ tauri = [ vue2 = [ "trame-grid-layout>=1.0.3", ] +jupyter = [ + "jupyter-server-proxy>=4.0.0", +] [build-system] @@ -53,6 +56,7 @@ include = [ "/src/e3sm_quickview/data/**", "/src/e3sm_quickview/assets/**", "/src/e3sm_quickview/module/**", + "/src/e3sm_quickview/jupyter/**", ] [tool.hatch.build.targets.wheel] @@ -64,6 +68,9 @@ packages = [ quickview-vue2 = "e3sm_quickview.app:main" quickview = "e3sm_quickview.app:main" +[project.entry-points."jupyter_serverproxy_servers"] +quickview = "e3sm_quickview.jupyter:setup_quickview" + [tool.ruff.lint.per-file-ignores] # Ignore star import issues in ParaView plugins "e3sm_quickview/plugins/*.py" = ["F403", "F405"] diff --git a/src/e3sm_quickview/jupyter/__init__.py b/src/e3sm_quickview/jupyter/__init__.py new file mode 100644 index 0000000..bf8e760 --- /dev/null +++ b/src/e3sm_quickview/jupyter/__init__.py @@ -0,0 +1,5 @@ +"""Jupyter integration for QuickView via jupyter-server-proxy.""" + +from .proxy import setup_quickview + +__all__ = ["setup_quickview"] diff --git a/src/e3sm_quickview/jupyter/icons/quickview.png b/src/e3sm_quickview/jupyter/icons/quickview.png new file mode 100644 index 0000000..ba8f15c Binary files /dev/null and b/src/e3sm_quickview/jupyter/icons/quickview.png differ diff --git a/src/e3sm_quickview/jupyter/proxy.py b/src/e3sm_quickview/jupyter/proxy.py new file mode 100644 index 0000000..3a41fbc --- /dev/null +++ b/src/e3sm_quickview/jupyter/proxy.py @@ -0,0 +1,35 @@ +"""Server proxy configuration for QuickView in JupyterLab.""" + +import os + + +def setup_quickview(): + """Configure jupyter-server-proxy for QuickView. + + Returns a dictionary with the server process configuration that + jupyter-server-proxy uses to launch and proxy QuickView. + """ + icon_path = os.path.join( + os.path.dirname(os.path.abspath(__file__)), + "icons", + "quickview.png", + ) + + return { + "command": [ + "quickview", + "--server", + "--port", + "{port}", + "--host", + "127.0.0.1", + ], + "timeout": 30, + "launcher_entry": { + "enabled": True, + "title": "QuickView", + "icon_path": icon_path, + "category": "Other", + }, + "new_browser_tab": False, + }