Beispiel #1
0
def viewsimulationqueue(request):
    cxt_data = \
        {'simulation_queue_executing': SimQueueEntry.objects.filter(status=SimQueueEntryState.Executing),
         'simulation_queue': SimQueueEntry.objects.filter(status=SimQueueEntryState.Waiting),
         'latest_runs': SimFileRun.objects.order_by('-execution_date')[0:10]}

    SimQueueEntry.trim_dangling_jobs()

    csrf_context = RequestContext(request, cxt_data)
    return render_to_response('view_simulation_queue.html', csrf_context)
Beispiel #2
0
def overview_resubmit_simfile(_request, simfile_id):
    try:
        sim_file = SimFile.get_tracked_sims(id=simfile_id)
    except:
        return simplejson.dumps({})

    # Existing simulation object
    if not sim_file.simqueueentry_set.count():
        SimQueueEntry.create(sim_file=sim_file, runconfig=_request.session["current_runconfig"])
    return simplejson.dumps({})
Beispiel #3
0
def overview_resubmit_simfile(_request, simfile_id):
    try:
        sim_file = SimFile.get_tracked_sims(id=simfile_id)
    except:
        return simplejson.dumps({})

    # Existing simulation object
    if not sim_file.simqueueentry_set.count():
        SimQueueEntry.create(sim_file=sim_file,
                             runconfig=_request.session['current_runconfig'])
    return simplejson.dumps({})
Beispiel #4
0
def overview_resubmit_simfile_if_failure(_request, simfile_id):
    try:
        sim_file = SimFile.get_tracked_sims(id=simfile_id)
    except:
        return simplejson.dumps({})

    if sim_file.get_status(runconfig=_request.session['current_runconfig']) == SimRunStatus.Success:
        return simplejson.dumps({})

    if not sim_file.simqueueentry_set.count():
        SimQueueEntry.create(sim_file=sim_file, runconfig=_request.session['current_runconfig'])

    return simplejson.dumps({})
Beispiel #5
0
def overview_resubmit_simfile_if_failure(_request, simfile_id):
    try:
        sim_file = SimFile.get_tracked_sims(id=simfile_id)
    except:
        return simplejson.dumps({})

    if sim_file.get_status() == SimRunStatus.Sucess:
        return simplejson.dumps({})

    if not sim_file.simqueueentry_set.count():
        SimQueueEntry.create(sim_file=sim_file,
                             runconfig=_request.session['current_runconfig'])

    return simplejson.dumps({})
Beispiel #6
0
def overview_toggle_simfile_for_resubmit(_request, simfile_id):
    ensure_config()

    try:
        sim_file = SimFile.get_tracked_sims(id=simfile_id)
    except:
        return simplejson.dumps({})

    # Existing simulation object
    if sim_file.simqueueentry_set.count():
        sim_file.simqueueentry_set.all().delete()
    else:
        SimQueueEntry.create(sim_file=sim_file, runconfig=_request.session['current_runconfig'])

    return simplejson.dumps({})
Beispiel #7
0
def do_queue_add_sims(request):
    if not request.method == 'POST':
        return HttpResponseRedirect('/viewsimulationqueue')

    print 'Queuing Sims:'
    print request.POST
    r = re.compile(r"""simid_(?P<id>\d+)""", re.VERBOSE)
    sim_id_matches = [r.match(k) for k in request.POST]
    sim_ids = [int(m.groupdict()['id']) for m in sim_id_matches if m]

    for simfile_id in sim_ids:
        sim_file = SimFile.get_tracked_sims(id = simfile_id)

        qe = SimQueueEntry(simfile=sim_file)
        qe.save()

        # Avoid Duplication
    return HttpResponseRedirect('/viewsimulationqueue')
Beispiel #8
0
def update_queue(_request, action):
    print 'Action', action
    tracked_sim_files = SimFile.get_tracked_sims()
    print 'Tracked sim files:', len(tracked_sim_files)

    runconfig=_request.session['current_runconfig']

    if action == 'add-all':
        with transaction.commit_on_success():
            for simfile in tracked_sim_files:
                if simfile.simqueueentry_set.count() > 0:
                    continue
                SimQueueEntry.create( sim_file=simfile, runconfig=runconfig)
        return simplejson.dumps({})

    if action == 'clear-all':
        SimQueueEntry.objects.all() .filter(status = SimQueueEntryState.Waiting).delete()
        return simplejson.dumps({})

    # TODO! Move functionality into here!
    if action == "add-all-failures":
        with transaction.commit_on_success():
            for simfile in tracked_sim_files:
                if simfile.simqueueentry_set.count() > 0:
                    continue
                if simfile.get_status(runconfig=runconfig) not in (SimRunStatus.TimeOut, SimRunStatus.UnhandledException, SimRunStatus.NonZeroExitCode, SimRunStatus.FileChanged,SimRunStatus.NeverBeenRun):
                    continue
                SimQueueEntry.create( sim_file=simfile, runconfig=_request.session['current_runconfig'])
        return simplejson.dumps({})

    if action == "add-all-failures-not-timeout":
        with transaction.commit_on_success():
            for simfile in tracked_sim_files:
                if simfile.simqueueentry_set.count() > 0:
                    continue
                if simfile.get_status(runconfig=runconfig) not in (SimRunStatus.UnhandledException, SimRunStatus.NonZeroExitCode, SimRunStatus.FileChanged,SimRunStatus.NeverBeenRun):
                    continue
                SimQueueEntry.create( sim_file=simfile, runconfig=_request.session['current_runconfig'])
        return simplejson.dumps({})



    else:
        assert False, 'Unhandled aciton: %s'% action
    print 'Action', action
    return simplejson.dumps({})