Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata and Dependency information into job view #490

Merged
merged 2 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 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">

<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">
<span class = "row col-12">
<p><strong>Execution Info</strong>:</p>
<pre class="exc_info col-12"><%= d.exc_info %></pre>
</div>
</span>

</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
Loading