def calcSquareSum(self, ctx, params): """ :param params: instance of type "CalcSquareSumParams" (===================== main =====================) -> structure: parameter "n" of Long :returns: instance of type "CalcSquareSumInputOutput" -> structure: parameter "square_sum" of Long """ # ctx is the context object # return variables are: returnVal #BEGIN calcSquareSum kbp = KBParallel(os.environ['SDK_CALLBACK_URL'], token=ctx['token']) returnVal = kbp.run({ 'prepare_method': { 'module_name': 'ParallelSquareSum', 'method_name': 'calcSquareSumPrepare', 'service_ver': 'dev' }, 'is_local': 1, 'global_params': params, 'time_limit': 1000000 }) #END calcSquareSum # At some point might do deeper type checking... if not isinstance(returnVal, dict): raise ValueError('Method calcSquareSum return value ' + 'returnVal is not type dict as required.') # return the results return [returnVal]
def manyHellos(self, ctx, input_params): """ :param input_params: instance of type "ManyHellosInputParams" (hello_msg - what to print as the message, time_limit - how long the program will run, in seconds, workspace - used to store report(s).) -> structure: parameter "hello_msg" of String, parameter "num_jobs" of Long, parameter "time_limit" of Long, parameter "workspace" of String :returns: instance of type "ManyHellos_globalResult" -> structure: parameter "output" of String, parameter "jobs" of list of tuple of size 2: parameter "job_number" of Long, parameter "message" of String """ # ctx is the context object # return variables are: returnVal #BEGIN manyHellos print("Hi this is manyHellos()!") print("hello_mesg is ", input_params["hello_msg"]) print("time_limit is ", input_params["time_limit"]) print("num_jobs is ", input_params["num_jobs"]) print("workspace is ", input_params["workspace"]) kbp = KBParallel(os.environ['SDK_CALLBACK_URL'], token=ctx['token']) returnVal = kbp.run({ 'method': { 'module_name': 'ManyHellos', 'method_name': 'manyHellos', 'service_ver': 'dev' }, 'is_local': 1, 'global_params': { 'msg': input_params["hello_msg"], 'num_jobs': input_params["num_jobs"], 'workspace': input_params["workspace"] }, 'time_limit': input_params["time_limit"] }) print("this is manyHellos(), signing off! Bye!") #END manyHellos # At some point might do deeper type checking... if not isinstance(returnVal, dict): raise ValueError('Method manyHellos return value ' + 'returnVal is not type dict as required.') # return the results return [returnVal]