Commit 5dc64728 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Add table to gallery, Implements #112

parent 584b40ec
......@@ -56,6 +56,8 @@ def parse_args():
gallery_add.add_argument("-i", "--id-job", type=str, required=True,
help="Id (name) of the job to add to the gallery")
gallery_add.add_argument("-n", "--name", type=str, required=True, help="Name to show in the gallery for the job")
gallery_add.add_argument("-q", "--query", type=str, required=True, help="Name of the query")
gallery_add.add_argument("-t", "--target", type=str, required=True, help="Name of the target")
gallery_add.add_argument("-p", "--pict", type=str, required=True, help="Name of the file that illustrate the job")
# Gallery del:
......@@ -163,17 +165,18 @@ def clear_jobs(max_data_age=7):
print("")
def add_to_gallery(id_job, name, picture):
def add_to_gallery(id_job, name, picture, query, target):
try:
job = Job.get(id_job=id_job)
except DoesNotExist:
print("Error: job \"%s\" does not exists!" % id_job)
exit(1)
else:
pict_file = os.path.join(config.app_data, "gallery", picture)
if not os.path.exists(pict_file):
print("Error: file \"%s\" does not exists!" % pict_file)
exit(1)
item = Gallery.create(job=job, name=name, picture=picture)
item = Gallery.create(job=job, name=name, picture=picture, query=query, target=target)
item.save()
......@@ -210,7 +213,7 @@ if __name__ == "__main__":
print("Cleaning jobs...")
clear_jobs(args.max_age)
elif command == "gallery_add":
add_to_gallery(args.id_job, args.name, args.pict)
add_to_gallery(args.id_job, args.name, args.pict, args.query, args.target)
elif command == "gallery_del":
if args.id_job is None and args.name is None:
print("Error: please give an id or a name for the job!")
......
......@@ -68,6 +68,8 @@ class Job(BaseModel):
class Gallery(BaseModel):
job = ForeignKeyField(Job)
name = CharField()
query = CharField()
target = CharField()
picture = CharField()
......
......@@ -191,6 +191,16 @@ class Functions:
index, sample_name = Functions.read_index(index_file)
Functions.send_fasta_ready(mailer, job_name, sample_name, compressed)
@staticmethod
def get_readable_size(size):
units = ["Kb", "Mb", "Gb"]
i = 0
while size >= 1024 and i < 3:
size /= 1024.0
i += 1
return "%.1f %s" % (size, units[i])
@staticmethod
def get_gallery_items():
items = []
......@@ -198,7 +208,11 @@ class Functions:
items.append({
"name": item.name,
"id_job": item.job.id_job,
"picture": item.picture
"picture": item.picture,
"query": item.query,
"target": item.target,
"mem_peak": Functions.get_readable_size(item.job.mem_peak),
"time_elapsed": item.job.time_elapsed
})
return items
......@@ -30,6 +30,42 @@
</div>
</a>
{% endfor %}
<table class="table table-striped">
<thead>
<tr>
<th>
Reference genome
</th>
<th>
Query genome
</th>
<th>
Time elapsed
</th>
<th>
Maximum RAM usage
</th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>
{{ item.target }}
</td>
<td>
{{ item.query }}
</td>
<td>
{{ item.time_elapsed }}
</td>
<td>
{{ item.mem_peak }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="empty">Gallery is empty!</p>
{% endif %}
......
Supports Markdown
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