Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 10, 2023
1 parent 847bf7f commit 8884d8b
Show file tree
Hide file tree
Showing 30 changed files with 748 additions and 614 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,12 @@ jlpm run watch
jupyter lab
```

With the watch command running, every saved change will immediately be built locally
and available in your running JupyterLab. Refresh JupyterLab to load the change in
With the watch command running, every saved change will immediately be built locally
and available in your running JupyterLab. Refresh JupyterLab to load the change in
your browser (you may need to wait several seconds for the extension to be rebuilt).

By default, the `jlpm run build` command generates the source maps for this
extension to make it easier to debug using the browser dev tools. To also generate
By default, the `jlpm run build` command generates the source maps for this
extension to make it easier to debug using the browser dev tools. To also generate
source maps for the JupyterLab core extensions, you can run the following command:

```bash
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,13 @@ Jupyter Server within a container and only allow network access to the Jupyter
Server via the container.

> For more insights, see [Ryan Lovett's comment about
it](https://github.com/jupyterhub/jupyter-server-proxy/pull/359#issuecomment-1350118197).
> it](https://github.com/jupyterhub/jupyter-server-proxy/pull/359#issuecomment-1350118197).
## Install

### Requirements

* `jupyterlab>=2` or `notebook`
- `jupyterlab>=2` or `notebook`

### Python package

Expand Down
20 changes: 9 additions & 11 deletions contrib/code-server-traitlet/jupyter_notebook_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@


c.ServerProxy.servers = {
'code-server': {
'command': [
'code-server',
'--auth=none',
'--disable-telemetry',
'--bind-addr=localhost:{port}'
],
'timeout': 20,
'launcher_entry': {
'title': 'VS Code'
"code-server": {
"command": [
"code-server",
"--auth=none",
"--disable-telemetry",
"--bind-addr=localhost:{port}",
],
"timeout": 20,
"launcher_entry": {"title": "VS Code"},
}
}
}
6 changes: 3 additions & 3 deletions contrib/template/cookiecutter.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"project_name": "",
"author_name": "Project Jupyter Contributors",
"author_email": "[email protected]"
"project_name": "",
"author_name": "Project Jupyter Contributors",
"author_email": "[email protected]"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"""
import os


def setup_{{cookiecutter.project_name}}():
return {
'command': [],
Expand Down
23 changes: 12 additions & 11 deletions contrib/theia/jupyter_theia_proxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@
import os
import shutil


def setup_theia():
# Make sure theia is in $PATH
def _theia_command(port):
full_path = shutil.which('theia')
full_path = shutil.which("theia")
if not full_path:
raise FileNotFoundError('Can not find theia executable in $PATH')
return ['theia', 'start', '.', '--hostname=127.0.0.1', '--port=' + str(port)]
raise FileNotFoundError("Can not find theia executable in $PATH")
return ["theia", "start", ".", "--hostname=127.0.0.1", "--port=" + str(port)]

return {
'command': _theia_command,
'environment': {
'USE_LOCAL_GIT': 'true'
"command": _theia_command,
"environment": {"USE_LOCAL_GIT": "true"},
"launcher_entry": {
"title": "Theia IDE",
"icon_path": os.path.join(
os.path.dirname(os.path.abspath(__file__)), "icons", "theia.svg"
),
},
'launcher_entry': {
'title': 'Theia IDE',
'icon_path': os.path.join(os.path.dirname(os.path.abspath(__file__)), 'icons', 'theia.svg')
}
}
}
16 changes: 7 additions & 9 deletions contrib/theia/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@

setuptools.setup(
name="jupyter-theia-proxy",
version='1.0dev',
version="1.0dev",
url="https://github.com/jupyterhub/jupyter-server-proxy/tree/HEAD/contrib/theia",
author="Project Jupyter Contributors",
description="[email protected]",
packages=setuptools.find_packages(),
keywords=['Jupyter'],
classifiers=['Framework :: Jupyter'],
install_requires=[
'jupyter-server-proxy'
],
keywords=["Jupyter"],
classifiers=["Framework :: Jupyter"],
install_requires=["jupyter-server-proxy"],
entry_points={
'jupyter_serverproxy_servers': [
'theia = jupyter_theia_proxy:setup_theia',
"jupyter_serverproxy_servers": [
"theia = jupyter_theia_proxy:setup_theia",
]
},
package_data={
'jupyter_theia_proxy': ['icons/*'],
"jupyter_theia_proxy": ["icons/*"],
},
)
2 changes: 1 addition & 1 deletion docs/source/arbitrary-ports-hosts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,4 @@ accessing it from a classic notebook extension.
// Construct URL of our proxied service
let service_url = base_url + 'proxy/' + port;
// Do stuff with your service_url
// Do stuff with your service_url
29 changes: 14 additions & 15 deletions docs/source/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

[@bollwyvl](https://github.com/search?q=repo%3Ajupyterhub%2Fjupyter-server-proxy+involves%3Abollwyvl+updated%3A2021-11-29..2022-01-19&type=Issues) | [@consideRatio](https://github.com/search?q=repo%3Ajupyterhub%2Fjupyter-server-proxy+involves%3AconsideRatio+updated%3A2021-11-29..2022-01-19&type=Issues) | [@yuvipanda](https://github.com/search?q=repo%3Ajupyterhub%2Fjupyter-server-proxy+involves%3Ayuvipanda+updated%3A2021-11-29..2022-01-19&type=Issues)


### 3.2.0 - 2021-11-29

#### New features added
Expand Down Expand Up @@ -110,7 +109,7 @@

#### Bugs fixed

* Include jupyterlab-server-proxy in the sdist [#260](https://github.com/jupyterhub/jupyter-server-proxy/pull/260) ([@xhochy](https://github.com/xhochy))
- Include jupyterlab-server-proxy in the sdist [#260](https://github.com/jupyterhub/jupyter-server-proxy/pull/260) ([@xhochy](https://github.com/xhochy))

#### Contributors to this release

Expand All @@ -120,7 +119,7 @@

#### Bugs fixed

* Fix PyPI url [#259](https://github.com/jupyterhub/jupyter-server-proxy/pull/259) ([@janjagusch](https://github.com/janjagusch))
- Fix PyPI url [#259](https://github.com/jupyterhub/jupyter-server-proxy/pull/259) ([@janjagusch](https://github.com/janjagusch))

#### Contributors to this release

Expand All @@ -138,19 +137,19 @@ version jumps from 2.1.2 to 3.0.0.

#### Enhancements made

* Package jupyter lab extension [#245](https://github.com/jupyterhub/jupyter-server-proxy/pull/245) ([@janjagusch](https://github.com/janjagusch))
- Package jupyter lab extension [#245](https://github.com/jupyterhub/jupyter-server-proxy/pull/245) ([@janjagusch](https://github.com/janjagusch))

#### Maintenance and upkeep improvements

* Breaking: Replace host_whitelist with host_allowlist [#256](https://github.com/jupyterhub/jupyter-server-proxy/pull/256) ([@manics](https://github.com/manics))
* Switch from notebook to jupyter-server [#254](https://github.com/jupyterhub/jupyter-server-proxy/pull/254) ([@manics](https://github.com/manics))
- Breaking: Replace host_whitelist with host_allowlist [#256](https://github.com/jupyterhub/jupyter-server-proxy/pull/256) ([@manics](https://github.com/manics))
- Switch from notebook to jupyter-server [#254](https://github.com/jupyterhub/jupyter-server-proxy/pull/254) ([@manics](https://github.com/manics))

#### Continuous integration improvements

* Move build.yaml into test.yaml [#255](https://github.com/jupyterhub/jupyter-server-proxy/pull/255) ([@manics](https://github.com/manics))
* Fix build.yaml workflow [#249](https://github.com/jupyterhub/jupyter-server-proxy/pull/249) ([@manics](https://github.com/manics))
* Add publish PyPI and NPM workflow [#247](https://github.com/jupyterhub/jupyter-server-proxy/pull/247) ([@manics](https://github.com/manics))
* tests: remove bad test, add new clarifying current behavior [#240](https://github.com/jupyterhub/jupyter-server-proxy/pull/240) ([@consideRatio](https://github.com/consideRatio))
- Move build.yaml into test.yaml [#255](https://github.com/jupyterhub/jupyter-server-proxy/pull/255) ([@manics](https://github.com/manics))
- Fix build.yaml workflow [#249](https://github.com/jupyterhub/jupyter-server-proxy/pull/249) ([@manics](https://github.com/manics))
- Add publish PyPI and NPM workflow [#247](https://github.com/jupyterhub/jupyter-server-proxy/pull/247) ([@manics](https://github.com/manics))
- tests: remove bad test, add new clarifying current behavior [#240](https://github.com/jupyterhub/jupyter-server-proxy/pull/240) ([@consideRatio](https://github.com/consideRatio))

#### Contributors to this release

Expand All @@ -170,14 +169,14 @@ extension isn't yet bundled with the python package.

#### Enhancements made

* Add Jupyter Server extension data file (JupyterLab 3 support) [#235](https://github.com/jupyterhub/jupyter-server-proxy/pull/235) ([@jtpio](https://github.com/jtpio))
* Update dependencies to include jupyterlab 3.x.x (JupyterLab 3 support) [#229](https://github.com/jupyterhub/jupyter-server-proxy/pull/229) ([@dipanjank](https://github.com/dipanjank))
- Add Jupyter Server extension data file (JupyterLab 3 support) [#235](https://github.com/jupyterhub/jupyter-server-proxy/pull/235) ([@jtpio](https://github.com/jtpio))
- Update dependencies to include jupyterlab 3.x.x (JupyterLab 3 support) [#229](https://github.com/jupyterhub/jupyter-server-proxy/pull/229) ([@dipanjank](https://github.com/dipanjank))

#### Documentation improvements

* Bump to 1.6.0 (setup.py) and add CHANGELOG.md [#238](https://github.com/jupyterhub/jupyter-server-proxy/pull/238) ([@consideRatio](https://github.com/consideRatio))
* Replace server-process list with linkable headings [#236](https://github.com/jupyterhub/jupyter-server-proxy/pull/236) ([@manics](https://github.com/manics))
* Rename the mamba-navigator example to gator in the documentation [#234](https://github.com/jupyterhub/jupyter-server-proxy/pull/234) ([@jtpio](https://github.com/jtpio))
- Bump to 1.6.0 (setup.py) and add CHANGELOG.md [#238](https://github.com/jupyterhub/jupyter-server-proxy/pull/238) ([@consideRatio](https://github.com/consideRatio))
- Replace server-process list with linkable headings [#236](https://github.com/jupyterhub/jupyter-server-proxy/pull/236) ([@manics](https://github.com/manics))
- Rename the mamba-navigator example to gator in the documentation [#234](https://github.com/jupyterhub/jupyter-server-proxy/pull/234) ([@jtpio](https://github.com/jtpio))

#### Contributors to this release

Expand Down
1 change: 0 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#
import datetime


# -- Project information -----------------------------------------------------
# ref: https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
#
Expand Down
2 changes: 1 addition & 1 deletion docs/source/convenience/new.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ named after your project with a python package. From there, you should:
process, any environment variables, and title of the launcher icon

#. (Optionally) Add a square svg icon for your launcher in the ``icons``
subfolder, with the same name as your project.
subfolder, with the same name as your project.
62 changes: 40 additions & 22 deletions jupyter_server_proxy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
from .handlers import setup_handlers
from .config import ServerProxy as ServerProxyConfig, make_handlers, get_entrypoint_server_processes, make_server_process
from jupyter_server.utils import url_path_join as ujoin
from .api import ServersInfoHandler, IconHandler

from .api import IconHandler, ServersInfoHandler
from .config import ServerProxy as ServerProxyConfig
from .config import get_entrypoint_server_processes, make_handlers, make_server_process
from .handlers import setup_handlers


# Jupyter Extension points
def _jupyter_server_extension_points():
return [{
'module': 'jupyter_server_proxy',
}]
return [
{
"module": "jupyter_server_proxy",
}
]


def _jupyter_nbextension_paths():
return [{
"section": "tree",
"dest": "jupyter_server_proxy",
'src': 'static',
"require": "jupyter_server_proxy/tree"
}]
return [
{
"section": "tree",
"dest": "jupyter_server_proxy",
"src": "static",
"require": "jupyter_server_proxy/tree",
}
]


def _jupyter_labextension_paths():
return [{
"src": "labextension",
"dest": "@jupyterhub/jupyter-server-proxy",
}]
return [
{
"src": "labextension",
"dest": "@jupyterhub/jupyter-server-proxy",
}
]


def _load_jupyter_server_extension(nbapp):
# Set up handlers picked up via config
base_url = nbapp.web_app.settings['base_url']
base_url = nbapp.web_app.settings["base_url"]
serverproxy_config = ServerProxyConfig(parent=nbapp)

server_processes = [
Expand All @@ -35,7 +46,7 @@ def _load_jupyter_server_extension(nbapp):
]
server_processes += get_entrypoint_server_processes(serverproxy_config)
server_handlers = make_handlers(base_url, server_processes)
nbapp.web_app.add_handlers('.*', server_handlers)
nbapp.web_app.add_handlers(".*", server_handlers)

# Set up default non-server handler
setup_handlers(
Expand All @@ -48,10 +59,17 @@ def _load_jupyter_server_extension(nbapp):
if sp.launcher_entry.enabled and sp.launcher_entry.icon_path:
icons[sp.name] = sp.launcher_entry.icon_path

nbapp.web_app.add_handlers('.*', [
(ujoin(base_url, 'server-proxy/servers-info'), ServersInfoHandler, {'server_processes': server_processes}),
(ujoin(base_url, 'server-proxy/icon/(.*)'), IconHandler, {'icons': icons}),
])
nbapp.web_app.add_handlers(
".*",
[
(
ujoin(base_url, "server-proxy/servers-info"),
ServersInfoHandler,
{"server_processes": server_processes},
),
(ujoin(base_url, "server-proxy/icon/(.*)"), IconHandler, {"icons": icons}),
],
)


# For backward compatibility
Expand Down
26 changes: 14 additions & 12 deletions jupyter_server_proxy/api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from tornado import web
import mimetypes

from jupyter_server.base.handlers import JupyterHandler
from jupyter_server.utils import url_path_join as ujoin
from collections import namedtuple
from tornado import web


class ServersInfoHandler(JupyterHandler):
def initialize(self, server_processes):
Expand All @@ -16,28 +17,29 @@ async def get(self):
for sp in self.server_processes:
# Manually recurse to convert namedtuples into JSONable structures
item = {
'name': sp.name,
'launcher_entry': {
'enabled': sp.launcher_entry.enabled,
'title': sp.launcher_entry.title,
'path_info': sp.launcher_entry.path_info
"name": sp.name,
"launcher_entry": {
"enabled": sp.launcher_entry.enabled,
"title": sp.launcher_entry.title,
"path_info": sp.launcher_entry.path_info,
},
'new_browser_tab' : sp.new_browser_tab
"new_browser_tab": sp.new_browser_tab,
}
if sp.launcher_entry.icon_path:
icon_url = ujoin(self.base_url, 'server-proxy', 'icon', sp.name)
item['launcher_entry']['icon_url'] = icon_url
icon_url = ujoin(self.base_url, "server-proxy", "icon", sp.name)
item["launcher_entry"]["icon_url"] = icon_url

data.append(item)

self.write({'server_processes': data})
self.write({"server_processes": data})


# FIXME: Should be a StaticFileHandler subclass
class IconHandler(JupyterHandler):
"""
Serve launcher icons
"""

def initialize(self, icons):
"""
icons is a dict of titles to paths
Expand Down Expand Up @@ -67,4 +69,4 @@ async def get(self, name):

with open(self.icons[name]) as f:
self.write(f.read())
self.set_header('Content-Type', content_type)
self.set_header("Content-Type", content_type)
Loading

0 comments on commit 8884d8b

Please sign in to comment.