Skip to content

Commit

Permalink
remove show_with_bokeh_server(); update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
athornton committed Dec 12, 2023
1 parent b3af5da commit d98af6b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 39 deletions.
77 changes: 73 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ Install from PyPI:
pip install lsst-rsp
```

lsst-rsp is developed by Rubin Observatory at https://github.com/lsst-sqre/lsst-rsp.
but, really, lsst-rsp is only useful inside an RSP JupyterLab container.

## Features
See below for how to test new versions within such a container.

<!-- A bullet list with things that this package does -->
lsst-rsp is developed by Rubin Observatory at https://github.com/lsst-sqre/lsst-rsp.

## Developing lsst-rsp

Expand All @@ -37,4 +37,73 @@ To learn more about the individual environments:
tox -av
```

[See the docs for more information.](https://lsst-rsp.lsst.io/dev/development.html)
## Developing lsst-rsp on the RSP

The `LSST` kernel in the RSP `sciplat-lab` image already has a release
version of `lsst-rsp` in it. Therefore, there is some setup you need to
do in order to create a development environment you can use.
Specifically, you need to create a virtualenv for the editable
`lsst-rsp`, install `tox` and `pre-commit` for its test machinery, and
then create a JupyterLab kernel pointing to it.

Open a terminal session:

```bash
VENV="lsst_rsp"
mkdir -p ${HOME}/venvs
python -m venv ${HOME}/venvs/${VENV}
. ${HOME}/venvs/${VENV}/bin/activate
mkdir -p ${HOME}/src
cd ${HOME}/src
git clone https://github.com/lsst-sqre/lsst-rsp # or [email protected]:lsst-sqre/lsst-rsp.git if you prefer
cd lsst-rsp
make init
pip install ipykernel
python -m ipykernel install --user --name=${VENV}
```

Now you will need to shut down your lab and get a new container image.
That's because the process your Lab interface is running inside doesn't
know about the new kernel--but once you restart the Lab container, it
will.

Once you're in your new container, you will notice that you have a new
kernel named `lsst_rsp`.

Now you've got an editable version installed in your custom kernel, and
you can still run all the usual tox environments too.

If you start a notebook with your custom kernel,

```python
import lsst.rsp

lsst.rsp.__version__
```

will show you your development version. Note that you will still need
to restart the kernel to pick up changes you make to your copy of
`lsst_rsp`.

Uninstalling a development version from the RSP
===============================================

Open a terminal window.

```bash
. $HOME/venvs/lsst_rsp/bin/activate
jupyter kernelspec uninstall lsst_rsp
y
deactivate
```

Shut down and restart your notebook as before. When you come back in,
in a terminal window:

```bash
rm -rf $HOME/venvs/lsst_rsp
```

You will need to remove the virtualenv directory after restarting the
Lab container, because otherwise JupyterLab will be holding some files
open because it still believes it has a kernel there.
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ classifiers = [
requires-python = ">=3.11"
# FIXME When pyvo 1.5.0 is released, remove pin.
dependencies = [
"bokeh",
"Deprecated",
"IPython",
"pyvo@git+https://github.com/astropy/pyvo.git@7682a1809cb2169cc2ffd9313feb6a4abd7f7e37"
Expand Down
2 changes: 0 additions & 2 deletions src/lsst/rsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
get_hostname,
get_node,
get_pod,
show_with_bokeh_server,
)

__version__: str
Expand Down Expand Up @@ -47,5 +46,4 @@
"get_obstap_service",
"retrieve_query",
"get_hostname",
"show_with_bokeh_server",
]
32 changes: 0 additions & 32 deletions src/lsst/rsp/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"""Utility functions for LSST JupyterLab notebook environment."""

import os
import urllib
from pathlib import Path
from typing import Any, Optional, Union

import bokeh.io
import pyvo
import requests
from deprecated import deprecated
Expand Down Expand Up @@ -93,36 +91,6 @@ def get_pyvo_auth() -> Optional[pyvo.auth.authsession.AuthSession]:
return auth


def show_with_bokeh_server(obj: Any) -> None:
"""Method to wrap bokeh with proxy URL"""

def jupyter_proxy_url(port: Optional[int] = None) -> str:
"""Callable to configure Bokeh's show method when a proxy must be
configured.
If port is None we're asking about the URL
for the origin header.
https://docs.bokeh.org/en/latest/docs/user_guide/jupyter.html
"""
base_url = os.environ["EXTERNAL_INSTANCE_URL"]
host = urllib.parse.urlparse(base_url).netloc

# If port is None we're asking for the URL origin
# so return the public hostname.
if port is None:
return host

service_url_path = os.environ["JUPYTERHUB_SERVICE_PREFIX"]
proxy_url_path = "proxy/%d" % port

user_url = urllib.parse.urljoin(base_url, service_url_path)
full_url = urllib.parse.urljoin(user_url, proxy_url_path)
return full_url

bokeh.io.show(obj=obj, notebook_url=jupyter_proxy_url)


@deprecated(
reason="get_pod() always returns None in RSPs running Nubladov3 or later"
)
Expand Down

0 comments on commit d98af6b

Please sign in to comment.