When an unexperienced symphony python developer trying to connect symphony via his python script (without knowing that he did not call function conn.create_session(sca) before making the connection call... the python script core dumped without giving any reason why... It gives nothing to the developer what went wrong... Our suggestion is to have detect such and print the error message instead of making a big core file...
iapp5112.devin1.ms.com andwang 2024-03-12 12:11:50 dev non-sym-cluster gui $ cat /v/global/user/s/so/soumasid/work/Symphony_Python/Python_Symphony_Client.py
# Run the following to set the SSO profile before triggering this program:
# source /ms/dist/grid/PROJ/clientconf/cva-in-pd-2-sso-720/profile.platform
import sys
import traceback
import uuid
# Symphony related imports
import soamapiversion
import soamapi
application_name = 'CVATWDistributedReporterEODCollator_uat2_143.0'
service_name = 'CVATWReporterCollatorEOD'
service_to_slot_ratio = (1, 8)
class MyMessage(soamapi.Message):
def __init__(self, i=None, is_sync=None, str=None):
self.__int = i
self.__bool = is_sync
self.__string = str
def get_int(self):
return self.__int
def set_int(self, i):
self.__int = i
def get_bool(self):
return self.__bool
def set_bool(self, is_sync):
self.__bool = is_sync
def get_string(self):
return self.__string
def set_string(self, str):
self.__string = str
def on_serialize(self, stream):
stream.write_int(self.__int)
stream.write_bool(self.__bool)
stream.write_string(self.__string)
def on_deserialize(self, stream):
self.__int = stream.read_int()
self.__bool = stream.read_bool()
self.__string = stream.read_string()
# Initialize soamapi
soamapi.initialize()
# Connect to Symphony Application
try:
# This is an SSO connection, so we don't need to provide username and password
sec = soamapi.DefaultSecurityCallback("", "")
conn = soamapi.connect(application_name, sec)
print('Connected to Symphony using Python! Connection ID: ' + conn.get_id())
except soamapi.SoamException:
print('Error while trying to connect to Symphony. Details:\n' + traceback.format_exc())
sys.exit()
# Set session attributes
sca = soamapi.SessionCreationAttributes()
sca.set_service_name(service_name)
sca.set_session_name(str(uuid.uuid4()))
sca.set_service_to_slot_ratio(soamapi.ServiceToSlotRatio(service_to_slot_ratio[0], service_to_slot_ratio[1]))
# Create session
session = conn.create_session(sca) <== missing this call
print('Symphony session created! Session ID: ' + session.get_id())
tasks_to_Submit = 1
hello = 'Hello Grid !!'
task_data = MyMessage(tasks_to_Submit, True, hello)
task_attr = soamapi.TaskSubmissionAttributes()
task_attr.set_task_input(task_data)
task_input_handle = session.send_task_input(task_attr)
prt_msg = "Sent task: " + task_input_handle.get_id()
print(prt_msg)
task_output_handle_list = session.fetch_task_output(tasks_to_Submit)
for task_output_handle in task_output_handle_list:
if task_output_handle.is_successful():
out_msg = MyMessage()
task_output_handle.populate_task_output(out_msg)
# Display content of reply
prt_msg = "Task Succeeded [" + task_output_handle.get_id() + "] \n"
prt_msg += "Integer Value : " + str(out_msg.get_int()) + "\n"
prt_msg += out_msg.get_string()
print(prt_msg)
else:
ex = task_output_handle.get_exception()
prt_msg = "Task Not Succeeded : " + str(ex)
print(prt_msg)
if ex.get_embedded_exception():
appEx = ex.get_embedded_exception()
print(appEx)
else:
print("No application exception")
task_output_handle = None
# Close session and connection and uninitialize soamapi
session.close()
conn.close()
print('Symphony session and connection closed.')
# Uninitialize soamapi
soamapi.uninitialize()
print("Done!")
iapp5112.devin1.ms.com andwang 2024-03-12 12:11:54 dev non-sym-cluster gui $