Commit 4708c1f7 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Add time elapsed and peak memory on status report while job succeeded

parent 753be3fc
......@@ -14,12 +14,12 @@ if [ "$fasta_q" != "NONE" ]; then
echo "Running: ${minimap_exec} -t ${nb_threads} ${fasta_t} ${fasta_q} > ${paf_raw}"
${minimap_exec} -t ${nb_threads} ${fasta_t} ${fasta_q} > ${paf_raw}
/usr/bin/time -f "%e %M" ${minimap_exec} -t ${nb_threads} ${fasta_t} ${fasta_q} > ${paf_raw}
else
echo "Running: ${minimap_exec} -t ${nb_threads} -X ${fasta_t} ${fasta_t} > ${paf_raw}"
${minimap_exec} -t ${nb_threads} -X ${fasta_t} ${fasta_t} > ${paf_raw}
/usr/bin/time -f "%e %M" ${minimap_exec} -t ${nb_threads} -X ${fasta_t} ${fasta_t} > ${paf_raw}
fi
......@@ -205,6 +205,7 @@ class JobManager:
jt.args = [self.config.minimap2_cluster_exec, self.config.nb_threads, self.target.get_path(),
self.get_query_split() if self.query is not None else "NONE", self.paf_raw]
jt.joinFiles = False
jt.errorPath = self.logs
native_specs = self.config.drmaa_native_specs
if batch_system_type == "slurm":
......@@ -360,6 +361,10 @@ class JobManager:
success = self.__launch_drmaa(batch_system_type)
if success:
job = Job.get(Job.id_job == self.id_job)
with open(self.logs) as logs:
measures = logs.readlines()[-1].strip("\n").split(" ")
job.time_elapsed = round(float(measures[0]))
job.mem_peak = int(measures[1])
job.status = "merging"
job.save()
if self.query is not None:
......@@ -431,6 +436,7 @@ class JobManager:
def status(self):
try:
job = Job.get(Job.id_job == self.id_job)
return job.status, job.error
return {"status": job.status, "mem_peak": job.mem_peak, "time_elapsed": job.time_elapsed,
"error": job.error}
except DoesNotExist:
return "unknown", ""
return {"status": "unknown", "error": ""}
......@@ -16,6 +16,8 @@ class Job(Model):
status = CharField(max_length=20, default="submitted")
date_created = DateTimeField()
error = CharField(default="")
mem_peak = IntegerField(null=True)
time_elapsed = IntegerField(null=True)
class Meta:
database = db
......
......@@ -137,9 +137,22 @@ def launch_analysis():
@app.route('/status/<id_job>', methods=['GET'])
def status(id_job):
job = JobManager(id_job)
j_status, error = job.status()
return render_template("status.html", title=app_title, status=j_status, error=error.replace("#ID#", ""),
id_job=id_job, menu="results")
j_status = job.status()
mem_peak = j_status["mem_peak"] if "mem_peak" in j_status else None
if mem_peak is not None:
mem_peak = "%.1f G" % (mem_peak / 1024.0 / 1024.0)
time_e = j_status["time_elapsed"] if "time_elapsed" in j_status else None
if time_e is not None:
if time_e < 60:
time_e = "%d secs" % time_e
else:
minutes = time_e // 60
seconds = time_e - minutes * 60
time_e = "%d min %d secs" % (minutes, seconds)
return render_template("status.html", title=app_title, status=j_status["status"],
error=j_status["error"].replace("#ID#", ""),
id_job=id_job, menu="results", mem_peak=mem_peak,
time_elapsed=time_e)
# Results path
......
......@@ -46,6 +46,8 @@
{% elif status == "success" %}
<p>Your job was completed successfully.<br/>
Please <a href="/result/{{ id_job }}">click here</a> to show results.</p>
<p>Time elapsed: {{ time_elapsed }}<br/>
Peak memory usage: {{ mem_peak }}</p>
{% elif status == "no-match" %}
<p>Your job is done.<br/>
Sorry, we did not find any match between your query and your target.</p>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment