about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--uploader/jobs.py18
-rw-r--r--uploader/templates/phenotypes/job-status.html29
2 files changed, 42 insertions, 5 deletions
diff --git a/uploader/jobs.py b/uploader/jobs.py
index ff6a3c7..270028a 100644
--- a/uploader/jobs.py
+++ b/uploader/jobs.py
@@ -10,6 +10,7 @@ from datetime import timedelta
 from typing import Union, Optional
 
 from redis import Redis
+from functional_tools import take
 from flask import current_app as app
 
 JOBS_PREFIX = "jobs"
@@ -132,9 +133,16 @@ def update_stdout_stderr(rconn: Redis,
     rconn.hset(name=job_key(rprefix, jobid), key=stream, value=new_contents)
 
 
-def job_errors(rconn: Redis, prefix: str, job_id: Union[str, uuid.UUID]) -> tuple[dict, ...]:
+def job_errors(
+        rconn: Redis,
+        prefix: str,
+        job_id: Union[str, uuid.UUID],
+        count: int = 100
+) -> tuple[dict, ...]:
     """Fetch job errors"""
-    return tuple(
-        json.loads(error)
-        for key in rconn.keys(f"{prefix}:{str(job_id)}:*:errors:*")
-        for error in rconn.lrange(key, 0, -1))
+    return take(
+        (
+            json.loads(error)
+            for key in rconn.keys(f"{prefix}:{str(job_id)}:*:errors:*")
+            for error in rconn.lrange(key, 0, -1)),
+        count)
diff --git a/uploader/templates/phenotypes/job-status.html b/uploader/templates/phenotypes/job-status.html
index d531a71..cfbedd5 100644
--- a/uploader/templates/phenotypes/job-status.html
+++ b/uploader/templates/phenotypes/job-status.html
@@ -40,6 +40,35 @@
   {%endif%}
 </div>
 
+<div class="row" style="min-height: 3em; max-height: 30em; overflow: auto;">
+  <table class="table">
+    <caption>Errors</caption>
+    <thead>
+      <tr>
+        <th>File</th>
+        <th>Row</th>
+        <th>Column</th>
+        <th>Message</th>
+    </thead>
+
+    <tbody>
+      {%for error in errors%}
+      <tr>
+        <td>{{error.filename}}</td>
+        <td>{{error.rowtitle}}</td>
+        <td>{{error.coltitle}}</td>
+        <td>{{error.message}}</td>
+      </tr>
+      {%else%}
+      <tr>
+        <td colspan="4" class="text-info">
+          No errors found so far.
+        </td>
+      </tr>
+      {%endfor%}
+    </tbody>
+  </table>
+</div>
 <div class="row">
   {{cli_output(job, "stdout")}}
 </div>