Skip to main content

No project description provided

Project description

PyBunny - Your SSH-Jupyter Proxy Hop Friend!

Python PEP8 License: MPL 2.0 PRs Welcome saythanks

Bunny is a ssh proxy jumping for jupyter notebooks. If you are in a situation similar to mine where you want to port forward a jupyter notebook from your mini cluster machine but is not ssh accessible so you need a gateway that is SSH accessible and you are going to port forward through several machines. Well I wrote a python package for it.

    HOST A (local machine) -> HOST B (gateway) -> HOST C (execute jupyter)
    

Note: you must have authorized keys in your SSH between every Host added into the Bunny.

Quick Start

Running the bunny is pretty easy. To initialize a class you pass the python_env variable to dictate which python env is going to be running the jupyter notebook. The notebook_launch_command is your exact launch command to run the jupyter notebook - mine is exampled down below and the port you execute your notebook on.

    from pybunny.bunny import Bunny
    
    bunny = Bunny(
        python_env='/path/to/env/python',
        notebook_launch_command='jupyter notebook --no-browser --NotebookApp.token=""',
        port='8889'
    )
    

Next add your hops between the bunnies, with the user, hostname, and the name of the gateway. If this is the last server in your chain to run the notebook then add the proxy_jump argument if


    bunny.add_hop('hop1', hostname='XX.XX.XXX.XXX', user='poor_graduate_student')
    bunny.add_hop('notebook', hostname='fakeemail@someuniversity.edu', user='poor_graduate_student', proxy_jump = True)
    

When your configurations are set then write the SSH Config, this is a local bunny_config file generated that contains the bunny configuration.


    bunny.write()

which generates something like this:

    
    Host hop1
    
      HostName XX.XXX.XXX.XXX
      User poor_graduate_student
    
    Host notebook
      HostName fakeemail@someuniversity.edu
      User poor_graduate_student
      ProxyJump XX.XX.XXX.XXX
      RequestTTY force
      LocalForward 8889 127.0.0.1:8889
      RemoteCommand /path/to/env/python jupyter notebook --no-browser --NotebookApp.token="" --port=8889

The last command will be the run() function which will execute the SSH connection across your gateways. Under the hood it runs the SSH -F bunny_config name so as long as your have SSH installed we should be good and your process will run.

    
    bunny.run()
    

If all successful we should be generating something like this:


[I 20:46:00.555 NotebookApp] JupyterLab extension loaded from anaconda3/lib/python3.7/site-packages/jupyterlab
[I 20:46:00.555 NotebookApp] JupyterLab application directory is /jupyter/lab
[I 20:46:00.557 NotebookApp] Serving notebooks from local directory: /rotation
[I 20:46:00.557 NotebookApp] The Jupyter Notebook is running at:
[I 20:46:00.557 NotebookApp] http://localhost:8889/
[I 20:46:00.557 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 20:46:04.084 NotebookApp] 302 GET / (127.0.0.1) 1.00ms
[E 20:46:04.166 NotebookApp] Could not open static file ''
[W 20:46:04.503 NotebookApp] 404 GET /static/components/react/react-dom.production.min.js (127.0.0.1) 14.90ms referer=http://localhost:8889/tree?

Announcements

  • Work has began Jan 9th

Installation

Bunny is going to be distribute via PyPi and as the content store grows we can expand it to other pieces of software making it accessible to all regardless of what you use. Alternatively, you could have a glance at the source code and copy/paste it yourself.

To install the reader


python -m pip install bunny

Structure of Bunny

Currently, the main subpackages are:

  • bunny: Bunny Main Class

Genesis

Bunny was created because I am forced to port forward my jupyter notebooks through a gateway server and there is no way around it due to bureaucracy.


External links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybunny-0.0.1.tar.gz (5.2 kB view details)

Uploaded Source

File details

Details for the file pybunny-0.0.1.tar.gz.

File metadata

  • Download URL: pybunny-0.0.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.6

File hashes

Hashes for pybunny-0.0.1.tar.gz
Algorithm Hash digest
SHA256 ac2a2e47fcbff30dd9bf5ff591533a1a6389f960e1cf52584ea298596072f0ac
MD5 008583dee445a12783c9d1512c43e3d5
BLAKE2b-256 977363c40bbb1c1bb88bda6cbf01628be125c30faf66eb3f82b6d63b2ccc6be6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page