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:43 UTC
[03/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/create-experiment/apache/airavata/model/workspace/ttypes.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/model/workspace/ttypes.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/model/workspace/ttypes.py
new file mode 100644
index 0000000..1395950
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/model/workspace/ttypes.py
@@ -0,0 +1,851 @@
+#
+# Autogenerated by Thrift Compiler (0.9.3)
+#
+# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
+#
+# options string: py
+#
+
+from thrift.Thrift import TType, TMessageType, TException, TApplicationException
+import apache.airavata.model.commons.ttypes
+
+
+from thrift.transport import TTransport
+from thrift.protocol import TBinaryProtocol, TProtocol
+try:
+ from thrift.protocol import fastbinary
+except:
+ fastbinary = None
+
+
+class GatewayApprovalStatus:
+ REQUESTED = 0
+ APPROVED = 1
+ ACTIVE = 2
+ DEACTIVATED = 3
+
+ _VALUES_TO_NAMES = {
+ 0: "REQUESTED",
+ 1: "APPROVED",
+ 2: "ACTIVE",
+ 3: "DEACTIVATED",
+ }
+
+ _NAMES_TO_VALUES = {
+ "REQUESTED": 0,
+ "APPROVED": 1,
+ "ACTIVE": 2,
+ "DEACTIVATED": 3,
+ }
+
+class NotificationPriority:
+ LOW = 0
+ NORMAL = 1
+ HIGH = 2
+
+ _VALUES_TO_NAMES = {
+ 0: "LOW",
+ 1: "NORMAL",
+ 2: "HIGH",
+ }
+
+ _NAMES_TO_VALUES = {
+ "LOW": 0,
+ "NORMAL": 1,
+ "HIGH": 2,
+ }
+
+
+class Group:
+ """
+ Attributes:
+ - groupName
+ - description
+ """
+
+ thrift_spec = (
+ None, # 0
+ (1, TType.STRING, 'groupName', None, None, ), # 1
+ (2, TType.STRING, 'description', None, None, ), # 2
+ )
+
+ def __init__(self, groupName=None, description=None,):
+ self.groupName = groupName
+ self.description = description
+
+ def read(self, iprot):
+ if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+ fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+ return
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.STRING:
+ self.groupName = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 2:
+ if ftype == TType.STRING:
+ self.description = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+ oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStructBegin('Group')
+ if self.groupName is not None:
+ oprot.writeFieldBegin('groupName', TType.STRING, 1)
+ oprot.writeString(self.groupName)
+ oprot.writeFieldEnd()
+ if self.description is not None:
+ oprot.writeFieldBegin('description', TType.STRING, 2)
+ oprot.writeString(self.description)
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
+
+ def validate(self):
+ if self.groupName is None:
+ raise TProtocol.TProtocolException(message='Required field groupName is unset!')
+ return
+
+
+ def __hash__(self):
+ value = 17
+ value = (value * 31) ^ hash(self.groupName)
+ value = (value * 31) ^ hash(self.description)
+ return value
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, value)
+ for key, value in self.__dict__.iteritems()]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+ def __ne__(self, other):
+ return not (self == other)
+
+class Project:
+ """
+ Attributes:
+ - projectID
+ - owner
+ - gatewayId
+ - name
+ - description
+ - creationTime
+ - sharedUsers
+ - sharedGroups
+ """
+
+ thrift_spec = (
+ None, # 0
+ (1, TType.STRING, 'projectID', None, "DO_NOT_SET_AT_CLIENTS", ), # 1
+ (2, TType.STRING, 'owner', None, None, ), # 2
+ (3, TType.STRING, 'gatewayId', None, None, ), # 3
+ (4, TType.STRING, 'name', None, None, ), # 4
+ (5, TType.STRING, 'description', None, None, ), # 5
+ (6, TType.I64, 'creationTime', None, None, ), # 6
+ (7, TType.LIST, 'sharedUsers', (TType.STRING,None), None, ), # 7
+ (8, TType.LIST, 'sharedGroups', (TType.STRING,None), None, ), # 8
+ )
+
+ def __init__(self, projectID=thrift_spec[1][4], owner=None, gatewayId=None, name=None, description=None, creationTime=None, sharedUsers=None, sharedGroups=None,):
+ self.projectID = projectID
+ self.owner = owner
+ self.gatewayId = gatewayId
+ self.name = name
+ self.description = description
+ self.creationTime = creationTime
+ self.sharedUsers = sharedUsers
+ self.sharedGroups = sharedGroups
+
+ def read(self, iprot):
+ if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+ fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+ return
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.STRING:
+ self.projectID = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 2:
+ if ftype == TType.STRING:
+ self.owner = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 3:
+ if ftype == TType.STRING:
+ self.gatewayId = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 4:
+ if ftype == TType.STRING:
+ self.name = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 5:
+ if ftype == TType.STRING:
+ self.description = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 6:
+ if ftype == TType.I64:
+ self.creationTime = iprot.readI64()
+ else:
+ iprot.skip(ftype)
+ elif fid == 7:
+ if ftype == TType.LIST:
+ self.sharedUsers = []
+ (_etype3, _size0) = iprot.readListBegin()
+ for _i4 in xrange(_size0):
+ _elem5 = iprot.readString()
+ self.sharedUsers.append(_elem5)
+ iprot.readListEnd()
+ else:
+ iprot.skip(ftype)
+ elif fid == 8:
+ if ftype == TType.LIST:
+ self.sharedGroups = []
+ (_etype9, _size6) = iprot.readListBegin()
+ for _i10 in xrange(_size6):
+ _elem11 = iprot.readString()
+ self.sharedGroups.append(_elem11)
+ iprot.readListEnd()
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+ oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStructBegin('Project')
+ if self.projectID is not None:
+ oprot.writeFieldBegin('projectID', TType.STRING, 1)
+ oprot.writeString(self.projectID)
+ oprot.writeFieldEnd()
+ if self.owner is not None:
+ oprot.writeFieldBegin('owner', TType.STRING, 2)
+ oprot.writeString(self.owner)
+ oprot.writeFieldEnd()
+ if self.gatewayId is not None:
+ oprot.writeFieldBegin('gatewayId', TType.STRING, 3)
+ oprot.writeString(self.gatewayId)
+ oprot.writeFieldEnd()
+ if self.name is not None:
+ oprot.writeFieldBegin('name', TType.STRING, 4)
+ oprot.writeString(self.name)
+ oprot.writeFieldEnd()
+ if self.description is not None:
+ oprot.writeFieldBegin('description', TType.STRING, 5)
+ oprot.writeString(self.description)
+ oprot.writeFieldEnd()
+ if self.creationTime is not None:
+ oprot.writeFieldBegin('creationTime', TType.I64, 6)
+ oprot.writeI64(self.creationTime)
+ oprot.writeFieldEnd()
+ if self.sharedUsers is not None:
+ oprot.writeFieldBegin('sharedUsers', TType.LIST, 7)
+ oprot.writeListBegin(TType.STRING, len(self.sharedUsers))
+ for iter12 in self.sharedUsers:
+ oprot.writeString(iter12)
+ oprot.writeListEnd()
+ oprot.writeFieldEnd()
+ if self.sharedGroups is not None:
+ oprot.writeFieldBegin('sharedGroups', TType.LIST, 8)
+ oprot.writeListBegin(TType.STRING, len(self.sharedGroups))
+ for iter13 in self.sharedGroups:
+ oprot.writeString(iter13)
+ oprot.writeListEnd()
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
+
+ def validate(self):
+ if self.projectID is None:
+ raise TProtocol.TProtocolException(message='Required field projectID is unset!')
+ if self.owner is None:
+ raise TProtocol.TProtocolException(message='Required field owner is unset!')
+ if self.gatewayId is None:
+ raise TProtocol.TProtocolException(message='Required field gatewayId is unset!')
+ if self.name is None:
+ raise TProtocol.TProtocolException(message='Required field name is unset!')
+ return
+
+
+ def __hash__(self):
+ value = 17
+ value = (value * 31) ^ hash(self.projectID)
+ value = (value * 31) ^ hash(self.owner)
+ value = (value * 31) ^ hash(self.gatewayId)
+ value = (value * 31) ^ hash(self.name)
+ value = (value * 31) ^ hash(self.description)
+ value = (value * 31) ^ hash(self.creationTime)
+ value = (value * 31) ^ hash(self.sharedUsers)
+ value = (value * 31) ^ hash(self.sharedGroups)
+ return value
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, value)
+ for key, value in self.__dict__.iteritems()]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+ def __ne__(self, other):
+ return not (self == other)
+
+class User:
+ """
+ Attributes:
+ - airavataInternalUserId
+ - userName
+ - gatewayId
+ - firstName
+ - lastName
+ - email
+ """
+
+ thrift_spec = (
+ None, # 0
+ (1, TType.STRING, 'airavataInternalUserId', None, "DO_NOT_SET_AT_CLIENTS", ), # 1
+ (2, TType.STRING, 'userName', None, None, ), # 2
+ (3, TType.STRING, 'gatewayId', None, None, ), # 3
+ (4, TType.STRING, 'firstName', None, None, ), # 4
+ (5, TType.STRING, 'lastName', None, None, ), # 5
+ (6, TType.STRING, 'email', None, None, ), # 6
+ )
+
+ def __init__(self, airavataInternalUserId=thrift_spec[1][4], userName=None, gatewayId=None, firstName=None, lastName=None, email=None,):
+ self.airavataInternalUserId = airavataInternalUserId
+ self.userName = userName
+ self.gatewayId = gatewayId
+ self.firstName = firstName
+ self.lastName = lastName
+ self.email = email
+
+ def read(self, iprot):
+ if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+ fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+ return
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.STRING:
+ self.airavataInternalUserId = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 2:
+ if ftype == TType.STRING:
+ self.userName = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 3:
+ if ftype == TType.STRING:
+ self.gatewayId = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 4:
+ if ftype == TType.STRING:
+ self.firstName = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 5:
+ if ftype == TType.STRING:
+ self.lastName = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 6:
+ if ftype == TType.STRING:
+ self.email = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+ oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStructBegin('User')
+ if self.airavataInternalUserId is not None:
+ oprot.writeFieldBegin('airavataInternalUserId', TType.STRING, 1)
+ oprot.writeString(self.airavataInternalUserId)
+ oprot.writeFieldEnd()
+ if self.userName is not None:
+ oprot.writeFieldBegin('userName', TType.STRING, 2)
+ oprot.writeString(self.userName)
+ oprot.writeFieldEnd()
+ if self.gatewayId is not None:
+ oprot.writeFieldBegin('gatewayId', TType.STRING, 3)
+ oprot.writeString(self.gatewayId)
+ oprot.writeFieldEnd()
+ if self.firstName is not None:
+ oprot.writeFieldBegin('firstName', TType.STRING, 4)
+ oprot.writeString(self.firstName)
+ oprot.writeFieldEnd()
+ if self.lastName is not None:
+ oprot.writeFieldBegin('lastName', TType.STRING, 5)
+ oprot.writeString(self.lastName)
+ oprot.writeFieldEnd()
+ if self.email is not None:
+ oprot.writeFieldBegin('email', TType.STRING, 6)
+ oprot.writeString(self.email)
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
+
+ def validate(self):
+ if self.airavataInternalUserId is None:
+ raise TProtocol.TProtocolException(message='Required field airavataInternalUserId is unset!')
+ if self.gatewayId is None:
+ raise TProtocol.TProtocolException(message='Required field gatewayId is unset!')
+ return
+
+
+ def __hash__(self):
+ value = 17
+ value = (value * 31) ^ hash(self.airavataInternalUserId)
+ value = (value * 31) ^ hash(self.userName)
+ value = (value * 31) ^ hash(self.gatewayId)
+ value = (value * 31) ^ hash(self.firstName)
+ value = (value * 31) ^ hash(self.lastName)
+ value = (value * 31) ^ hash(self.email)
+ return value
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, value)
+ for key, value in self.__dict__.iteritems()]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+ def __ne__(self, other):
+ return not (self == other)
+
+class Gateway:
+ """
+ Attributes:
+ - gatewayId
+ - gatewayApprovalStatus
+ - gatewayName
+ - domain
+ - emailAddress
+ - gatewayAcronym
+ - gatewayURL
+ - gatewayPublicAbstract
+ - reviewProposalDescription
+ - gatewayAdminFirstName
+ - gatewayAdminLastName
+ - gatewayAdminEmail
+ - identityServerUserName
+ - identityServerPasswordToken
+ """
+
+ thrift_spec = (
+ None, # 0
+ (1, TType.STRING, 'gatewayId', None, None, ), # 1
+ (2, TType.I32, 'gatewayApprovalStatus', None, None, ), # 2
+ (3, TType.STRING, 'gatewayName', None, None, ), # 3
+ (4, TType.STRING, 'domain', None, None, ), # 4
+ (5, TType.STRING, 'emailAddress', None, None, ), # 5
+ (6, TType.STRING, 'gatewayAcronym', None, None, ), # 6
+ (7, TType.STRING, 'gatewayURL', None, None, ), # 7
+ (8, TType.STRING, 'gatewayPublicAbstract', None, None, ), # 8
+ (9, TType.STRING, 'reviewProposalDescription', None, None, ), # 9
+ (10, TType.STRING, 'gatewayAdminFirstName', None, None, ), # 10
+ (11, TType.STRING, 'gatewayAdminLastName', None, None, ), # 11
+ (12, TType.STRING, 'gatewayAdminEmail', None, None, ), # 12
+ (13, TType.STRING, 'identityServerUserName', None, None, ), # 13
+ (14, TType.STRING, 'identityServerPasswordToken', None, None, ), # 14
+ )
+
+ def __init__(self, gatewayId=None, gatewayApprovalStatus=None, gatewayName=None, domain=None, emailAddress=None, gatewayAcronym=None, gatewayURL=None, gatewayPublicAbstract=None, reviewProposalDescription=None, gatewayAdminFirstName=None, gatewayAdminLastName=None, gatewayAdminEmail=None, identityServerUserName=None, identityServerPasswordToken=None,):
+ self.gatewayId = gatewayId
+ self.gatewayApprovalStatus = gatewayApprovalStatus
+ self.gatewayName = gatewayName
+ self.domain = domain
+ self.emailAddress = emailAddress
+ self.gatewayAcronym = gatewayAcronym
+ self.gatewayURL = gatewayURL
+ self.gatewayPublicAbstract = gatewayPublicAbstract
+ self.reviewProposalDescription = reviewProposalDescription
+ self.gatewayAdminFirstName = gatewayAdminFirstName
+ self.gatewayAdminLastName = gatewayAdminLastName
+ self.gatewayAdminEmail = gatewayAdminEmail
+ self.identityServerUserName = identityServerUserName
+ self.identityServerPasswordToken = identityServerPasswordToken
+
+ def read(self, iprot):
+ if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+ fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+ return
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.STRING:
+ self.gatewayId = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 2:
+ if ftype == TType.I32:
+ self.gatewayApprovalStatus = iprot.readI32()
+ else:
+ iprot.skip(ftype)
+ elif fid == 3:
+ if ftype == TType.STRING:
+ self.gatewayName = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 4:
+ if ftype == TType.STRING:
+ self.domain = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 5:
+ if ftype == TType.STRING:
+ self.emailAddress = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 6:
+ if ftype == TType.STRING:
+ self.gatewayAcronym = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 7:
+ if ftype == TType.STRING:
+ self.gatewayURL = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 8:
+ if ftype == TType.STRING:
+ self.gatewayPublicAbstract = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 9:
+ if ftype == TType.STRING:
+ self.reviewProposalDescription = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 10:
+ if ftype == TType.STRING:
+ self.gatewayAdminFirstName = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 11:
+ if ftype == TType.STRING:
+ self.gatewayAdminLastName = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 12:
+ if ftype == TType.STRING:
+ self.gatewayAdminEmail = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 13:
+ if ftype == TType.STRING:
+ self.identityServerUserName = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 14:
+ if ftype == TType.STRING:
+ self.identityServerPasswordToken = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+ oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStructBegin('Gateway')
+ if self.gatewayId is not None:
+ oprot.writeFieldBegin('gatewayId', TType.STRING, 1)
+ oprot.writeString(self.gatewayId)
+ oprot.writeFieldEnd()
+ if self.gatewayApprovalStatus is not None:
+ oprot.writeFieldBegin('gatewayApprovalStatus', TType.I32, 2)
+ oprot.writeI32(self.gatewayApprovalStatus)
+ oprot.writeFieldEnd()
+ if self.gatewayName is not None:
+ oprot.writeFieldBegin('gatewayName', TType.STRING, 3)
+ oprot.writeString(self.gatewayName)
+ oprot.writeFieldEnd()
+ if self.domain is not None:
+ oprot.writeFieldBegin('domain', TType.STRING, 4)
+ oprot.writeString(self.domain)
+ oprot.writeFieldEnd()
+ if self.emailAddress is not None:
+ oprot.writeFieldBegin('emailAddress', TType.STRING, 5)
+ oprot.writeString(self.emailAddress)
+ oprot.writeFieldEnd()
+ if self.gatewayAcronym is not None:
+ oprot.writeFieldBegin('gatewayAcronym', TType.STRING, 6)
+ oprot.writeString(self.gatewayAcronym)
+ oprot.writeFieldEnd()
+ if self.gatewayURL is not None:
+ oprot.writeFieldBegin('gatewayURL', TType.STRING, 7)
+ oprot.writeString(self.gatewayURL)
+ oprot.writeFieldEnd()
+ if self.gatewayPublicAbstract is not None:
+ oprot.writeFieldBegin('gatewayPublicAbstract', TType.STRING, 8)
+ oprot.writeString(self.gatewayPublicAbstract)
+ oprot.writeFieldEnd()
+ if self.reviewProposalDescription is not None:
+ oprot.writeFieldBegin('reviewProposalDescription', TType.STRING, 9)
+ oprot.writeString(self.reviewProposalDescription)
+ oprot.writeFieldEnd()
+ if self.gatewayAdminFirstName is not None:
+ oprot.writeFieldBegin('gatewayAdminFirstName', TType.STRING, 10)
+ oprot.writeString(self.gatewayAdminFirstName)
+ oprot.writeFieldEnd()
+ if self.gatewayAdminLastName is not None:
+ oprot.writeFieldBegin('gatewayAdminLastName', TType.STRING, 11)
+ oprot.writeString(self.gatewayAdminLastName)
+ oprot.writeFieldEnd()
+ if self.gatewayAdminEmail is not None:
+ oprot.writeFieldBegin('gatewayAdminEmail', TType.STRING, 12)
+ oprot.writeString(self.gatewayAdminEmail)
+ oprot.writeFieldEnd()
+ if self.identityServerUserName is not None:
+ oprot.writeFieldBegin('identityServerUserName', TType.STRING, 13)
+ oprot.writeString(self.identityServerUserName)
+ oprot.writeFieldEnd()
+ if self.identityServerPasswordToken is not None:
+ oprot.writeFieldBegin('identityServerPasswordToken', TType.STRING, 14)
+ oprot.writeString(self.identityServerPasswordToken)
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
+
+ def validate(self):
+ if self.gatewayId is None:
+ raise TProtocol.TProtocolException(message='Required field gatewayId is unset!')
+ if self.gatewayApprovalStatus is None:
+ raise TProtocol.TProtocolException(message='Required field gatewayApprovalStatus is unset!')
+ return
+
+
+ def __hash__(self):
+ value = 17
+ value = (value * 31) ^ hash(self.gatewayId)
+ value = (value * 31) ^ hash(self.gatewayApprovalStatus)
+ value = (value * 31) ^ hash(self.gatewayName)
+ value = (value * 31) ^ hash(self.domain)
+ value = (value * 31) ^ hash(self.emailAddress)
+ value = (value * 31) ^ hash(self.gatewayAcronym)
+ value = (value * 31) ^ hash(self.gatewayURL)
+ value = (value * 31) ^ hash(self.gatewayPublicAbstract)
+ value = (value * 31) ^ hash(self.reviewProposalDescription)
+ value = (value * 31) ^ hash(self.gatewayAdminFirstName)
+ value = (value * 31) ^ hash(self.gatewayAdminLastName)
+ value = (value * 31) ^ hash(self.gatewayAdminEmail)
+ value = (value * 31) ^ hash(self.identityServerUserName)
+ value = (value * 31) ^ hash(self.identityServerPasswordToken)
+ return value
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, value)
+ for key, value in self.__dict__.iteritems()]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+ def __ne__(self, other):
+ return not (self == other)
+
+class Notification:
+ """
+ Attributes:
+ - notificationId
+ - gatewayId
+ - title
+ - notificationMessage
+ - creationTime
+ - publishedTime
+ - expirationTime
+ - priority
+ """
+
+ thrift_spec = (
+ None, # 0
+ (1, TType.STRING, 'notificationId', None, None, ), # 1
+ (2, TType.STRING, 'gatewayId', None, None, ), # 2
+ (3, TType.STRING, 'title', None, None, ), # 3
+ (4, TType.STRING, 'notificationMessage', None, None, ), # 4
+ (5, TType.I64, 'creationTime', None, None, ), # 5
+ (6, TType.I64, 'publishedTime', None, None, ), # 6
+ (7, TType.I64, 'expirationTime', None, None, ), # 7
+ (8, TType.I32, 'priority', None, None, ), # 8
+ )
+
+ def __init__(self, notificationId=None, gatewayId=None, title=None, notificationMessage=None, creationTime=None, publishedTime=None, expirationTime=None, priority=None,):
+ self.notificationId = notificationId
+ self.gatewayId = gatewayId
+ self.title = title
+ self.notificationMessage = notificationMessage
+ self.creationTime = creationTime
+ self.publishedTime = publishedTime
+ self.expirationTime = expirationTime
+ self.priority = priority
+
+ def read(self, iprot):
+ if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
+ fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
+ return
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.STRING:
+ self.notificationId = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 2:
+ if ftype == TType.STRING:
+ self.gatewayId = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 3:
+ if ftype == TType.STRING:
+ self.title = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 4:
+ if ftype == TType.STRING:
+ self.notificationMessage = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 5:
+ if ftype == TType.I64:
+ self.creationTime = iprot.readI64()
+ else:
+ iprot.skip(ftype)
+ elif fid == 6:
+ if ftype == TType.I64:
+ self.publishedTime = iprot.readI64()
+ else:
+ iprot.skip(ftype)
+ elif fid == 7:
+ if ftype == TType.I64:
+ self.expirationTime = iprot.readI64()
+ else:
+ iprot.skip(ftype)
+ elif fid == 8:
+ if ftype == TType.I32:
+ self.priority = iprot.readI32()
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
+ oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStructBegin('Notification')
+ if self.notificationId is not None:
+ oprot.writeFieldBegin('notificationId', TType.STRING, 1)
+ oprot.writeString(self.notificationId)
+ oprot.writeFieldEnd()
+ if self.gatewayId is not None:
+ oprot.writeFieldBegin('gatewayId', TType.STRING, 2)
+ oprot.writeString(self.gatewayId)
+ oprot.writeFieldEnd()
+ if self.title is not None:
+ oprot.writeFieldBegin('title', TType.STRING, 3)
+ oprot.writeString(self.title)
+ oprot.writeFieldEnd()
+ if self.notificationMessage is not None:
+ oprot.writeFieldBegin('notificationMessage', TType.STRING, 4)
+ oprot.writeString(self.notificationMessage)
+ oprot.writeFieldEnd()
+ if self.creationTime is not None:
+ oprot.writeFieldBegin('creationTime', TType.I64, 5)
+ oprot.writeI64(self.creationTime)
+ oprot.writeFieldEnd()
+ if self.publishedTime is not None:
+ oprot.writeFieldBegin('publishedTime', TType.I64, 6)
+ oprot.writeI64(self.publishedTime)
+ oprot.writeFieldEnd()
+ if self.expirationTime is not None:
+ oprot.writeFieldBegin('expirationTime', TType.I64, 7)
+ oprot.writeI64(self.expirationTime)
+ oprot.writeFieldEnd()
+ if self.priority is not None:
+ oprot.writeFieldBegin('priority', TType.I32, 8)
+ oprot.writeI32(self.priority)
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
+
+ def validate(self):
+ if self.gatewayId is None:
+ raise TProtocol.TProtocolException(message='Required field gatewayId is unset!')
+ if self.title is None:
+ raise TProtocol.TProtocolException(message='Required field title is unset!')
+ if self.notificationMessage is None:
+ raise TProtocol.TProtocolException(message='Required field notificationMessage is unset!')
+ return
+
+
+ def __hash__(self):
+ value = 17
+ value = (value * 31) ^ hash(self.notificationId)
+ value = (value * 31) ^ hash(self.gatewayId)
+ value = (value * 31) ^ hash(self.title)
+ value = (value * 31) ^ hash(self.notificationMessage)
+ value = (value * 31) ^ hash(self.creationTime)
+ value = (value * 31) ^ hash(self.publishedTime)
+ value = (value * 31) ^ hash(self.expirationTime)
+ value = (value * 31) ^ hash(self.priority)
+ return value
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, value)
+ for key, value in self.__dict__.iteritems()]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ return isinstance(other, self.__class__) and self.__dict__ == other.__dict__
+
+ def __ne__(self, other):
+ return not (self == other)
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/model/workspace/ttypes.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/model/workspace/ttypes.pyc b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/model/workspace/ttypes.pyc
new file mode 100644
index 0000000..c9050e3
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/apache/airavata/model/workspace/ttypes.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/create-experiment.ipynb
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/create-experiment.ipynb b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/create-experiment.ipynb
new file mode 100644
index 0000000..3523a80
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/create-experiment.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/thrift/TSCons.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TSCons.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TSCons.py
new file mode 100644
index 0000000..da8d283
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TSCons.py
@@ -0,0 +1,35 @@
+#
+# 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 os import path
+from SCons.Builder import Builder
+
+
+def scons_env(env, add=''):
+ opath = path.dirname(path.abspath('$TARGET'))
+ lstr = 'thrift --gen cpp -o ' + opath + ' ' + add + ' $SOURCE'
+ cppbuild = Builder(action=lstr)
+ env.Append(BUILDERS={'ThriftCpp': cppbuild})
+
+
+def gen_cpp(env, dir, file):
+ scons_env(env)
+ suffixes = ['_types.h', '_types.cpp']
+ targets = map(lambda s: 'gen-cpp/' + file + s, suffixes)
+ return env.ThriftCpp(targets, dir + file + '.thrift')
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TSerialization.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TSerialization.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TSerialization.py
new file mode 100644
index 0000000..54f10e2
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TSerialization.py
@@ -0,0 +1,38 @@
+#
+# 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 lib.thrift.protocol import TBinaryProtocol
+from lib.thrift.transport import TTransport
+
+
+def serialize(thrift_object,
+ protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()):
+ transport = TTransport.TMemoryBuffer()
+ protocol = protocol_factory.getProtocol(transport)
+ thrift_object.write(protocol)
+ return transport.getvalue()
+
+
+def deserialize(base,
+ buf,
+ protocol_factory=TBinaryProtocol.TBinaryProtocolFactory()):
+ transport = TTransport.TMemoryBuffer(buf)
+ protocol = protocol_factory.getProtocol(transport)
+ base.read(protocol)
+ return base
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TTornado.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TTornado.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TTornado.py
new file mode 100644
index 0000000..af309c3
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/TTornado.py
@@ -0,0 +1,153 @@
+#
+# 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
+import logging
+import socket
+import struct
+
+from thrift.transport import TTransport
+from thrift.transport.TTransport import TTransportException
+
+from tornado import gen
+from tornado import iostream
+from tornado import netutil
+
+
+class TTornadoStreamTransport(TTransport.TTransportBase):
+ """a framed, buffered transport over a Tornado stream"""
+ def __init__(self, host, port, stream=None):
+ self.host = host
+ self.port = port
+ self.is_queuing_reads = False
+ self.read_queue = []
+ self.__wbuf = StringIO()
+
+ # servers provide a ready-to-go stream
+ self.stream = stream
+ if self.stream is not None:
+ self._set_close_callback()
+
+ # not the same number of parameters as TTransportBase.open
+ def open(self, callback):
+ logging.debug('socket connecting')
+ sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM, 0)
+ self.stream = iostream.IOStream(sock)
+
+ def on_close_in_connect(*_):
+ message = 'could not connect to {}:{}'.format(self.host, self.port)
+ raise TTransportException(
+ type=TTransportException.NOT_OPEN,
+ message=message)
+ self.stream.set_close_callback(on_close_in_connect)
+
+ def finish(*_):
+ self._set_close_callback()
+ callback()
+
+ self.stream.connect((self.host, self.port), callback=finish)
+
+ def _set_close_callback(self):
+ def on_close():
+ raise TTransportException(
+ type=TTransportException.END_OF_FILE,
+ message='socket closed')
+ self.stream.set_close_callback(self.close)
+
+ def close(self):
+ # don't raise if we intend to close
+ self.stream.set_close_callback(None)
+ self.stream.close()
+
+ def read(self, _):
+ # The generated code for Tornado shouldn't do individual reads -- only
+ # frames at a time
+ assert "you're doing it wrong" is True
+
+ @gen.engine
+ def readFrame(self, callback):
+ self.read_queue.append(callback)
+ logging.debug('read queue: %s', self.read_queue)
+
+ if self.is_queuing_reads:
+ # If a read is already in flight, then the while loop below should
+ # pull it from self.read_queue
+ return
+
+ self.is_queuing_reads = True
+ while self.read_queue:
+ next_callback = self.read_queue.pop()
+ result = yield gen.Task(self._readFrameFromStream)
+ next_callback(result)
+ self.is_queuing_reads = False
+
+ @gen.engine
+ def _readFrameFromStream(self, callback):
+ logging.debug('_readFrameFromStream')
+ frame_header = yield gen.Task(self.stream.read_bytes, 4)
+ frame_length, = struct.unpack('!i', frame_header)
+ logging.debug('received frame header, frame length = %i', frame_length)
+ frame = yield gen.Task(self.stream.read_bytes, frame_length)
+ logging.debug('received frame payload')
+ callback(frame)
+
+ def write(self, buf):
+ self.__wbuf.write(buf)
+
+ def flush(self, callback=None):
+ 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 = struct.pack("!i", wsz) + wout
+
+ logging.debug('writing frame length = %i', wsz)
+ self.stream.write(buf, callback)
+
+
+class TTornadoServer(netutil.TCPServer):
+ def __init__(self, processor, iprot_factory, oprot_factory=None,
+ *args, **kwargs):
+ super(TTornadoServer, self).__init__(*args, **kwargs)
+
+ self._processor = processor
+ self._iprot_factory = iprot_factory
+ self._oprot_factory = (oprot_factory if oprot_factory is not None
+ else iprot_factory)
+
+ def handle_stream(self, stream, address):
+ try:
+ host, port = address
+ trans = TTornadoStreamTransport(host=host, port=port, stream=stream)
+ oprot = self._oprot_factory.getProtocol(trans)
+
+ def next_pass():
+ if not trans.stream.closed():
+ self._processor.process(trans, self._iprot_factory, oprot,
+ callback=next_pass)
+
+ next_pass()
+
+ except Exception:
+ logging.exception('thrift exception in handle_stream')
+ trans.close()
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/Thrift.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/Thrift.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/Thrift.py
new file mode 100644
index 0000000..9890af7
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/Thrift.py
@@ -0,0 +1,170 @@
+#
+# 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 sys
+
+
+class TType:
+ STOP = 0
+ VOID = 1
+ BOOL = 2
+ BYTE = 3
+ I08 = 3
+ DOUBLE = 4
+ I16 = 6
+ I32 = 8
+ I64 = 10
+ STRING = 11
+ UTF7 = 11
+ STRUCT = 12
+ MAP = 13
+ SET = 14
+ LIST = 15
+ UTF8 = 16
+ UTF16 = 17
+
+ _VALUES_TO_NAMES = ('STOP',
+ 'VOID',
+ 'BOOL',
+ 'BYTE',
+ 'DOUBLE',
+ None,
+ 'I16',
+ None,
+ 'I32',
+ None,
+ 'I64',
+ 'STRING',
+ 'STRUCT',
+ 'MAP',
+ 'SET',
+ 'LIST',
+ 'UTF8',
+ 'UTF16')
+
+
+class TMessageType:
+ CALL = 1
+ REPLY = 2
+ EXCEPTION = 3
+ ONEWAY = 4
+
+
+class TProcessor:
+ """Base class for procsessor, which works on two streams."""
+
+ def process(iprot, oprot):
+ pass
+
+
+class TException(Exception):
+ """Base class for all thrift exceptions."""
+
+ # BaseException.message is deprecated in Python v[2.6,3.0)
+ if (2, 6, 0) <= sys.version_info < (3, 0):
+ def _get_message(self):
+ return self._message
+
+ def _set_message(self, message):
+ self._message = message
+ message = property(_get_message, _set_message)
+
+ def __init__(self, message=None):
+ Exception.__init__(self, message)
+ self.message = message
+
+
+class TApplicationException(TException):
+ """Application level thrift exceptions."""
+
+ UNKNOWN = 0
+ UNKNOWN_METHOD = 1
+ INVALID_MESSAGE_TYPE = 2
+ WRONG_METHOD_NAME = 3
+ BAD_SEQUENCE_ID = 4
+ MISSING_RESULT = 5
+ INTERNAL_ERROR = 6
+ PROTOCOL_ERROR = 7
+ INVALID_TRANSFORM = 8
+ INVALID_PROTOCOL = 9
+ UNSUPPORTED_CLIENT_TYPE = 10
+
+ def __init__(self, type=UNKNOWN, message=None):
+ TException.__init__(self, message)
+ self.type = type
+
+ def __str__(self):
+ if self.message:
+ return self.message
+ elif self.type == self.UNKNOWN_METHOD:
+ return 'Unknown method'
+ elif self.type == self.INVALID_MESSAGE_TYPE:
+ return 'Invalid message type'
+ elif self.type == self.WRONG_METHOD_NAME:
+ return 'Wrong method name'
+ elif self.type == self.BAD_SEQUENCE_ID:
+ return 'Bad sequence ID'
+ elif self.type == self.MISSING_RESULT:
+ return 'Missing result'
+ elif self.type == self.INTERNAL_ERROR:
+ return 'Internal error'
+ elif self.type == self.PROTOCOL_ERROR:
+ return 'Protocol error'
+ elif self.type == self.INVALID_TRANSFORM:
+ return 'Invalid transform'
+ elif self.type == self.INVALID_PROTOCOL:
+ return 'Invalid protocol'
+ elif self.type == self.UNSUPPORTED_CLIENT_TYPE:
+ return 'Unsupported client type'
+ else:
+ return 'Default (unknown) TApplicationException'
+
+ def read(self, iprot):
+ iprot.readStructBegin()
+ while True:
+ (fname, ftype, fid) = iprot.readFieldBegin()
+ if ftype == TType.STOP:
+ break
+ if fid == 1:
+ if ftype == TType.STRING:
+ self.message = iprot.readString()
+ else:
+ iprot.skip(ftype)
+ elif fid == 2:
+ if ftype == TType.I32:
+ self.type = iprot.readI32()
+ else:
+ iprot.skip(ftype)
+ else:
+ iprot.skip(ftype)
+ iprot.readFieldEnd()
+ iprot.readStructEnd()
+
+ def write(self, oprot):
+ oprot.writeStructBegin('TApplicationException')
+ if self.message is not None:
+ oprot.writeFieldBegin('message', TType.STRING, 1)
+ oprot.writeString(self.message)
+ oprot.writeFieldEnd()
+ if self.type is not None:
+ oprot.writeFieldBegin('type', TType.I32, 2)
+ oprot.writeI32(self.type)
+ oprot.writeFieldEnd()
+ oprot.writeFieldStop()
+ oprot.writeStructEnd()
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/Thrift.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/Thrift.pyc b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/Thrift.pyc
new file mode 100644
index 0000000..829e502
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/Thrift.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/__init__.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/__init__.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/__init__.py
new file mode 100644
index 0000000..48d659c
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/__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__ = ['Thrift', 'TSCons']
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/__init__.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/__init__.pyc b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/__init__.pyc
new file mode 100644
index 0000000..f8f5649
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/__init__.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBase.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBase.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBase.py
new file mode 100644
index 0000000..6cbd5f3
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBase.py
@@ -0,0 +1,81 @@
+#
+# 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 thrift.Thrift import *
+from thrift.protocol import TBinaryProtocol
+from thrift.transport import TTransport
+
+try:
+ from thrift.protocol import fastbinary
+except:
+ fastbinary = None
+
+
+class TBase(object):
+ __slots__ = []
+
+ def __repr__(self):
+ L = ['%s=%r' % (key, getattr(self, key))
+ for key in self.__slots__]
+ return '%s(%s)' % (self.__class__.__name__, ', '.join(L))
+
+ def __eq__(self, other):
+ if not isinstance(other, self.__class__):
+ return False
+ for attr in self.__slots__:
+ my_val = getattr(self, attr)
+ other_val = getattr(other, attr)
+ if my_val != other_val:
+ return False
+ return True
+
+ def __ne__(self, other):
+ return not (self == other)
+
+ def read(self, iprot):
+ if (iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and
+ isinstance(iprot.trans, TTransport.CReadableTransport) and
+ self.thrift_spec is not None and
+ fastbinary is not None):
+ fastbinary.decode_binary(self,
+ iprot.trans,
+ (self.__class__, self.thrift_spec))
+ return
+ iprot.readStruct(self, self.thrift_spec)
+
+ def write(self, oprot):
+ if (oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and
+ self.thrift_spec is not None and
+ fastbinary is not None):
+ oprot.trans.write(
+ fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
+ return
+ oprot.writeStruct(self, self.thrift_spec)
+
+
+class TExceptionBase(Exception):
+ # old style class so python2.4 can raise exceptions derived from this
+ # This can't inherit from TBase because of that limitation.
+ __slots__ = []
+
+ __repr__ = TBase.__repr__.im_func
+ __eq__ = TBase.__eq__.im_func
+ __ne__ = TBase.__ne__.im_func
+ read = TBase.read.im_func
+ write = TBase.write.im_func
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBinaryProtocol.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBinaryProtocol.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBinaryProtocol.py
new file mode 100644
index 0000000..17a600f
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBinaryProtocol.py
@@ -0,0 +1,261 @@
+#
+# 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 struct import pack, unpack
+
+from thrift.protocol.TProtocol import *
+
+
+class TBinaryProtocol(TProtocolBase):
+ """Binary implementation of the Thrift protocol driver."""
+
+ # NastyHaxx. Python 2.4+ on 32-bit machines forces hex constants to be
+ # positive, converting this into a long. If we hardcode the int value
+ # instead it'll stay in 32 bit-land.
+
+ # VERSION_MASK = 0xffff0000
+ VERSION_MASK = -65536
+
+ # VERSION_1 = 0x80010000
+ VERSION_1 = -2147418112
+
+ TYPE_MASK = 0x000000ff
+
+ def __init__(self, trans, strictRead=False, strictWrite=True):
+ TProtocolBase.__init__(self, trans)
+ self.strictRead = strictRead
+ self.strictWrite = strictWrite
+
+ def writeMessageBegin(self, name, type, seqid):
+ if self.strictWrite:
+ self.writeI32(TBinaryProtocol.VERSION_1 | type)
+ self.writeString(name)
+ self.writeI32(seqid)
+ else:
+ self.writeString(name)
+ self.writeByte(type)
+ self.writeI32(seqid)
+
+ def writeMessageEnd(self):
+ pass
+
+ def writeStructBegin(self, name):
+ pass
+
+ def writeStructEnd(self):
+ pass
+
+ def writeFieldBegin(self, name, type, id):
+ self.writeByte(type)
+ self.writeI16(id)
+
+ def writeFieldEnd(self):
+ pass
+
+ def writeFieldStop(self):
+ self.writeByte(TType.STOP)
+
+ def writeMapBegin(self, ktype, vtype, size):
+ self.writeByte(ktype)
+ self.writeByte(vtype)
+ self.writeI32(size)
+
+ def writeMapEnd(self):
+ pass
+
+ def writeListBegin(self, etype, size):
+ self.writeByte(etype)
+ self.writeI32(size)
+
+ def writeListEnd(self):
+ pass
+
+ def writeSetBegin(self, etype, size):
+ self.writeByte(etype)
+ self.writeI32(size)
+
+ def writeSetEnd(self):
+ pass
+
+ def writeBool(self, bool):
+ if bool:
+ self.writeByte(1)
+ else:
+ self.writeByte(0)
+
+ def writeByte(self, byte):
+ buff = pack("!b", byte)
+ self.trans.write(buff)
+
+ def writeI16(self, i16):
+ buff = pack("!h", i16)
+ self.trans.write(buff)
+
+ def writeI32(self, i32):
+ buff = pack("!i", i32)
+ self.trans.write(buff)
+
+ def writeI64(self, i64):
+ buff = pack("!q", i64)
+ self.trans.write(buff)
+
+ def writeDouble(self, dub):
+ buff = pack("!d", dub)
+ self.trans.write(buff)
+
+ def writeString(self, str):
+ self.writeI32(len(str))
+ self.trans.write(str)
+
+ def readMessageBegin(self):
+ sz = self.readI32()
+ if sz < 0:
+ version = sz & TBinaryProtocol.VERSION_MASK
+ if version != TBinaryProtocol.VERSION_1:
+ raise TProtocolException(
+ type=TProtocolException.BAD_VERSION,
+ message='Bad version in readMessageBegin: %d' % (sz))
+ type = sz & TBinaryProtocol.TYPE_MASK
+ name = self.readString()
+ seqid = self.readI32()
+ else:
+ if self.strictRead:
+ raise TProtocolException(type=TProtocolException.BAD_VERSION,
+ message='No protocol version header')
+ name = self.trans.readAll(sz)
+ type = self.readByte()
+ seqid = self.readI32()
+ return (name, type, seqid)
+
+ def readMessageEnd(self):
+ pass
+
+ def readStructBegin(self):
+ pass
+
+ def readStructEnd(self):
+ pass
+
+ def readFieldBegin(self):
+ type = self.readByte()
+ if type == TType.STOP:
+ return (None, type, 0)
+ id = self.readI16()
+ return (None, type, id)
+
+ def readFieldEnd(self):
+ pass
+
+ def readMapBegin(self):
+ ktype = self.readByte()
+ vtype = self.readByte()
+ size = self.readI32()
+ return (ktype, vtype, size)
+
+ def readMapEnd(self):
+ pass
+
+ def readListBegin(self):
+ etype = self.readByte()
+ size = self.readI32()
+ return (etype, size)
+
+ def readListEnd(self):
+ pass
+
+ def readSetBegin(self):
+ etype = self.readByte()
+ size = self.readI32()
+ return (etype, size)
+
+ def readSetEnd(self):
+ pass
+
+ def readBool(self):
+ byte = self.readByte()
+ if byte == 0:
+ return False
+ return True
+
+ def readByte(self):
+ buff = self.trans.readAll(1)
+ val, = unpack('!b', buff)
+ return val
+
+ def readI16(self):
+ buff = self.trans.readAll(2)
+ val, = unpack('!h', buff)
+ return val
+
+ def readI32(self):
+ buff = self.trans.readAll(4)
+ val, = unpack('!i', buff)
+ return val
+
+ def readI64(self):
+ buff = self.trans.readAll(8)
+ val, = unpack('!q', buff)
+ return val
+
+ def readDouble(self):
+ buff = self.trans.readAll(8)
+ val, = unpack('!d', buff)
+ return val
+
+ def readString(self):
+ len = self.readI32()
+ str = self.trans.readAll(len)
+ return str
+
+
+class TBinaryProtocolFactory:
+ def __init__(self, strictRead=False, strictWrite=True):
+ self.strictRead = strictRead
+ self.strictWrite = strictWrite
+
+ def getProtocol(self, trans):
+ prot = TBinaryProtocol(trans, self.strictRead, self.strictWrite)
+ return prot
+
+
+class TBinaryProtocolAccelerated(TBinaryProtocol):
+ """C-Accelerated version of TBinaryProtocol.
+
+ This class does not override any of TBinaryProtocol's methods,
+ but the generated code recognizes it directly and will call into
+ our C module to do the encoding, bypassing this object entirely.
+ We inherit from TBinaryProtocol so that the normal TBinaryProtocol
+ encoding can happen if the fastbinary module doesn't work for some
+ reason. (TODO(dreiss): Make this happen sanely in more cases.)
+
+ In order to take advantage of the C module, just use
+ TBinaryProtocolAccelerated instead of TBinaryProtocol.
+
+ NOTE: This code was contributed by an external developer.
+ The internal Thrift team has reviewed and tested it,
+ but we cannot guarantee that it is production-ready.
+ Please feel free to report bugs and/or success stories
+ to the public mailing list.
+ """
+ pass
+
+
+class TBinaryProtocolAcceleratedFactory:
+ def getProtocol(self, trans):
+ return TBinaryProtocolAccelerated(trans)
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBinaryProtocol.pyc
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBinaryProtocol.pyc b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBinaryProtocol.pyc
new file mode 100644
index 0000000..85a6486
Binary files /dev/null and b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TBinaryProtocol.pyc differ
http://git-wip-us.apache.org/repos/asf/airavata-sandbox/blob/75eb96c2/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TCompactProtocol.py
----------------------------------------------------------------------
diff --git a/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TCompactProtocol.py b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TCompactProtocol.py
new file mode 100644
index 0000000..fcf8e62
--- /dev/null
+++ b/Interacting_with_Airavata_using_ipython_Notebook/create-experiment/thrift/protocol/TCompactProtocol.py
@@ -0,0 +1,405 @@
+#
+# 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 struct import pack, unpack
+
+from thrift.protocol.TProtocol import *
+
+
+__all__ = ['TCompactProtocol', 'TCompactProtocolFactory']
+
+CLEAR = 0
+FIELD_WRITE = 1
+VALUE_WRITE = 2
+CONTAINER_WRITE = 3
+BOOL_WRITE = 4
+FIELD_READ = 5
+CONTAINER_READ = 6
+VALUE_READ = 7
+BOOL_READ = 8
+
+
+def make_helper(v_from, container):
+ def helper(func):
+ def nested(self, *args, **kwargs):
+ assert self.state in (v_from, container), (self.state, v_from, container)
+ return func(self, *args, **kwargs)
+ return nested
+ return helper
+writer = make_helper(VALUE_WRITE, CONTAINER_WRITE)
+reader = make_helper(VALUE_READ, CONTAINER_READ)
+
+
+def makeZigZag(n, bits):
+ return (n << 1) ^ (n >> (bits - 1))
+
+
+def fromZigZag(n):
+ return (n >> 1) ^ -(n & 1)
+
+
+def writeVarint(trans, n):
+ out = []
+ while True:
+ if n & ~0x7f == 0:
+ out.append(n)
+ break
+ else:
+ out.append((n & 0xff) | 0x80)
+ n = n >> 7
+ trans.write(''.join(map(chr, out)))
+
+
+def readVarint(trans):
+ result = 0
+ shift = 0
+ while True:
+ x = trans.readAll(1)
+ byte = ord(x)
+ result |= (byte & 0x7f) << shift
+ if byte >> 7 == 0:
+ return result
+ shift += 7
+
+
+class CompactType:
+ STOP = 0x00
+ TRUE = 0x01
+ FALSE = 0x02
+ BYTE = 0x03
+ I16 = 0x04
+ I32 = 0x05
+ I64 = 0x06
+ DOUBLE = 0x07
+ BINARY = 0x08
+ LIST = 0x09
+ SET = 0x0A
+ MAP = 0x0B
+ STRUCT = 0x0C
+
+CTYPES = {TType.STOP: CompactType.STOP,
+ TType.BOOL: CompactType.TRUE, # used for collection
+ TType.BYTE: CompactType.BYTE,
+ TType.I16: CompactType.I16,
+ TType.I32: CompactType.I32,
+ TType.I64: CompactType.I64,
+ TType.DOUBLE: CompactType.DOUBLE,
+ TType.STRING: CompactType.BINARY,
+ TType.STRUCT: CompactType.STRUCT,
+ TType.LIST: CompactType.LIST,
+ TType.SET: CompactType.SET,
+ TType.MAP: CompactType.MAP
+ }
+
+TTYPES = {}
+for k, v in CTYPES.items():
+ TTYPES[v] = k
+TTYPES[CompactType.FALSE] = TType.BOOL
+del k
+del v
+
+
+class TCompactProtocol(TProtocolBase):
+ """Compact implementation of the Thrift protocol driver."""
+
+ PROTOCOL_ID = 0x82
+ VERSION = 1
+ VERSION_MASK = 0x1f
+ TYPE_MASK = 0xe0
+ TYPE_SHIFT_AMOUNT = 5
+
+ def __init__(self, trans):
+ TProtocolBase.__init__(self, trans)
+ self.state = CLEAR
+ self.__last_fid = 0
+ self.__bool_fid = None
+ self.__bool_value = None
+ self.__structs = []
+ self.__containers = []
+
+ def __writeVarint(self, n):
+ writeVarint(self.trans, n)
+
+ def writeMessageBegin(self, name, type, seqid):
+ assert self.state == CLEAR
+ self.__writeUByte(self.PROTOCOL_ID)
+ self.__writeUByte(self.VERSION | (type << self.TYPE_SHIFT_AMOUNT))
+ self.__writeVarint(seqid)
+ self.__writeString(name)
+ self.state = VALUE_WRITE
+
+ def writeMessageEnd(self):
+ assert self.state == VALUE_WRITE
+ self.state = CLEAR
+
+ def writeStructBegin(self, name):
+ assert self.state in (CLEAR, CONTAINER_WRITE, VALUE_WRITE), self.state
+ self.__structs.append((self.state, self.__last_fid))
+ self.state = FIELD_WRITE
+ self.__last_fid = 0
+
+ def writeStructEnd(self):
+ assert self.state == FIELD_WRITE
+ self.state, self.__last_fid = self.__structs.pop()
+
+ def writeFieldStop(self):
+ self.__writeByte(0)
+
+ def __writeFieldHeader(self, type, fid):
+ delta = fid - self.__last_fid
+ if 0 < delta <= 15:
+ self.__writeUByte(delta << 4 | type)
+ else:
+ self.__writeByte(type)
+ self.__writeI16(fid)
+ self.__last_fid = fid
+
+ def writeFieldBegin(self, name, type, fid):
+ assert self.state == FIELD_WRITE, self.state
+ if type == TType.BOOL:
+ self.state = BOOL_WRITE
+ self.__bool_fid = fid
+ else:
+ self.state = VALUE_WRITE
+ self.__writeFieldHeader(CTYPES[type], fid)
+
+ def writeFieldEnd(self):
+ assert self.state in (VALUE_WRITE, BOOL_WRITE), self.state
+ self.state = FIELD_WRITE
+
+ def __writeUByte(self, byte):
+ self.trans.write(pack('!B', byte))
+
+ def __writeByte(self, byte):
+ self.trans.write(pack('!b', byte))
+
+ def __writeI16(self, i16):
+ self.__writeVarint(makeZigZag(i16, 16))
+
+ def __writeSize(self, i32):
+ self.__writeVarint(i32)
+
+ def writeCollectionBegin(self, etype, size):
+ assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
+ if size <= 14:
+ self.__writeUByte(size << 4 | CTYPES[etype])
+ else:
+ self.__writeUByte(0xf0 | CTYPES[etype])
+ self.__writeSize(size)
+ self.__containers.append(self.state)
+ self.state = CONTAINER_WRITE
+ writeSetBegin = writeCollectionBegin
+ writeListBegin = writeCollectionBegin
+
+ def writeMapBegin(self, ktype, vtype, size):
+ assert self.state in (VALUE_WRITE, CONTAINER_WRITE), self.state
+ if size == 0:
+ self.__writeByte(0)
+ else:
+ self.__writeSize(size)
+ self.__writeUByte(CTYPES[ktype] << 4 | CTYPES[vtype])
+ self.__containers.append(self.state)
+ self.state = CONTAINER_WRITE
+
+ def writeCollectionEnd(self):
+ assert self.state == CONTAINER_WRITE, self.state
+ self.state = self.__containers.pop()
+ writeMapEnd = writeCollectionEnd
+ writeSetEnd = writeCollectionEnd
+ writeListEnd = writeCollectionEnd
+
+ def writeBool(self, bool):
+ if self.state == BOOL_WRITE:
+ if bool:
+ ctype = CompactType.TRUE
+ else:
+ ctype = CompactType.FALSE
+ self.__writeFieldHeader(ctype, self.__bool_fid)
+ elif self.state == CONTAINER_WRITE:
+ if bool:
+ self.__writeByte(CompactType.TRUE)
+ else:
+ self.__writeByte(CompactType.FALSE)
+ else:
+ raise AssertionError("Invalid state in compact protocol")
+
+ writeByte = writer(__writeByte)
+ writeI16 = writer(__writeI16)
+
+ @writer
+ def writeI32(self, i32):
+ self.__writeVarint(makeZigZag(i32, 32))
+
+ @writer
+ def writeI64(self, i64):
+ self.__writeVarint(makeZigZag(i64, 64))
+
+ @writer
+ def writeDouble(self, dub):
+ self.trans.write(pack('!d', dub))
+
+ def __writeString(self, s):
+ self.__writeSize(len(s))
+ self.trans.write(s)
+ writeString = writer(__writeString)
+
+ def readFieldBegin(self):
+ assert self.state == FIELD_READ, self.state
+ type = self.__readUByte()
+ if type & 0x0f == TType.STOP:
+ return (None, 0, 0)
+ delta = type >> 4
+ if delta == 0:
+ fid = self.__readI16()
+ else:
+ fid = self.__last_fid + delta
+ self.__last_fid = fid
+ type = type & 0x0f
+ if type == CompactType.TRUE:
+ self.state = BOOL_READ
+ self.__bool_value = True
+ elif type == CompactType.FALSE:
+ self.state = BOOL_READ
+ self.__bool_value = False
+ else:
+ self.state = VALUE_READ
+ return (None, self.__getTType(type), fid)
+
+ def readFieldEnd(self):
+ assert self.state in (VALUE_READ, BOOL_READ), self.state
+ self.state = FIELD_READ
+
+ def __readUByte(self):
+ result, = unpack('!B', self.trans.readAll(1))
+ return result
+
+ def __readByte(self):
+ result, = unpack('!b', self.trans.readAll(1))
+ return result
+
+ def __readVarint(self):
+ return readVarint(self.trans)
+
+ def __readZigZag(self):
+ return fromZigZag(self.__readVarint())
+
+ def __readSize(self):
+ result = self.__readVarint()
+ if result < 0:
+ raise TException("Length < 0")
+ return result
+
+ def readMessageBegin(self):
+ assert self.state == CLEAR
+ proto_id = self.__readUByte()
+ if proto_id != self.PROTOCOL_ID:
+ raise TProtocolException(TProtocolException.BAD_VERSION,
+ 'Bad protocol id in the message: %d' % proto_id)
+ ver_type = self.__readUByte()
+ type = (ver_type & self.TYPE_MASK) >> self.TYPE_SHIFT_AMOUNT
+ version = ver_type & self.VERSION_MASK
+ if version != self.VERSION:
+ raise TProtocolException(TProtocolException.BAD_VERSION,
+ 'Bad version: %d (expect %d)' % (version, self.VERSION))
+ seqid = self.__readVarint()
+ name = self.__readString()
+ return (name, type, seqid)
+
+ def readMessageEnd(self):
+ assert self.state == CLEAR
+ assert len(self.__structs) == 0
+
+ def readStructBegin(self):
+ assert self.state in (CLEAR, CONTAINER_READ, VALUE_READ), self.state
+ self.__structs.append((self.state, self.__last_fid))
+ self.state = FIELD_READ
+ self.__last_fid = 0
+
+ def readStructEnd(self):
+ assert self.state == FIELD_READ
+ self.state, self.__last_fid = self.__structs.pop()
+
+ def readCollectionBegin(self):
+ assert self.state in (VALUE_READ, CONTAINER_READ), self.state
+ size_type = self.__readUByte()
+ size = size_type >> 4
+ type = self.__getTType(size_type)
+ if size == 15:
+ size = self.__readSize()
+ self.__containers.append(self.state)
+ self.state = CONTAINER_READ
+ return type, size
+ readSetBegin = readCollectionBegin
+ readListBegin = readCollectionBegin
+
+ def readMapBegin(self):
+ assert self.state in (VALUE_READ, CONTAINER_READ), self.state
+ size = self.__readSize()
+ types = 0
+ if size > 0:
+ types = self.__readUByte()
+ vtype = self.__getTType(types)
+ ktype = self.__getTType(types >> 4)
+ self.__containers.append(self.state)
+ self.state = CONTAINER_READ
+ return (ktype, vtype, size)
+
+ def readCollectionEnd(self):
+ assert self.state == CONTAINER_READ, self.state
+ self.state = self.__containers.pop()
+ readSetEnd = readCollectionEnd
+ readListEnd = readCollectionEnd
+ readMapEnd = readCollectionEnd
+
+ def readBool(self):
+ if self.state == BOOL_READ:
+ return self.__bool_value == CompactType.TRUE
+ elif self.state == CONTAINER_READ:
+ return self.__readByte() == CompactType.TRUE
+ else:
+ raise AssertionError("Invalid state in compact protocol: %d" %
+ self.state)
+
+ readByte = reader(__readByte)
+ __readI16 = __readZigZag
+ readI16 = reader(__readZigZag)
+ readI32 = reader(__readZigZag)
+ readI64 = reader(__readZigZag)
+
+ @reader
+ def readDouble(self):
+ buff = self.trans.readAll(8)
+ val, = unpack('!d', buff)
+ return val
+
+ def __readString(self):
+ len = self.__readSize()
+ return self.trans.readAll(len)
+ readString = reader(__readString)
+
+ def __getTType(self, byte):
+ return TTYPES[byte & 0x0f]
+
+
+class TCompactProtocolFactory:
+ def __init__(self):
+ pass
+
+ def getProtocol(self, trans):
+ return TCompactProtocol(trans)