def test(self): hutoma = EasyHutoma(USER_KEY) try: # get the list of AIs ais = hutoma.list_ai() self.assertTrue(isinstance(ais, list)) # if no AIs create one if len(ais) == 0: ais = hutoma.create_ai() self.assertTrue(len(ais) > 0) # test deletion old_len = len(ais) ais = hutoma.delete_ai(ais[0]) self.assertEqual(len(ais), old_len - 1) # ensure at least 1 AI if len(ais) == 0: ais = hutoma.create_ai() except HutomaException as e: logging.warn(e.message)
def main(): args = add_args() hutoma = EasyHutoma(args.user_key) input = raw_input( 'Attention! this will delete all existing AIs (type "quit" to exit): ') if 'quit' in input: return # get the list of available AIs ais = hutoma.list_ai() print 'AIs list: {0}'.format(ais) for ai in ais: print 'deleting {0}...'.format(ai) hutoma.delete_ai(ai) ais = hutoma.create_ai() print 'New AI created: {0}'.format(ais) aiid = ais[0] print 'AI id: {0}'.format(aiid) print 'Upload data files...' hutoma.training_upload_files(aiid, args.source_file, args.target_file) print 'Training monitor (check every {0} secs):'.format(args.sleep) print 'Start training...' start_time = time.time() response, _ = hutoma.training_start(aiid) print '\tStatus: {trainingStatusDetails:s}\n\tRuntime status: {runtimeStatusDetails:s}'.format( **response) print '\tScore: {score:s}'.format(**response) print '\tAIid: {0}'.format(aiid) while response.get('trainingStatus ', -1) < 3: time.sleep(args.sleep) response, _ = hutoma.current_status(aiid) print print '\n\tStatus: {trainingStatusDetails:s}\n\tRuntime status: {runtimeStatusDetails:s}'.format( **response) print '\tScore: {score:s}'.format(**response) print '\tAIid: {0}'.format(aiid) print '{0} secs to train'.format(int(time.time() - start_time)) print 'API calls: {0}'.format(hutoma.api_calls_count())
def main(): args = add_args() hutoma = EasyHutoma(args.user_key) input = raw_input('Attention! this will delete all existing AIs (type "quit" to exit): ') if "quit" in input: return # get the list of available AIs ais = hutoma.list_ai() print "AIs list: {0}".format(ais) for ai in ais: print "deleting {0}...".format(ai) hutoma.delete_ai(ai) ais = hutoma.create_ai() print "New AI created: {0}".format(ais) aiid = ais[0] print "AI id: {0}".format(aiid) print "Upload data files..." hutoma.training_upload_files(aiid, args.source_file, args.target_file) print "Training monitor (check every {0} secs):".format(args.sleep) print "Start training..." start_time = time.time() response, _ = hutoma.training_start(aiid) print "\tStatus: {trainingStatusDetails:s}\n\tRuntime status: {runtimeStatusDetails:s}".format(**response) print "\tScore: {score:s}".format(**response) print "\tAIid: {0}".format(aiid) while response.get("trainingStatus ", -1) < 3: time.sleep(args.sleep) response, _ = hutoma.current_status(aiid) print print "\n\tStatus: {trainingStatusDetails:s}\n\tRuntime status: {runtimeStatusDetails:s}".format(**response) print "\tScore: {score:s}".format(**response) print "\tAIid: {0}".format(aiid) print "{0} secs to train".format(int(time.time() - start_time)) print "API calls: {0}".format(hutoma.api_calls_count())