Skip to content

Commit

Permalink
Rename python package to rsconnect_jupyter (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Curran authored Dec 5, 2018
1 parent 86f45d9 commit 9ca7e29
Show file tree
Hide file tree
Showing 33 changed files with 129 additions and 102 deletions.
3 changes: 0 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
### Description



Connected to #

### Testing Notes / Validation Steps
Expand Down
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# v1.0.0
# v1.2.0
- Renamed plugin from `rsconnect` to `rsconnect_jupyter`
- Publish notebooks with source allowing them to be rendered on RStudio Connect.
`pip` and `virtualenv` are used to determine dependent packages.

# v1.0.1
- Ensure json is decoded as utf-8

- initial release
- publish notebooks as static documents
# v1.0.0
- Initial release
- Publish notebooks as pre-rendered static documents
8 changes: 4 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ def buildAndTest(pyVersion) {
push: !isUserBranch
)

img.inside("-v ${env.WORKSPACE}:/rsconnect") {
img.inside("-v ${env.WORKSPACE}:/rsconnect_jupyter") {
withEnv(["PY_VERSION=${pyVersion}"]) {
print "running tests: python${pyVersion}"
sh '/rsconnect/run.sh test'
sh '/rsconnect_jupyter/run.sh test'
}
}
return img
Expand Down Expand Up @@ -136,7 +136,7 @@ try {
'python3.6': {
img = buildAndTest("3.6")

img.inside("-v ${env.WORKSPACE}:/rsconnect") {
img.inside("-v ${env.WORKSPACE}:/rsconnect_jupyter") {
print "building python wheel package"
sh 'make dist'
archiveArtifacts artifacts: 'dist/*.whl'
Expand All @@ -155,7 +155,7 @@ try {
docker_context: './docs',
push: !isUserBranch
)
docs_image.inside("-v ${env.WORKSPACE}:/rsconnect") {
docs_image.inside("-v ${env.WORKSPACE}:/rsconnect_jupyter") {
sh 'make docs-build'
archiveArtifacts artifacts: 'dist/*.pdf,dist/*.html'
stash includes: 'dist/*.pdf,dist/*.html', name: 'docs'
Expand Down
6 changes: 3 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include README.md
include rsconnect/static/*.js
include rsconnect/static/main.css
include rsconnect/static/images/*.png
include rsconnect_jupyter/static/*.js
include rsconnect_jupyter/static/main.css
include rsconnect_jupyter/static/images/*.png
26 changes: 13 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ IMAGE=rstudio/rsconnect-jupyter-py
VERSION=$(shell cat version.txt).$(shell printenv BUILD_NUMBER || echo 9999)

clean:
rm -rf build/ dist/ rsconnect.egg-info/
rm -rf build/ dist/ rsconnect_jupyter.egg-info/

all-images: image2 image3.5 image3.6 image3.7

Expand All @@ -24,13 +24,13 @@ image%:
launch:
docker run --rm -i -t \
-v $(CURDIR)/notebooks$(PY_VERSION):/notebooks \
-v $(CURDIR):/rsconnect \
-v $(CURDIR):/rsconnect_jupyter \
-e NB_UID=$(NB_UID) \
-e NB_GID=$(NB_GID) \
-e PY_VERSION=$(PY_VERSION) \
-p :9999:9999 \
$(DOCKER_IMAGE) \
/rsconnect/run.sh $(TARGET)
/rsconnect_jupyter/run.sh $(TARGET)


notebook%:
Expand Down Expand Up @@ -63,12 +63,12 @@ package:
run:
# link python package
python setup.py develop
# install rsconnect as a jupyter extension
jupyter-nbextension install --symlink --user --py rsconnect
# install rsconnect_jupyter as a jupyter extension
jupyter-nbextension install --symlink --user --py rsconnect_jupyter
# enable js extension
jupyter-nbextension enable --py rsconnect
jupyter-nbextension enable --py rsconnect_jupyter
# enable python extension
jupyter-serverextension enable --py rsconnect
jupyter-serverextension enable --py rsconnect_jupyter
# start notebook
jupyter-notebook -y --notebook-dir=/notebooks --ip='0.0.0.0' --port=9999 --no-browser --NotebookApp.token=''

Expand All @@ -82,10 +82,10 @@ dist-run%:
make DOCKER_IMAGE=$(IMAGE)$* PY_VERSION=$* TARGET=dist-run launch

dist-run: dist
pip install dist/rsconnect-$(VERSION)-py2.py3-none-any.whl
jupyter-nbextension install --symlink --user --py rsconnect
jupyter-nbextension enable --py rsconnect
jupyter-serverextension enable --py rsconnect
pip install dist/rsconnect_jupyter-$(VERSION)-py2.py3-none-any.whl
jupyter-nbextension install --symlink --user --py rsconnect_jupyter
jupyter-nbextension enable --py rsconnect_jupyter
jupyter-serverextension enable --py rsconnect_jupyter
jupyter-notebook -y --notebook-dir=/notebooks --ip='0.0.0.0' --port=9999 --no-browser --NotebookApp.token=''

build/mock-connect/bin/flask:
Expand Down Expand Up @@ -115,8 +115,8 @@ ifeq (${JOB_NAME},)
BUILD_DOC=docker run --rm=true ${DOCKER_RUN_AS} \
-e VERSION=${VERSION} \
${DOCKER_ARGS} \
-v $(CURDIR):/rsconnect \
-w /rsconnect \
-v $(CURDIR):/rsconnect_jupyter \
-w /rsconnect_jupyter \
rsconnect-jupyter-docs docs/build-doc.sh
endif

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Installation and usage instructions are available
[here](https://github.com/rstudio/rsconnect-jupyter/tree/master/docs).

# Developing `rsconnect`
# Developing `rsconnect-jupyter`

Need to run this after checkout and when modifying the docker images

Expand Down
2 changes: 1 addition & 1 deletion docs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ RUN export PANDOC_VERSION=2.1.3 && \
gzip -d pandoc.gz pandoc-citeproc.gz && \
chmod 0755 pandoc pandoc-citeproc

WORKDIR /rsconnect
WORKDIR /rsconnect_jupyter
4 changes: 2 additions & 2 deletions docs/build-doc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ sed s/RSCONNECT_VERSION/${VERSION}/g < README.md > ../../build/docs-README.md

pandoc -f markdown-implicit_figures \
--self-contained \
-o ${OUT}/rsconnect-jupyter-${VERSION}.html \
-o ${OUT}/rsconnect_jupyter-${VERSION}.html \
-H style.css \
../../build/docs-README.md

pandoc -f markdown-implicit_figures \
-o ${OUT}/rsconnect-jupyter-${VERSION}.pdf \
-o ${OUT}/rsconnect_jupyter-${VERSION}.pdf \
../../build/docs-README.md
95 changes: 59 additions & 36 deletions docs/guide/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: rsconnect User Guide
title: rsconnect-jupyter User Guide
---
[rsconnect](https://www.github.com/rstudio/rsconnect-jupyter/) is a
[rsconnect-jupyter](https://www.github.com/rstudio/rsconnect-jupyter/) is a
plugin for [Jupyter Notebook](https://jupyter.org/) that enables
publishing notebooks to [RStudio
Connect](https://www.rstudio.com/products/connect/).
Expand All @@ -17,11 +17,12 @@ If using `conda`, `pip` and `wheel` should already be installed.

# Installation

Download the `rsconnect` python package from
[https://s3.amazonaws.com/rstudio-rsconnect-jupyter/rsconnect-RSCONNECT_VERSION-py2.py3-none-any.whl](https://s3.amazonaws.com/rstudio-rsconnect-jupyter/rsconnect-RSCONNECT_VERSION-py2.py3-none-any.whl)
Download the `rsconnect-jupyter` python package from
[https://s3.amazonaws.com/rstudio-rsconnect-jupyter/rsconnect_jupyter-RSCONNECT_VERSION-py2.py3-none-any.whl](https://s3.amazonaws.com/rstudio-rsconnect-jupyter/rsconnect_jupyter-RSCONNECT_VERSION-py2.py3-none-any.whl)
(packaged as a [wheel](https://pythonwheels.com/) file).

If you are installing `rsconnect` for use in Jupyterhub, please see the [Jupyterhub](#Installation-In-Jupyterhub) section below.
If you are installing `rsconnect-jupyter` for use in Jupyterhub, please see the
[Jupyterhub](#Installation-In-Jupyterhub) section below.

We recommend working within a `virtualenv`. If you
are unfamiliar, these commands create and activate a `virtualenv`
Expand All @@ -33,52 +34,52 @@ virtualenv /my/path
source /my/path/bin/activate
```

Install the `rsconnect` package with the following command:
Install the `rsconnect-jupyter` package with the following command:

```bash
pip install rsconnect-RSCONNECT_VERSION-py2.py3-none-any.whl
pip install rsconnect_jupyter-RSCONNECT_VERSION-py2.py3-none-any.whl
```

Enable the `rsconnect` extension with the following commands:
Enable the `rsconnect-jupyter` extension with the following commands:

```bash
# Install `rsconnect` as a jupyter extension
jupyter-nbextension install --sys-prefix --py rsconnect
# Install `rsconnect-jupyter` as a jupyter extension
jupyter-nbextension install --sys-prefix --py rsconnect_jupyter

# Enable JavaScript extension
jupyter-nbextension enable --sys-prefix --py rsconnect
jupyter-nbextension enable --sys-prefix --py rsconnect_jupyter

# Enable Python extension
jupyter-serverextension enable --sys-prefix --py rsconnect
jupyter-serverextension enable --sys-prefix --py rsconnect_jupyter
```

Note: The above commands only need to be run once when installing
`rsconnect`.
`rsconnect_jupyter`.

Note: If you run into an issue during installation please let us know by filing
a bug [here](https://github.com/rstudio/rsconnect-jupyter/issues).

# Uninstalling

First disable and remove the `rsconnect` notebook extension:
First disable and remove the `rsconnect-jupyter` notebook extension:

```bash
# Disable Python extensions found in `rsconnect`
jupyter-serverextension disable --sys-prefix --py rsconnect
# Disable Python extensions found in `rsconnect-jupyter`
jupyter-serverextension disable --sys-prefix --py rsconnect_jupyter

# Remove JavaScript extension
jupyter-nbextension uninstall --sys-prefix --py rsconnect
jupyter-nbextension uninstall --sys-prefix --py rsconnect_jupyter
```

Finally, uninstall the `rsconnect` python package:
Finally, uninstall the `rsconnect-jupyter` python package:

```bash
pip uninstall rsconnect
pip uninstall rsconnect_jupyter
```

# Upgrading

To upgrade `rsconnect`, first uninstall the extension and then
To upgrade `rsconnect-jupyter`, first uninstall the extension and then
re-install it.

# Usage
Expand Down Expand Up @@ -113,11 +114,23 @@ If you select "Publish document with source code", the notebook file and a list

#### Environment detection with pip

The list of packages sent along with the notebook comes from the python environment where the notebook kernel is running. In order for environment inspection to work, the `rsconnect` package must be installed in the kernel environment; that is, the environment where the `ipykernel` package is installed. In most cases that will be the same as the notebook server environment where `jupyter` is installed.
The list of packages sent along with the notebook comes from the python
environment where the notebook kernel is running. In order for environment
inspection to work, the `rsconnect-jupyter` package must be installed in the
kernel environment; that is, the environment where the `ipykernel` package is
installed. In most cases that will be the same as the notebook server
environment where `jupyter` is installed.

If there is a `requirements.txt` file in the same directory as the notebook file, its contents will be used. This allows you to directly control which packages will be installed on the RStudio Connect server before the notebook is rendered. If you use this option, you must ensure that all necessary packages are listed in the `requirements.txt` file.
If there is a `requirements.txt` file in the same directory as the notebook
file, its contents will be used. This allows you to directly control which
packages will be installed on the RStudio Connect server before the notebook is
rendered. If you use this option, you must ensure that all necessary packages
are listed in the `requirements.txt` file.

If there isn't a requirements file, the command `pip freeze` will be used to inspect the environment. The output of `pip freeze` lists all packages currently installed, as well as their versions, which enables RStudio Connect to recreate the same environment.
If there isn't a requirements file, the command `pip freeze` will be used to
inspect the environment. The output of `pip freeze` lists all packages currently
installed, as well as their versions, which enables RStudio Connect to recreate
the same environment.


### Handling conflicts
Expand Down Expand Up @@ -148,16 +161,23 @@ You may share notebooks if appropriate.

# Installation in JupyterHub

In JupyterHub, follow the directions [above](#Installation) to install the `rsconnect` package into the Python environment where the Jupyter notebook server and kernel are installed. Typically those will be the same environment. If you've configured separate kernel environments, install the `rsconnect` package in the notebook server environment as well as each kernel environment.
In JupyterHub, follow the directions [above](#Installation) to install the
`rsconnect-jupyter` package into the Python environment where the Jupyter
notebook server and kernel are installed. Typically those will be the same
environment. If you've configured separate kernel environments, install the
`rsconnect-jupyter` package in the notebook server environment as well as each
kernel environment.

The exact install location depends on your Jupyterhub configuration.


## JupyterHub Example Configuration

This section presents a simple working example of a Jupyterhub configuration with `rsconnect` installed.
This section presents a simple working example of a Jupyterhub configuration
with `rsconnect-jupyter` installed.

This example uses Docker, but you can install the `rsconnect` package in any Jupyterhub installation. Docker is not required.
This example uses Docker, but you can install the `rsconnect-jupyter` package in
any Jupyterhub installation. Docker is not required.

Example Dockerfile:

Expand All @@ -167,17 +187,17 @@ FROM jupyterhub/jupyterhub:0.9.4
# Install Jupyter notebook into the existing base conda environment
RUN conda install notebook

# Download and install rsconnect in the same environment
# Update this to specify the desired version of the rsconnect package,
# Download and install rsconnect-jupyter in the same environment
# Update this to specify the desired version of the rsconnect-jupyter package,
# or pass `--build-arg VERSION=...` to docker build.
ARG VERSION=RSCONNECT_VERSION
ARG REPOSITORY=https://s3.amazonaws.com/rstudio-rsconnect-jupyter

RUN wget ${REPOSITORY}/rsconnect-${VERSION}-py2.py3-none-any.whl
RUN pip install rsconnect-${VERSION}-py2.py3-none-any.whl && \
jupyter-nbextension install --sys-prefix --py rsconnect && \
jupyter-nbextension enable --sys-prefix --py rsconnect && \
jupyter-serverextension enable --sys-prefix --py rsconnect
RUN wget ${REPOSITORY}/rsconnect_jupyter-${VERSION}-py2.py3-none-any.whl
RUN pip install rsconnect_jupyter-${VERSION}-py2.py3-none-any.whl && \
jupyter-nbextension install --sys-prefix --py rsconnect_jupyter && \
jupyter-nbextension enable --sys-prefix --py rsconnect_jupyter && \
jupyter-serverextension enable --sys-prefix --py rsconnect_jupyter

# create test users
RUN useradd -m -s /bin/bash user1 && \
Expand All @@ -192,8 +212,11 @@ CMD ["jupyterhub"]

Run these commands to build and start the container:
```bash
docker build -t jupyterhub:rsconnect .
docker run --rm -p 8000:8000 --name jupyterhub jupyterhub:rsconnect
docker build -t jupyterhub:rsconnect-jupyter .
docker run --rm -p 8000:8000 --name jupyterhub jupyterhub:rsconnect-jupyter
```

Connect to Jupyterhub on http://localhost:8000 and log in as one of the test users. From there, you can create a notebook and publish it to RStudio Connect. Note that the current Jupyterhub docker image uses Python 3.6.5, so you will need a compatible Python version installed on your RStudio Connect server.
Connect to Jupyterhub on http://localhost:8000 and log in as one of the test
users. From there, you can create a notebook and publish it to RStudio Connect.
Note that the current Jupyterhub docker image uses Python 3.6.5, so you will
need a compatible Python version installed on your RStudio Connect server.
8 changes: 4 additions & 4 deletions rsconnect/__init__.py → rsconnect_jupyter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

def _jupyter_server_extension_paths():
return [{
"module": "rsconnect"
"module": "rsconnect_jupyter"
}]


Expand All @@ -27,9 +27,9 @@ def _jupyter_nbextension_paths():
# the path is relative to the `rsconnect` directory
src="static",
# directory in the `nbextension/` namespace
dest="rsconnect",
dest="rsconnect_jupyter",
# _also_ in the `nbextension/` namespace
require="rsconnect/index")]
require="rsconnect_jupyter/index")]


def md5(s):
Expand Down Expand Up @@ -161,7 +161,7 @@ def post(self, action):


def load_jupyter_server_extension(nb_app):
nb_app.log.info("rsconnect enabled!")
nb_app.log.info("rsconnect_jupyter enabled!")
web_app = nb_app.web_app
host_pattern = '.*$'
action_pattern = r'(?P<action>\w+)'
Expand Down
2 changes: 1 addition & 1 deletion rsconnect/api.py → rsconnect_jupyter/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, message):

from notebook.utils import url_path_join

logger = logging.getLogger('rsconnect')
logger = logging.getLogger('rsconnect_jupyter')
logger.setLevel(logging.INFO)


Expand Down
2 changes: 1 addition & 1 deletion rsconnect/bundle.py → rsconnect_jupyter/bundle.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import nbformat
from ipython_genutils import text

log = logging.getLogger('rsconnect')
log = logging.getLogger('rsconnect_jupyter')
log.setLevel(logging.DEBUG)


Expand Down
Loading

0 comments on commit 9ca7e29

Please sign in to comment.