ipython notebook --no-mathjax
There are several steps to secure the notebook server on a remote machine (see http://ipython.org/ipython-doc/dev/notebook/public_server.html)
There is a bug in the combination of Safari and tornado that may not allow you to run the remote notebook properly: Use a different browser
In [4]:
!ssh thauser@thauser@comet.sdsc.edu 'cd .ipython/profile_nbserver; ls -al'
In [6]:
from IPython.lib import passwd
passwd('test password')
Out[6]:
Not recommended: Use interactive ipython and then just passwd()
In [10]:
!ssh thauser@gordon.sdsc.xsede.org 'head -n 12 .ipython/profile_nbserver/ipython_notebook_config.py'
ipython notebook --profile=nbserver
connect to
https://comet-ln3.sdsc.edu:11111
you need to enter your password
On some machines compute nodes maybe not accessible from the outside
On your local machine:
#ssh -L localport:nodename:remote_port -f -N comet.sdsc.edu
$ ssh -L 8088:comet-04-45:9088 -f -N comet comet.sdsc.edu
open your localbrowser at https://localhost:8088
A light-weight access layer for distributed computing infrastructure
http://saga-project.github.io/saga-python/
$ pip install saga-python
In [5]:
import sys
import time
import saga
# Adapted from the saga example
# Your ssh identity on the remote machine.
ctx = saga.Context("ssh")
ctx.user_id = 'thauser'
session = saga.Session()
session.add_context(ctx)
# Create a job service object that represent a remote pbs cluster.
js = saga.job.Service("slurm+ssh://comet.sdsc.edu", session=session)
# Set the parameters for this example
local_port=9988
remote_port=11111
username='thauser'
hostname='comet.sdsc.edu'
# Next, we describe the job we want to run. A complete set of job
# description attributes can be found in the API documentation.
jd = saga.job.Description()
jd.wall_time_limit = 10 # minutes
jd.executable = "ipython notebook --profile=nbserver"
jd.queue = "compute"
jd.working_directory = "A"
jd.output = "ipythonjob.out"
jd.error = "ipythonjob.err"
In [6]:
touchjob = js.create_job(jd)
# Check our job's id and state
print "Job ID : %s" % (touchjob.id)
print "Job State : %s" % (touchjob.state)
# Now we can start our job.
print "\n...starting job...\n"
touchjob.run()
print "Job ID : %s" % (touchjob.id)
print "Job State : %s" % (touchjob.state)
# List all jobs that are known by the adaptor.
# This should show our job as well.
print "\nListing active jobs: "
for job in js.list():
print " * %s" % job
In [7]:
# Now we disconnect and reconnect to our job by using the get_job()
# method and our job's id. While this doesn't make a lot of sense
# here, disconnect / reconnect can become very important for
# long-running job.
touchjob_clone = js.get_job(touchjob.id)
print touchjob_clone.state
while touchjob_clone.state == 'Pending':
print "...Waiting for Job to start...."
time.sleep(30)
nodename = touchjob_clone.execution_hosts[0]
nodename = nodename[:-2]
touchjob_clone.wait()
print "Job State : %s" % (touchjob_clone.state)
print "Exitcode : %s" % (touchjob_clone.exit_code)
js.close()
In [8]:
touchjob.id
Out[8]:
In [9]:
js.get_job(touchjob.id)
Out[9]:
In [10]:
touchjob_clone = js.get_job(touchjob.id)
In [11]:
print touchjob_clone.state
In [13]:
touchjob_clone.execution_hosts
Out[13]:
In [ ]: