def GetProblem(problemName, options): if not os.path.exists(options.datasets): os.mkdir(options.datasets) path = os.path.join(options.datasets, problemName + '.arff') if os.path.exists(path): return path else: logger.debug("Requesting problem " + problemName) problem = poligon.get_problem(problemName, options.algsynonim, options.algpassword) if not problem: raise Exception("Could not get problem " + problemName) _save_as_arff(problem, problemName, path) return path
def Run(options): commands = ReadCommands(options.commands) while True: while True: logger.debug("Requesting task...") task = poligon.get_task(options.algsynonim, options.algpassword) if task: logger.info("Got task for " + task.AlgSynonim + ". Problem: " + task.ProblemSynonim + ", PocketId: " + str(task.PocketId)) results = ProcessTask(task, options, commands) logger.debug("Task is processed. Registering results...") poligon.register_results(options.algsynonim, options.algpassword, task.PocketId, results) logger.info("Task is processed and results have been registered") else: break if options.wait == 0: break else: logger.info("No more tasks. Going to sleep...") time.sleep(options.wait * 60) logger.info("No more tasks. Exiting...")
def load_task_data(task, algPassword, dataFile, learnIndexes, testIndexes, algProperties): """Writes problem data, indexes and alg params into the given path""" class Indexes(object): def __init__(self, learn, test): self.test = test self.learn = learn # 1. Loading problem data problem = poligon.get_problem(task.ProblemSynonim, task.AlgSynonim, algPassword) if not problem: logger.error( 'Can\'t load problem \'{0}\' from server'.format(task.ProblemSynonim)) logger.debug( 'Problem \'{0}\' received with {1} rows'.format( task.ProblemSynonim, len(problem.DataMatrix.ArrayOfDouble))) objects, properties, classes = _save_as_arff(problem, task.ProblemSynonim, dataFile) logger.debug('Problem data saved as \'{0}\''.format(dataFile)) # 2. Saving indexes test = _save_indexes(task.TestIndexes, testIndexes) logger.debug('{0} test indexes saved'.format(len(test))) learn = _save_indexes(task.LearnIndexes, learnIndexes) logger.info('{0} learn indexes saved'.format(len(learn))) if len(test) != len(learn): logger.error('Indexes count mismatch') indexes = [] for i in range(0, len(learn)): indexes.append(Indexes(learn[i], test[i])) # 3. Writing alg properties count = _save_params(task, algProperties) logger.info('{0} alg params saved as \'{1}\''.format(count, algProperties)) return indexes #, properties, classes
self.ObjectsWeights = [] def __init__(self): self.Error = False self.ErrorException = '' self.Test = Result.Data() self.Learn = Result.Data() logger = _init_logger() parser = _init_optparser() (options, args) = parser.parse_args() logger.debug(options) # 1. Loading task info from poligon server task = poligon.get_task(options.algSynonim , options.algPassword) if not task: logger.info( "There is no task for {0} {1}".format( options.algSynonim, options.algPassword)) exit() while task: # 2. Loading task data and creating input files indexes = load_task_data(task, options.algPassword , options.data , options.learnIndexes , options.testIndexes , options.algProperties)