Skip to content

Commit

Permalink
Metadata and Dependency information into job view (#1)
Browse files Browse the repository at this point in the history
* naive py and html solution

* return list directly

* moved exc_info to top
  • Loading branch information
dopc authored May 24, 2024
1 parent cd896f8 commit 61d6cc5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 5 deletions.
24 changes: 20 additions & 4 deletions rq_dashboard/templates/rq_dashboard/job.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,39 @@ <h2><strong>Job ID</strong>: {{ id }}</h2>


<script name="job-info" type="text/template">
<div class = "row col-12">
<pre class="exc_info col-12"><%= d.exc_info %></pre>
</div>

<span class="col-6">
<p class="ellipsify"><strong>Description</strong>:<br><%= d.description %></p>
<p><strong>Origin queue</strong>:<br><%= d.origin %></p>
<p><strong>Status</strong>:<br><%= d.status %></p>
<p><strong>Result</strong>:<br><%= d.result %></p>
<p><strong>Metadata</strong>:<br><%= d.metadata %></p>
<p><strong>Depends on</strong>:</p>
<% if (d.depends_on) { %>
<ul>
<%
for (var i = 0; i < d.depends_on.length; i++) {
var jobId = d.depends_on[i].trim();
var status = d.depends_on_status[i].trim();
%>
<% if (status === "active") { %>
<li><a href="<%= url_for_single_job_view(jobId) %>"><%= jobId %></a></li>
<% } else { %>
<li><%= jobId %> (Expired)</li>
<% } %>
<% } %>
</ul>
<% } %>
</span>

<span class="col-6">
<p><strong>Created at</strong>:<br> <%= d.created_at %></p>
<p><strong>Enqueued at</strong>:<br> <%= d.enqueued_at %></p>
<p><strong>Ended at</strong>:<br> <%= d.ended_at %></p>
</span>

<div class = "row col-12">
<pre class="exc_info col-12"><%= d.exc_info %></pre>
</div>
</script>
</div>

Expand Down
16 changes: 15 additions & 1 deletion rq_dashboard/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
provides the option to require HTTP Basic Auth in a few lines of code.
"""
import json
import os
import re
from functools import wraps
Expand Down Expand Up @@ -577,7 +578,7 @@ def list_jobs(instance_number, queue_name, registry_name, per_page, page):
@jsonify
def job_info(instance_number, job_id):
job = Job.fetch(job_id, serializer=config.serializer)
return dict(
result = dict(
id=job.id,
created_at=serialize_date(job.created_at),
enqueued_at=serialize_date(job.enqueued_at),
Expand All @@ -587,7 +588,20 @@ def job_info(instance_number, job_id):
result=job.return_value(),
exc_info=str(job.exc_info) if job.exc_info else None,
description=job.description,
metadata=json.dumps(job.get_meta()),
)
dep_ids = [di.decode("utf-8").split(':')[-1].strip() for di in job.dependency_ids]
if len(dep_ids) > 0:
result["depends_on"] = dep_ids
status = []
for dep_id in dep_ids:
try:
_ = Job.fetch(dep_id, serializer=config.serializer)
status.append('active')
except NoSuchJobError:
status.append('expired')
result["depends_on_status"] = status
return result


@blueprint.route("/<int:instance_number>/data/workers.json")
Expand Down

0 comments on commit 61d6cc5

Please sign in to comment.