예제 #1
0
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()
예제 #2
0
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__()
예제 #3
0
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
예제 #4
0
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()
예제 #5
0
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
예제 #6
0
    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
예제 #7
0
def getJob(data):
    """Gets job by ID"""
    txn = db.getTxn()
    output = db.Job(data['id']).get().__dict__()
    txn.commit()
    return output