3.4. Driving from a Jupyter Notebook

One of the most popular ways to drive the xGT server is from a Python environment managed by a Jupyter Notebook. This environment can be run on a variety of client platforms, including Linux, Mac OSX, and Windows. An easy way to get your environment set up and ready to run is to install Anaconda. There is an open source individual edition, which is an easy way to get started using Anaconda.

Of course, it is possible to install the Jupyter Notebook application without installing Anaconda. If you have a Python environment complete with a pip application, you can simply do:

$ pip install jupyter

3.4.1. Useful Notebook Cells

If you wish to have the notebook establish an SSH tunnel to the xGT server, you should have one of the first code cells contain something like:

!ssh -fNL 4367:localhost:4367 username@my.examples.com
!ps -A | grep 'ssh[ ]-fNL'

Another convenient code cell to have is one that establishes a connection to the xGT server:

import xgt
import getpass
server = xgt.Connection(userid = getpass.getuser(),
                        credentials = getpass.getpass('Password: '))
server.server_version

As discussed in User Authentication, this will use the username identity provided by the getpass calls to log in on the remote server.