You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by sm...@apache.org on 2016/08/09 18:00:55 UTC

[15/32] airavata-sandbox git commit: adding jupyter note books for Airavata

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TSocket.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TSocket.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TSocket.py
new file mode 100644
index 0000000..971b526
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TSocket.py
@@ -0,0 +1,176 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+import errno
+import os
+import socket
+import sys
+
+from thrift.transport.TTransport import *
+
+
+class TSocketBase(TTransportBase):
+  def _resolveAddr(self):
+    if self._unix_socket is not None:
+      return [(socket.AF_UNIX, socket.SOCK_STREAM, None, None,
+               self._unix_socket)]
+    else:
+      return socket.getaddrinfo(self.host,
+                                self.port,
+                                socket.AF_UNSPEC,
+                                socket.SOCK_STREAM,
+                                0,
+                                socket.AI_PASSIVE | socket.AI_ADDRCONFIG)
+
+  def close(self):
+    if self.handle:
+      self.handle.close()
+      self.handle = None
+
+
+class TSocket(TSocketBase):
+  """Socket implementation of TTransport base."""
+
+  def __init__(self, host='localhost', port=9090, unix_socket=None):
+    """Initialize a TSocket
+
+    @param host(str)  The host to connect to.
+    @param port(int)  The (TCP) port to connect to.
+    @param unix_socket(str)  The filename of a unix socket to connect to.
+                             (host and port will be ignored.)
+    """
+    self.host = host
+    self.port = port
+    self.handle = None
+    self._unix_socket = unix_socket
+    self._timeout = None
+
+  def setHandle(self, h):
+    self.handle = h
+
+  def isOpen(self):
+    return self.handle is not None
+
+  def setTimeout(self, ms):
+    if ms is None:
+      self._timeout = None
+    else:
+      self._timeout = ms / 1000.0
+
+    if self.handle is not None:
+      self.handle.settimeout(self._timeout)
+
+  def open(self):
+    try:
+      res0 = self._resolveAddr()
+      for res in res0:
+        self.handle = socket.socket(res[0], res[1])
+        self.handle.settimeout(self._timeout)
+        try:
+          self.handle.connect(res[4])
+        except socket.error, e:
+          if res is not res0[-1]:
+            continue
+          else:
+            raise e
+        break
+    except socket.error, e:
+      if self._unix_socket:
+        message = 'Could not connect to socket %s' % self._unix_socket
+      else:
+        message = 'Could not connect to %s:%d' % (self.host, self.port)
+      raise TTransportException(type=TTransportException.NOT_OPEN,
+                                message=message)
+
+  def read(self, sz):
+    try:
+      buff = self.handle.recv(sz)
+    except socket.error, e:
+      if (e.args[0] == errno.ECONNRESET and
+          (sys.platform == 'darwin' or sys.platform.startswith('freebsd'))):
+        # freebsd and Mach don't follow POSIX semantic of recv
+        # and fail with ECONNRESET if peer performed shutdown.
+        # See corresponding comment and code in TSocket::read()
+        # in lib/cpp/src/transport/TSocket.cpp.
+        self.close()
+        # Trigger the check to raise the END_OF_FILE exception below.
+        buff = ''
+      else:
+        raise
+    if len(buff) == 0:
+      raise TTransportException(type=TTransportException.END_OF_FILE,
+                                message='TSocket read 0 bytes')
+    return buff
+
+  def write(self, buff):
+    if not self.handle:
+      raise TTransportException(type=TTransportException.NOT_OPEN,
+                                message='Transport not open')
+    sent = 0
+    have = len(buff)
+    while sent < have:
+      plus = self.handle.send(buff)
+      if plus == 0:
+        raise TTransportException(type=TTransportException.END_OF_FILE,
+                                  message='TSocket sent 0 bytes')
+      sent += plus
+      buff = buff[plus:]
+
+  def flush(self):
+    pass
+
+
+class TServerSocket(TSocketBase, TServerTransportBase):
+  """Socket implementation of TServerTransport base."""
+
+  def __init__(self, host=None, port=9090, unix_socket=None):
+    self.host = host
+    self.port = port
+    self._unix_socket = unix_socket
+    self.handle = None
+
+  def listen(self):
+    res0 = self._resolveAddr()
+    for res in res0:
+      if res[0] is socket.AF_INET6 or res is res0[-1]:
+        break
+
+    # We need remove the old unix socket if the file exists and
+    # nobody is listening on it.
+    if self._unix_socket:
+      tmp = socket.socket(res[0], res[1])
+      try:
+        tmp.connect(res[4])
+      except socket.error, err:
+        eno, message = err.args
+        if eno == errno.ECONNREFUSED:
+          os.unlink(res[4])
+
+    self.handle = socket.socket(res[0], res[1])
+    self.handle.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+    if hasattr(self.handle, 'settimeout'):
+      self.handle.settimeout(None)
+    self.handle.bind(res[4])
+    self.handle.listen(128)
+
+  def accept(self):
+    client, addr = self.handle.accept()
+    result = TSocket()
+    result.setHandle(client)
+    return result

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TSocket.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TSocket.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TSocket.pyc
new file mode 100644
index 0000000..a94c5e2
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TSocket.pyc differ

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTransport.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTransport.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTransport.py
new file mode 100644
index 0000000..4481371
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTransport.py
@@ -0,0 +1,330 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from cStringIO import StringIO
+from struct import pack, unpack
+from thrift.Thrift import TException
+
+
+class TTransportException(TException):
+  """Custom Transport Exception class"""
+
+  UNKNOWN = 0
+  NOT_OPEN = 1
+  ALREADY_OPEN = 2
+  TIMED_OUT = 3
+  END_OF_FILE = 4
+
+  def __init__(self, type=UNKNOWN, message=None):
+    TException.__init__(self, message)
+    self.type = type
+
+
+class TTransportBase:
+  """Base class for Thrift transport layer."""
+
+  def isOpen(self):
+    pass
+
+  def open(self):
+    pass
+
+  def close(self):
+    pass
+
+  def read(self, sz):
+    pass
+
+  def readAll(self, sz):
+    buff = ''
+    have = 0
+    while (have < sz):
+      chunk = self.read(sz - have)
+      have += len(chunk)
+      buff += chunk
+
+      if len(chunk) == 0:
+        raise EOFError()
+
+    return buff
+
+  def write(self, buf):
+    pass
+
+  def flush(self):
+    pass
+
+
+# This class should be thought of as an interface.
+class CReadableTransport:
+  """base class for transports that are readable from C"""
+
+  # TODO(dreiss): Think about changing this interface to allow us to use
+  #               a (Python, not c) StringIO instead, because it allows
+  #               you to write after reading.
+
+  # NOTE: This is a classic class, so properties will NOT work
+  #       correctly for setting.
+  @property
+  def cstringio_buf(self):
+    """A cStringIO buffer that contains the current chunk we are reading."""
+    pass
+
+  def cstringio_refill(self, partialread, reqlen):
+    """Refills cstringio_buf.
+
+    Returns the currently used buffer (which can but need not be the same as
+    the old cstringio_buf). partialread is what the C code has read from the
+    buffer, and should be inserted into the buffer before any more reads.  The
+    return value must be a new, not borrowed reference.  Something along the
+    lines of self._buf should be fine.
+
+    If reqlen bytes can't be read, throw EOFError.
+    """
+    pass
+
+
+class TServerTransportBase:
+  """Base class for Thrift server transports."""
+
+  def listen(self):
+    pass
+
+  def accept(self):
+    pass
+
+  def close(self):
+    pass
+
+
+class TTransportFactoryBase:
+  """Base class for a Transport Factory"""
+
+  def getTransport(self, trans):
+    return trans
+
+
+class TBufferedTransportFactory:
+  """Factory transport that builds buffered transports"""
+
+  def getTransport(self, trans):
+    buffered = TBufferedTransport(trans)
+    return buffered
+
+
+class TBufferedTransport(TTransportBase, CReadableTransport):
+  """Class that wraps another transport and buffers its I/O.
+
+  The implementation uses a (configurable) fixed-size read buffer
+  but buffers all writes until a flush is performed.
+  """
+  DEFAULT_BUFFER = 4096
+
+  def __init__(self, trans, rbuf_size=DEFAULT_BUFFER):
+    self.__trans = trans
+    self.__wbuf = StringIO()
+    self.__rbuf = StringIO("")
+    self.__rbuf_size = rbuf_size
+
+  def isOpen(self):
+    return self.__trans.isOpen()
+
+  def open(self):
+    return self.__trans.open()
+
+  def close(self):
+    return self.__trans.close()
+
+  def read(self, sz):
+    ret = self.__rbuf.read(sz)
+    if len(ret) != 0:
+      return ret
+
+    self.__rbuf = StringIO(self.__trans.read(max(sz, self.__rbuf_size)))
+    return self.__rbuf.read(sz)
+
+  def write(self, buf):
+    self.__wbuf.write(buf)
+
+  def flush(self):
+    out = self.__wbuf.getvalue()
+    # reset wbuf before write/flush to preserve state on underlying failure
+    self.__wbuf = StringIO()
+    self.__trans.write(out)
+    self.__trans.flush()
+
+  # Implement the CReadableTransport interface.
+  @property
+  def cstringio_buf(self):
+    return self.__rbuf
+
+  def cstringio_refill(self, partialread, reqlen):
+    retstring = partialread
+    if reqlen < self.__rbuf_size:
+      # try to make a read of as much as we can.
+      retstring += self.__trans.read(self.__rbuf_size)
+
+    # but make sure we do read reqlen bytes.
+    if len(retstring) < reqlen:
+      retstring += self.__trans.readAll(reqlen - len(retstring))
+
+    self.__rbuf = StringIO(retstring)
+    return self.__rbuf
+
+
+class TMemoryBuffer(TTransportBase, CReadableTransport):
+  """Wraps a cStringIO object as a TTransport.
+
+  NOTE: Unlike the C++ version of this class, you cannot write to it
+        then immediately read from it.  If you want to read from a
+        TMemoryBuffer, you must either pass a string to the constructor.
+  TODO(dreiss): Make this work like the C++ version.
+  """
+
+  def __init__(self, value=None):
+    """value -- a value to read from for stringio
+
+    If value is set, this will be a transport for reading,
+    otherwise, it is for writing"""
+    if value is not None:
+      self._buffer = StringIO(value)
+    else:
+      self._buffer = StringIO()
+
+  def isOpen(self):
+    return not self._buffer.closed
+
+  def open(self):
+    pass
+
+  def close(self):
+    self._buffer.close()
+
+  def read(self, sz):
+    return self._buffer.read(sz)
+
+  def write(self, buf):
+    self._buffer.write(buf)
+
+  def flush(self):
+    pass
+
+  def getvalue(self):
+    return self._buffer.getvalue()
+
+  # Implement the CReadableTransport interface.
+  @property
+  def cstringio_buf(self):
+    return self._buffer
+
+  def cstringio_refill(self, partialread, reqlen):
+    # only one shot at reading...
+    raise EOFError()
+
+
+class TFramedTransportFactory:
+  """Factory transport that builds framed transports"""
+
+  def getTransport(self, trans):
+    framed = TFramedTransport(trans)
+    return framed
+
+
+class TFramedTransport(TTransportBase, CReadableTransport):
+  """Class that wraps another transport and frames its I/O when writing."""
+
+  def __init__(self, trans,):
+    self.__trans = trans
+    self.__rbuf = StringIO()
+    self.__wbuf = StringIO()
+
+  def isOpen(self):
+    return self.__trans.isOpen()
+
+  def open(self):
+    return self.__trans.open()
+
+  def close(self):
+    return self.__trans.close()
+
+  def read(self, sz):
+    ret = self.__rbuf.read(sz)
+    if len(ret) != 0:
+      return ret
+
+    self.readFrame()
+    return self.__rbuf.read(sz)
+
+  def readFrame(self):
+    buff = self.__trans.readAll(4)
+    sz, = unpack('!i', buff)
+    self.__rbuf = StringIO(self.__trans.readAll(sz))
+
+  def write(self, buf):
+    self.__wbuf.write(buf)
+
+  def flush(self):
+    wout = self.__wbuf.getvalue()
+    wsz = len(wout)
+    # reset wbuf before write/flush to preserve state on underlying failure
+    self.__wbuf = StringIO()
+    # N.B.: Doing this string concatenation is WAY cheaper than making
+    # two separate calls to the underlying socket object. Socket writes in
+    # Python turn out to be REALLY expensive, but it seems to do a pretty
+    # good job of managing string buffer operations without excessive copies
+    buf = pack("!i", wsz) + wout
+    self.__trans.write(buf)
+    self.__trans.flush()
+
+  # Implement the CReadableTransport interface.
+  @property
+  def cstringio_buf(self):
+    return self.__rbuf
+
+  def cstringio_refill(self, prefix, reqlen):
+    # self.__rbuf will already be empty here because fastbinary doesn't
+    # ask for a refill until the previous buffer is empty.  Therefore,
+    # we can start reading new frames immediately.
+    while len(prefix) < reqlen:
+      self.readFrame()
+      prefix += self.__rbuf.getvalue()
+    self.__rbuf = StringIO(prefix)
+    return self.__rbuf
+
+
+class TFileObjectTransport(TTransportBase):
+  """Wraps a file-like object to make it work as a Thrift transport."""
+
+  def __init__(self, fileobj):
+    self.fileobj = fileobj
+
+  def isOpen(self):
+    return True
+
+  def close(self):
+    self.fileobj.close()
+
+  def read(self, sz):
+    return self.fileobj.read(sz)
+
+  def write(self, buf):
+    self.fileobj.write(buf)
+
+  def flush(self):
+    self.fileobj.flush()

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTransport.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTransport.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTransport.pyc
new file mode 100644
index 0000000..33fcc1c
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTransport.pyc differ

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTwisted.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTwisted.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTwisted.py
new file mode 100644
index 0000000..3ce3eb2
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TTwisted.py
@@ -0,0 +1,221 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+from cStringIO import StringIO
+
+from zope.interface import implements, Interface, Attribute
+from twisted.internet.protocol import Protocol, ServerFactory, ClientFactory, \
+    connectionDone
+from twisted.internet import defer
+from twisted.protocols import basic
+from twisted.python import log
+from twisted.web import server, resource, http
+
+from thrift.transport import TTransport
+
+
+class TMessageSenderTransport(TTransport.TTransportBase):
+
+    def __init__(self):
+        self.__wbuf = StringIO()
+
+    def write(self, buf):
+        self.__wbuf.write(buf)
+
+    def flush(self):
+        msg = self.__wbuf.getvalue()
+        self.__wbuf = StringIO()
+        self.sendMessage(msg)
+
+    def sendMessage(self, message):
+        raise NotImplementedError
+
+
+class TCallbackTransport(TMessageSenderTransport):
+
+    def __init__(self, func):
+        TMessageSenderTransport.__init__(self)
+        self.func = func
+
+    def sendMessage(self, message):
+        self.func(message)
+
+
+class ThriftClientProtocol(basic.Int32StringReceiver):
+
+    MAX_LENGTH = 2 ** 31 - 1
+
+    def __init__(self, client_class, iprot_factory, oprot_factory=None):
+        self._client_class = client_class
+        self._iprot_factory = iprot_factory
+        if oprot_factory is None:
+            self._oprot_factory = iprot_factory
+        else:
+            self._oprot_factory = oprot_factory
+
+        self.recv_map = {}
+        self.started = defer.Deferred()
+
+    def dispatch(self, msg):
+        self.sendString(msg)
+
+    def connectionMade(self):
+        tmo = TCallbackTransport(self.dispatch)
+        self.client = self._client_class(tmo, self._oprot_factory)
+        self.started.callback(self.client)
+
+    def connectionLost(self, reason=connectionDone):
+        for k, v in self.client._reqs.iteritems():
+            tex = TTransport.TTransportException(
+                type=TTransport.TTransportException.END_OF_FILE,
+                message='Connection closed')
+            v.errback(tex)
+
+    def stringReceived(self, frame):
+        tr = TTransport.TMemoryBuffer(frame)
+        iprot = self._iprot_factory.getProtocol(tr)
+        (fname, mtype, rseqid) = iprot.readMessageBegin()
+
+        try:
+            method = self.recv_map[fname]
+        except KeyError:
+            method = getattr(self.client, 'recv_' + fname)
+            self.recv_map[fname] = method
+
+        method(iprot, mtype, rseqid)
+
+
+class ThriftServerProtocol(basic.Int32StringReceiver):
+
+    MAX_LENGTH = 2 ** 31 - 1
+
+    def dispatch(self, msg):
+        self.sendString(msg)
+
+    def processError(self, error):
+        self.transport.loseConnection()
+
+    def processOk(self, _, tmo):
+        msg = tmo.getvalue()
+
+        if len(msg) > 0:
+            self.dispatch(msg)
+
+    def stringReceived(self, frame):
+        tmi = TTransport.TMemoryBuffer(frame)
+        tmo = TTransport.TMemoryBuffer()
+
+        iprot = self.factory.iprot_factory.getProtocol(tmi)
+        oprot = self.factory.oprot_factory.getProtocol(tmo)
+
+        d = self.factory.processor.process(iprot, oprot)
+        d.addCallbacks(self.processOk, self.processError,
+            callbackArgs=(tmo,))
+
+
+class IThriftServerFactory(Interface):
+
+    processor = Attribute("Thrift processor")
+
+    iprot_factory = Attribute("Input protocol factory")
+
+    oprot_factory = Attribute("Output protocol factory")
+
+
+class IThriftClientFactory(Interface):
+
+    client_class = Attribute("Thrift client class")
+
+    iprot_factory = Attribute("Input protocol factory")
+
+    oprot_factory = Attribute("Output protocol factory")
+
+
+class ThriftServerFactory(ServerFactory):
+
+    implements(IThriftServerFactory)
+
+    protocol = ThriftServerProtocol
+
+    def __init__(self, processor, iprot_factory, oprot_factory=None):
+        self.processor = processor
+        self.iprot_factory = iprot_factory
+        if oprot_factory is None:
+            self.oprot_factory = iprot_factory
+        else:
+            self.oprot_factory = oprot_factory
+
+
+class ThriftClientFactory(ClientFactory):
+
+    implements(IThriftClientFactory)
+
+    protocol = ThriftClientProtocol
+
+    def __init__(self, client_class, iprot_factory, oprot_factory=None):
+        self.client_class = client_class
+        self.iprot_factory = iprot_factory
+        if oprot_factory is None:
+            self.oprot_factory = iprot_factory
+        else:
+            self.oprot_factory = oprot_factory
+
+    def buildProtocol(self, addr):
+        p = self.protocol(self.client_class, self.iprot_factory,
+            self.oprot_factory)
+        p.factory = self
+        return p
+
+
+class ThriftResource(resource.Resource):
+
+    allowedMethods = ('POST',)
+
+    def __init__(self, processor, inputProtocolFactory,
+        outputProtocolFactory=None):
+        resource.Resource.__init__(self)
+        self.inputProtocolFactory = inputProtocolFactory
+        if outputProtocolFactory is None:
+            self.outputProtocolFactory = inputProtocolFactory
+        else:
+            self.outputProtocolFactory = outputProtocolFactory
+        self.processor = processor
+
+    def getChild(self, path, request):
+        return self
+
+    def _cbProcess(self, _, request, tmo):
+        msg = tmo.getvalue()
+        request.setResponseCode(http.OK)
+        request.setHeader("content-type", "application/x-thrift")
+        request.write(msg)
+        request.finish()
+
+    def render_POST(self, request):
+        request.content.seek(0, 0)
+        data = request.content.read()
+        tmi = TTransport.TMemoryBuffer(data)
+        tmo = TTransport.TMemoryBuffer()
+
+        iprot = self.inputProtocolFactory.getProtocol(tmi)
+        oprot = self.outputProtocolFactory.getProtocol(tmo)
+
+        d = self.processor.process(iprot, oprot)
+        d.addCallback(self._cbProcess, request, tmo)
+        return server.NOT_DONE_YET

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TZlibTransport.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TZlibTransport.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TZlibTransport.py
new file mode 100644
index 0000000..97e58b3
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/TZlibTransport.py
@@ -0,0 +1,249 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+"""TZlibTransport provides a compressed transport and transport factory
+class, using the python standard library zlib module to implement
+data compression.
+"""
+
+from __future__ import division
+import zlib
+from cStringIO import StringIO
+
+from lib.thrift.transport.TTransport import TTransportBase, CReadableTransport
+
+
+class TZlibTransportFactory(object):
+  """Factory transport that builds zlib compressed transports.
+
+  This factory caches the last single client/transport that it was passed
+  and returns the same TZlibTransport object that was created.
+
+  This caching means the TServer class will get the _same_ transport
+  object for both input and output transports from this factory.
+  (For non-threaded scenarios only, since the cache only holds one object)
+
+  The purpose of this caching is to allocate only one TZlibTransport where
+  only one is really needed (since it must have separate read/write buffers),
+  and makes the statistics from getCompSavings() and getCompRatio()
+  easier to understand.
+  """
+  # class scoped cache of last transport given and zlibtransport returned
+  _last_trans = None
+  _last_z = None
+
+  def getTransport(self, trans, compresslevel=9):
+    """Wrap a transport, trans, with the TZlibTransport
+    compressed transport class, returning a new
+    transport to the caller.
+
+    @param compresslevel: The zlib compression level, ranging
+    from 0 (no compression) to 9 (best compression).  Defaults to 9.
+    @type compresslevel: int
+
+    This method returns a TZlibTransport which wraps the
+    passed C{trans} TTransport derived instance.
+    """
+    if trans == self._last_trans:
+      return self._last_z
+    ztrans = TZlibTransport(trans, compresslevel)
+    self._last_trans = trans
+    self._last_z = ztrans
+    return ztrans
+
+
+class TZlibTransport(TTransportBase, CReadableTransport):
+  """Class that wraps a transport with zlib, compressing writes
+  and decompresses reads, using the python standard
+  library zlib module.
+  """
+  # Read buffer size for the python fastbinary C extension,
+  # the TBinaryProtocolAccelerated class.
+  DEFAULT_BUFFSIZE = 4096
+
+  def __init__(self, trans, compresslevel=9):
+    """Create a new TZlibTransport, wrapping C{trans}, another
+    TTransport derived object.
+
+    @param trans: A thrift transport object, i.e. a TSocket() object.
+    @type trans: TTransport
+    @param compresslevel: The zlib compression level, ranging
+    from 0 (no compression) to 9 (best compression).  Default is 9.
+    @type compresslevel: int
+    """
+    self.__trans = trans
+    self.compresslevel = compresslevel
+    self.__rbuf = StringIO()
+    self.__wbuf = StringIO()
+    self._init_zlib()
+    self._init_stats()
+
+  def _reinit_buffers(self):
+    """Internal method to initialize/reset the internal StringIO objects
+    for read and write buffers.
+    """
+    self.__rbuf = StringIO()
+    self.__wbuf = StringIO()
+
+  def _init_stats(self):
+    """Internal method to reset the internal statistics counters
+    for compression ratios and bandwidth savings.
+    """
+    self.bytes_in = 0
+    self.bytes_out = 0
+    self.bytes_in_comp = 0
+    self.bytes_out_comp = 0
+
+  def _init_zlib(self):
+    """Internal method for setting up the zlib compression and
+    decompression objects.
+    """
+    self._zcomp_read = zlib.decompressobj()
+    self._zcomp_write = zlib.compressobj(self.compresslevel)
+
+  def getCompRatio(self):
+    """Get the current measured compression ratios (in,out) from
+    this transport.
+
+    Returns a tuple of:
+    (inbound_compression_ratio, outbound_compression_ratio)
+
+    The compression ratios are computed as:
+        compressed / uncompressed
+
+    E.g., data that compresses by 10x will have a ratio of: 0.10
+    and data that compresses to half of ts original size will
+    have a ratio of 0.5
+
+    None is returned if no bytes have yet been processed in
+    a particular direction.
+    """
+    r_percent, w_percent = (None, None)
+    if self.bytes_in > 0:
+      r_percent = self.bytes_in_comp / self.bytes_in
+    if self.bytes_out > 0:
+      w_percent = self.bytes_out_comp / self.bytes_out
+    return (r_percent, w_percent)
+
+  def getCompSavings(self):
+    """Get the current count of saved bytes due to data
+    compression.
+
+    Returns a tuple of:
+    (inbound_saved_bytes, outbound_saved_bytes)
+
+    Note: if compression is actually expanding your
+    data (only likely with very tiny thrift objects), then
+    the values returned will be negative.
+    """
+    r_saved = self.bytes_in - self.bytes_in_comp
+    w_saved = self.bytes_out - self.bytes_out_comp
+    return (r_saved, w_saved)
+
+  def isOpen(self):
+    """Return the underlying transport's open status"""
+    return self.__trans.isOpen()
+
+  def open(self):
+    """Open the underlying transport"""
+    self._init_stats()
+    return self.__trans.open()
+
+  def listen(self):
+    """Invoke the underlying transport's listen() method"""
+    self.__trans.listen()
+
+  def accept(self):
+    """Accept connections on the underlying transport"""
+    return self.__trans.accept()
+
+  def close(self):
+    """Close the underlying transport,"""
+    self._reinit_buffers()
+    self._init_zlib()
+    return self.__trans.close()
+
+  def read(self, sz):
+    """Read up to sz bytes from the decompressed bytes buffer, and
+    read from the underlying transport if the decompression
+    buffer is empty.
+    """
+    ret = self.__rbuf.read(sz)
+    if len(ret) > 0:
+      return ret
+    # keep reading from transport until something comes back
+    while True:
+      if self.readComp(sz):
+        break
+    ret = self.__rbuf.read(sz)
+    return ret
+
+  def readComp(self, sz):
+    """Read compressed data from the underlying transport, then
+    decompress it and append it to the internal StringIO read buffer
+    """
+    zbuf = self.__trans.read(sz)
+    zbuf = self._zcomp_read.unconsumed_tail + zbuf
+    buf = self._zcomp_read.decompress(zbuf)
+    self.bytes_in += len(zbuf)
+    self.bytes_in_comp += len(buf)
+    old = self.__rbuf.read()
+    self.__rbuf = StringIO(old + buf)
+    if len(old) + len(buf) == 0:
+      return False
+    return True
+
+  def write(self, buf):
+    """Write some bytes, putting them into the internal write
+    buffer for eventual compression.
+    """
+    self.__wbuf.write(buf)
+
+  def flush(self):
+    """Flush any queued up data in the write buffer and ensure the
+    compression buffer is flushed out to the underlying transport
+    """
+    wout = self.__wbuf.getvalue()
+    if len(wout) > 0:
+      zbuf = self._zcomp_write.compress(wout)
+      self.bytes_out += len(wout)
+      self.bytes_out_comp += len(zbuf)
+    else:
+      zbuf = ''
+    ztail = self._zcomp_write.flush(zlib.Z_SYNC_FLUSH)
+    self.bytes_out_comp += len(ztail)
+    if (len(zbuf) + len(ztail)) > 0:
+      self.__wbuf = StringIO()
+      self.__trans.write(zbuf + ztail)
+    self.__trans.flush()
+
+  @property
+  def cstringio_buf(self):
+    """Implement the CReadableTransport interface"""
+    return self.__rbuf
+
+  def cstringio_refill(self, partialread, reqlen):
+    """Implement the CReadableTransport interface for refill"""
+    retstring = partialread
+    if reqlen < self.DEFAULT_BUFFSIZE:
+      retstring += self.read(self.DEFAULT_BUFFSIZE)
+    while len(retstring) < reqlen:
+      retstring += self.read(reqlen - len(retstring))
+    self.__rbuf = StringIO(retstring)
+    return self.__rbuf

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/__init__.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/__init__.py b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/__init__.py
new file mode 100644
index 0000000..c9596d9
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/__init__.py
@@ -0,0 +1,20 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+__all__ = ['TTransport', 'TSocket', 'THttpClient', 'TZlibTransport']

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/__init__.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/__init__.pyc b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/__init__.pyc
new file mode 100644
index 0000000..ef72ead
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/Admin-User/thrift/transport/__init__.pyc differ

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/.ipynb_checkpoints/create-experiment-checkpoint.ipynb
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/.ipynb_checkpoints/create-experiment-checkpoint.ipynb b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/.ipynb_checkpoints/create-experiment-checkpoint.ipynb
new file mode 100644
index 0000000..3523a80
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/.ipynb_checkpoints/create-experiment-checkpoint.ipynb
@@ -0,0 +1,449 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "import sys\n",
+    "import random\n",
+    "\n",
+    "from thrift.protocol import TBinaryProtocol\n",
+    "from thrift.transport import TSocket, TTransport, TSSLSocket\n",
+    "\n",
+    "from apache.airavata.api import Airavata\n",
+    "from apache.airavata.model.experiment.ttypes import ExperimentModel\n",
+    "from apache.airavata.model.scheduling.ttypes import ComputationalResourceSchedulingModel\n",
+    "from apache.airavata.model.experiment.ttypes import UserConfigurationDataModel\n",
+    "from apache.airavata.model.status.ttypes import ExperimentState\n",
+    "from apache.airavata.model.security.ttypes import AuthzToken\n",
+    "from apache.airavata.model.application.io.ttypes import InputDataObjectType, OutputDataObjectType\n",
+    "\n",
+    "from oauthlib.oauth2 import LegacyApplicationClient\n",
+    "from requests_oauthlib import OAuth2Session\n",
+    "from oauthlib.oauth2 import BackendApplicationClient"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Getting OAuth Access Code from IDP"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "client_id = r'XXXXXXXXXXX'\n",
+    "client_secret = r'XXXXXXXXXXXX'\n",
+    "\n",
+    "client = BackendApplicationClient(client_id=client_id)\n",
+    "oauth = OAuth2Session(client=client)\n",
+    "token = oauth.fetch_token(token_url='https://idp.scigap.org:9443/oauth2/token', client_id=client_id, client_secret=client_secret)\n",
+    "authzToken = AuthzToken(token[\"access_token\"])\n",
+    "\n",
+    "claimsMap = {\"userName\":\"admin\",\"gatewayID\": \"seagrid\"}\n",
+    "authzToken.claimsMap = claimsMap\n",
+    "\n",
+    "userName = \"admin\"\n",
+    "gatewayId = \"seagrid\""
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Creating Airavata Client"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'0.16.0'"
+      ]
+     },
+     "execution_count": 3,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "transport = TSSLSocket.TSSLSocket(\"gw56.iu.xsede.org\",9930, validate=False)\n",
+    "transport = TTransport.TBufferedTransport(transport)\n",
+    "protocol = TBinaryProtocol.TBinaryProtocol(transport)\n",
+    "airavataClient = Airavata.Client(protocol)\n",
+    "transport.open()\n",
+    "\n",
+    "#Testing the Airavata Client\n",
+    "airavataClient.getAPIVersion(authzToken)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## List User Projects"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "TestProject487543_b6ba13ff-4af5-4cf1-a5d4-9a7908cd338e\n",
+      "TestProject0398576_bb39d722-e136-41d2-89fd-a2e60e15c841\n",
+      "TestProject984752_9d011ce9-24ea-41a7-a40c-0192cbdb475f\n",
+      "TestProject81724_f4dde490-2e23-4308-b2c7-0cc2454520f0\n",
+      "TestProj5_e8b872d9-17ed-4f13-9007-40cd71df6450\n",
+      "TestProj4_ca7b95df-dd56-41b5-b112-d58b2748fc46\n",
+      "TestProj3_3ff3b1fc-70e0-4cfc-8581-b915209786a5\n",
+      "TheTestProj_397ccd77-0cb3-4c86-ba74-fb1954548085\n",
+      "TestProj_733ada60-2e88-4f52-a4f4-789c2795fc3e\n",
+      "testeroonius_61d70e07-78fc-4b82-a26b-24d37b2bd294\n",
+      "testeroonius_0e20b332-c694-4b90-9443-8403d46a1fcc\n",
+      "testeroonius_21e5f9aa-9fef-406d-9ff2-315ed7312efe\n",
+      "testeroonius_b31b789e-c61a-4eeb-828d-35edc2fcaa4b\n",
+      "testerooni_4a655ef7-b04b-4f6f-8481-216ebdb8437b\n",
+      "DefaultProject_9f56c72c-51ef-461e-bad8-6595af42b8de\n"
+     ]
+    }
+   ],
+   "source": [
+    "projects = airavataClient.getUserProjects(authzToken, gatewayId, userName, -1, 0)\n",
+    "for p in projects:\n",
+    "        print(p.projectID)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "metadata": {
+    "collapsed": true
+   },
+   "outputs": [],
+   "source": [
+    "selectedProjId = \"TestProj3_3ff3b1fc-70e0-4cfc-8581-b915209786a5\""
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## List of Applications Available in the Gateway"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Echo_3f480d1f-ea86-4018-94bb-015423d66a1c\n",
+      "Amber_Sander_27b68571-b9c0-4bd5-bd70-e29435fa81bd\n",
+      "Gaussian_377feede-4d67-4065-984f-284d05c7d32d\n",
+      "Gromacs_c56857f1-c5d5-491b-b5ac-3f8165fdfc7a\n",
+      "Abinit_69939a97-17b8-472c-bdf3-81a41de57b74\n",
+      "AutoDock_6140eb97-af55-458d-a610-0e6cfee82487\n",
+      "CP2K_e9f82e52-dd78-4733-81ef-e163443efae5\n",
+      "CPMD_2038f63a-42a2-45df-b5fb-8916c1df8fc8\n",
+      "DDSCat_7911e731-2a8f-47fa-9ec2-e97f94ddbe7a\n",
+      "DFTB+_3b6232a4-3584-42bd-a0fb-452e56fc1c97\n",
+      "Gamess_9014bed7-f6a9-4bf6-8903-3531fce6adfe\n",
+      "Gamess_BR2_4a9a65dd-d9ea-45ff-a752-44614cf78dce\n",
+      "Gamess_Stampede_b8e90ce5-81ab-42ab-be57-304f2cdeb69e\n",
+      "Gromacs_CrayMPI_579f6463-10bb-4f06-9b6c-2e43589aaed3\n",
+      "Lammps_09de4f61-45b8-4c24-90c6-ebe718958728\n",
+      "Lammps_BR2_090f5f20-bb8e-4b96-a0fa-85cea7aec2f1\n",
+      "Molcas_89d5feb0-b1f1-437a-baef-9f353debd145\n",
+      "NWChem_e21df4ce-0c8e-422b-9e79-e0e7d56fad1f\n",
+      "Qchem_5e2f490a-25da-4631-a96d-d6f428e77ad5\n",
+      "Quantum_Espresso_fa1c5f04-bc52-4e91-8fd7-dbd1bcb1e39b\n",
+      "Tinker_Monte_1afae7f3-7c02-4fc6-8c67-8378c65a88b3\n",
+      "Abaqus_dcf7df79-5564-46db-88c4-837207882fdb\n",
+      "NEK5000_8ca957b3-6037-4535-9e02-005eb7dafd2d\n",
+      "Test-Application-Interface_39f9229d-c3b6-4251-90ec-c76265aafde8\n",
+      "Tes-App-Int_3efc89dc-d03a-4abb-af33-d7f242e9c656\n",
+      "TestAppInt1_2776c902-3200-4363-ab1e-ff99adc643cf\n",
+      "Test1_9c82fb1e-54da-42e8-87ae-6e3e1b1b8951\n",
+      "AutoDock_Vina_dcb6a898-fef3-4bed-b2d3-9aad45b42131\n",
+      "TestAppInt2_458c30d2-5f29-45b9-acd8-953315c6a730\n",
+      "Phasta_P_61030007-7243-4c6c-b13c-e7287670a847\n",
+      "Vina_Multiple_85771219-f188-48da-8dfe-422eea72c1ff\n",
+      "Vina_Optional_Ligands_a32ee927-f205-49a1-9a6f-c03e4a24aefc\n",
+      "Trinity_33a4a5ab-8d69-4477-a72d-0bd0cd7f3926\n"
+     ]
+    }
+   ],
+   "source": [
+    "appInterfaces = airavataClient.getAllApplicationInterfaces(authzToken, gatewayId)\n",
+    "for interface in appInterfaces:\n",
+    "    print(interface.applicationInterfaceId)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Listing all Compute Resource with Echo App Enabled"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "selectedInterfaceId = \"Echo_3f480d1f-ea86-4018-94bb-015423d66a1c\"\n",
+    "availableCompRes = airavataClient.getAvailableAppInterfaceComputeResources(authzToken, selectedInterfaceId)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "bigred2.uits.iu.edu_ac140dca-3c88-46d8-b9ed-875d96ea6908 bigred2.uits.iu.edu\n"
+     ]
+    }
+   ],
+   "source": [
+    "for k in availableCompRes:\n",
+    "    print(k + \" \" + availableCompRes[k])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 9,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "selectedCompResId = \"bigred2.uits.iu.edu_ac140dca-3c88-46d8-b9ed-875d96ea6908\""
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Creating the Experiment Object"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 10,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "experiment = ExperimentModel()\n",
+    "experiment.experimentName = \"Simple Echo Experiment \" + str(random.random())\n",
+    "experiment.projectId = selectedProjId\n",
+    "experiment.gatewayId = gatewayId\n",
+    "experiment.userName = userName\n",
+    "experiment.description = \"Simple Echo Experiment\"\n",
+    "experiment.executionId = selectedInterfaceId"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 11,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "echoInterface = airavataClient.getApplicationInterface(authzToken, selectedInterfaceId)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 12,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "inputs = echoInterface.applicationInputs\n",
+    "inputs[0].value = \"Hello World\"\n",
+    "\n",
+    "experiment.experimentInputs = inputs\n",
+    "experiment.experimentOutputs = echoInterface.applicationOutputs"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 13,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "compResource = airavataClient.getComputeResource(authzToken, selectedCompResId)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 14,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[BatchQueue(maxJobsInQueue=0, maxNodes=128, maxRunTime=2880, maxMemory=0, queueDescription='The routing queue for all \"production\" jobs; each job is routed, based on its resource requirements, to one of the execution queues (normal, serial, or long)', maxProcessors=4096, queueName='cpu'),\n",
+       " BatchQueue(maxJobsInQueue=0, maxNodes=21824, maxRunTime=0, maxMemory=0, queueDescription='GPU queue', maxProcessors=1364, queueName='gpu')]"
+      ]
+     },
+     "execution_count": 14,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "compResource.batchQueues"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [],
+   "source": [
+    "queueName = \"cpu\"\n",
+    "\n",
+    "computationalRS = ComputationalResourceSchedulingModel()\n",
+    "computationalRS.resourceHostId = selectedCompResId\n",
+    "computationalRS.totalCPUCount = 16\n",
+    "computationalRS.nodeCount = 1\n",
+    "computationalRS.numberOfThreads = 1\n",
+    "computationalRS.queueName = queueName\n",
+    "computationalRS.wallTimeLimit = 10\n",
+    "computationalRS.totalPhysicalMemory = 1\n",
+    "\n",
+    "userConfig = UserConfigurationDataModel()\n",
+    "userConfig.airavataAutoSchedule = True\n",
+    "userConfig.overrideManualScheduledParams = False\n",
+    "userConfig.computationalResourceScheduling = computationalRS\n",
+    "\n",
+    "experiment.userConfigurationData = userConfig"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Create & Launch Experiment"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 16,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "Experiment Id is SimpleEchoExperiment0.666940363066_ed483ef9-f87f-402d-a25c-881b1d6cc6ac\n"
+     ]
+    }
+   ],
+   "source": [
+    "transport.open()\n",
+    "expId = airavataClient.createExperiment(authzToken, gatewayId, experiment)\n",
+    "print (\"Experiment Id is \" + expId)\n",
+    "airavataClient.launchExperiment(authzToken, expId, gatewayId)"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "## Retreiving Experiment Status"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 17,
+   "metadata": {
+    "collapsed": false
+   },
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "LAUNCHED\n"
+     ]
+    }
+   ],
+   "source": [
+    "transport.open()\n",
+    "status = airavataClient.getExperimentStatus(authzToken, expId)\n",
+    "print(ExperimentState._VALUES_TO_NAMES[status.state])"
+   ]
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 2",
+   "language": "python",
+   "name": "python2"
+  },
+  "language_info": {
+   "codemirror_mode": {
+    "name": "ipython",
+    "version": 2
+   },
+   "file_extension": ".py",
+   "mimetype": "text/x-python",
+   "name": "python",
+   "nbconvert_exporter": "python",
+   "pygments_lexer": "ipython2",
+   "version": "2.7.12"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 0
+}

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/__init__.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/__init__.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/__init__.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/__init__.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/__init__.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/__init__.pyc b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/__init__.pyc
new file mode 100644
index 0000000..144e9b9
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/__init__.pyc differ

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/__init__.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/__init__.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/__init__.py
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/__init__.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/__init__.pyc b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/__init__.pyc
new file mode 100644
index 0000000..ba42260
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/__init__.pyc differ