def resetAllJobs(data): """Resets all jobs""" for keys in db.Job.db_key_tuples(): txn = db.getTxn() jobDb = db.Job(*keys) jobToReset = jobDb.get(txn=txn) jobToReset.resetJob() jobDb.put(jobToReset, txn=txn) txn.commit()
def resetJob(data): """resets a job to a new state""" jobId = data['jobId'] txn = db.getTxn() jobDb = db.Job(jobId) jobToReset = jobDb.get(txn=txn, write=True) jobToReset.resetJob() jobDb.put(jobToReset, txn=txn) txn.commit() return jobToReset.__dict__()
def getAllJobs(data): jobs = [] for key in db.Job.db_key_tuples(): value = db.Job(*key).get() if value is None: continue jobs.append(value.__dict__()) return jobs
def restartAllJobs(data): for key in db.Job.db_key_tuples(): txn = db.getTxn() jobDb = db.Job(*key) job = jobDb.get(txn=txn, write=True) restarted = job.restartUnfinished() if restarted: jobDb.put(job, txn=txn) txn.commit()
def updateTask(data): """Updates a task given the job/task id and stuff to update it with""" jobId = data['id'] task = data['task'] txn = db.getTxn() jobDb = db.Job(jobId) jobToUpdate = jobDb.get(txn=txn, write=True) task = jobToUpdate.updateTask(task) jobDb.put(jobToUpdate, txn=txn) txn.commit() if jobToUpdate.status == 'Done': checkForMoreJobs(task) return task
def putNewJobWithTxn(self, txn, checkExists=True): """puts Job into job list if the job doesn't exist""" if checkExists: if self.checkIfExists(): return self.id = str(db.JobInfo('Id').incrementId(txn=txn)) self.iteration = db.Iteration( self.user, self.hub, self.track, self.problem['chrom'], self.problem['chromStart']).increment(txn=txn) self.putWithDb(db.Job(self.id), txn=txn) return self.id
def getJob(data): """Gets job by ID""" txn = db.getTxn() output = db.Job(data['id']).get().__dict__() txn.commit() return output