Beispiel #1
0
def result():
    # peer_id = 0
    result = request.json

    task_id = result['id']
    task = TaskController.get(task_id)
    task.completed += len(result['results'])
    job = task.job
    job.completed += len(result['results'])
    job.running -= len(result['results'])
    resultMatrix = Matrix.matrices[job.id]['result']
    taskMatrix = Matrix.matrices[job.id]['task']

    for res in result['results']:
        row = res['row']
        col = res['col']
        value = res['value']

        resultMatrix[row][col] = value
        taskMatrix[row][col] = Constants.STATE_DONE

    print("Job " + str(job.id) + ": " + str(job.completed) + "/" +
          str(job.toComplete) + " completed")

    if job.isFinished():
        filename = "result_matrices/result_job_" + str(job.id)
        print("Job " + str(job.id) + " completed. Writing result to file " +
              filename)
        MatrixController.writeToFile(Matrix.matrices[job.id]['result'],
                                     filename, True)
        job.end = datetime.now()
        # REMOVE JOB + MATRICES
    db.session.commit()

    return jsonify()
Beispiel #2
0
def result():
    # peer_id = 0
    result = request.json

    task_id = result['id']
    task = TaskController.get(task_id)
    task.completed += len(result['results'])
    job = task.job
    job.completed += len(result['results'])
    job.running -= len(result['results'])
    resultMatrix = Matrix.matrices[job.id]['result']
    taskMatrix = Matrix.matrices[job.id]['task']

    for res in result['results']:
        row = res['row']
        col = res['col']
        value = res['value']

        resultMatrix[row][col] = value
        taskMatrix[row][col] = Constants.STATE_DONE

    print ("Job " + str(job.id) + ": " + str(job.completed) + "/" + str(job.toComplete) + " completed")

    if job.isFinished():
        filename = "result_matrices/result_job_" + str(job.id)
        print ("Job " + str(job.id) + " completed. Writing result to file " + filename)
        MatrixController.writeToFile(Matrix.matrices[job.id]['result'],
                                     filename, True)
        job.end = datetime.now()
        # REMOVE JOB + MATRICES
    db.session.commit()

    return jsonify()
Beispiel #3
0
def get_task(id):
    return TaskController.get(id)