Skip to content

Commit

Permalink
Added function to show results of processing modules. Fix for display…
Browse files Browse the repository at this point in the history
… of processing logs.
  • Loading branch information
tblock79 committed Jul 24, 2024
1 parent 843a299 commit 25b8241
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 7 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.1-beta.6
0.3.1-beta.7
15 changes: 13 additions & 2 deletions bookkeeping/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async def get_dicom_files(request) -> JSONResponse:
@router.get("/task_process_logs")
@requires("authenticated")
async def get_task_process_logs(request) -> JSONResponse:
"""Endpoint for getting all events related to one series."""
"""Endpoint for getting all processing logs related to one series."""
task_id = request.query_params.get("task_id", "")

subtask_query = (
Expand All @@ -149,7 +149,7 @@ async def get_task_process_logs(request) -> JSONResponse:
subtasks = await database.fetch_all(subtask_query)
subtask_ids = [row[0] for row in subtasks]

query = processor_logs_table.select(processor_logs_table.c.task_id.in_(subtask_ids))
query = processor_logs_table.select(processor_logs_table.c.task_id.in_(subtask_ids)).order_by(processor_logs_table.c.id)
results = [dict(r) for r in await database.fetch_all(query)]
for result in results:
if result["logs"] == None:
Expand All @@ -160,6 +160,17 @@ async def get_task_process_logs(request) -> JSONResponse:
return CustomJSONResponse(results)


@router.get("/task_process_results")
@requires("authenticated")
async def get_task_process_results(request) -> JSONResponse:
"""Endpoint for getting all processing results from a task."""
task_id = request.query_params.get("task_id", "")

query = processor_outputs_table.select().where(processor_outputs_table.c.task_id == task_id).order_by(processor_outputs_table.c.id)
results = [dict(r) for r in await database.fetch_all(query)]
return CustomJSONResponse(results)


@router.get("/find_task")
@requires("authenticated")
async def find_task(request) -> JSONResponse:
Expand Down
4 changes: 4 additions & 0 deletions common/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,5 +258,9 @@ async def task_process_logs(task_id="") -> Any:
return await get("query/task_process_logs", {"task_id": task_id})


async def task_process_results(task_id="") -> Any:
return await get("query/task_process_results", {"task_id": task_id})


async def get_task_info(task_id="") -> Any:
return await get("query/get_task_info", {"task_id": task_id})
10 changes: 10 additions & 0 deletions webinterface/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ async def task_process_logs(request):
return JSONResponse({"error": e.status_code}, status_code=e.status_code)


@router.get("/task-process-results")
@requires(["authenticated"])
async def task_process_results(request):
task_id = request.query_params.get("task_id", "")
try:
return JSONResponse(await monitor.task_process_results(task_id))
except monitor.MonitorHTTPError as e:
return JSONResponse({"error": e.status_code}, status_code=e.status_code)


@router.get("/get-task-info")
@requires(["authenticated"])
async def get_task_info(request):
Expand Down
4 changes: 2 additions & 2 deletions webinterface/statics/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -381,14 +381,14 @@ table.dataTable tbody tr.selected th, table.dataTable tbody tr.selected td {
height: 14px;
}

.process-logs-output {
.process-logs-output, .process-results-output {
font-family: monospace;
background-color: #0a0a0a;
color: #fff;
padding: 8px;
}

.process-logs-output::selection {
.process-logs-output::selection, .process-results-output::selection {
background-color: rgb(50, 115, 220);
color: #fff;
}
Expand Down
67 changes: 65 additions & 2 deletions webinterface/templates/queue.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,20 @@ <h5 class="title is-5 configtitle" style="margin-top: 60px;"><i
</div>
</div>

<div class="modal" id="process_results">
<div class="modal-background"></div>
<div class="modal-card process-results" style="width: 60%;">
<header class="modal-card-head">
<p class="modal-card-title">Processing Results</p>
</header>
<section class="modal-card-body process-results" style="background-color: #0a0a0a; border-left: 3px solid #FFF; border-right: 3px solid #FFF;">
<pre id="process_results_display" class="process-results process-results-output"></pre>
</section>
<footer class="modal-card-foot buttons is-centered">
<button class="button" type="button" id="closeprocessresults" onclick="closeProcessResults()">Close</button>
</footer>
</div>
</div>
</main>

<script>
Expand Down Expand Up @@ -812,9 +826,10 @@ <h5 class="title is-5 configtitle" style="margin-top: 60px;"><i
autoClose: true,
text: '<i class="fas fa-filter"></i>',
className: 'queueArchiveFilter',
titleAttr: 'Job filter',
buttons: [
{
text: 'Show only STUDY tasks',
text: 'Show only STUDY jobs',
className: 'queueArchiveFilterButton',
action: function (e, dt, node, config, cb) {
// Toggles class when pressed
Expand Down Expand Up @@ -848,7 +863,15 @@ <h5 class="title is-5 configtitle" style="margin-top: 60px;"><i
var jid = $('#jobs_archive').DataTable().rows( { selected: true } ).data()[0].slice(-1)[0];
showLogs(jid);
}
}
},
{
text: '<i class="fas fa-chart-bar"></i>',
titleAttr: 'Processing results',
action: function ( e, dt, node, config ) {
var jid = $('#jobs_archive').DataTable().rows( { selected: true } ).data()[0].slice(-1)[0];
showResults(jid);
}
}
],
dom: 'Bfrtip',
"scrollY": "740px",
Expand All @@ -865,6 +888,7 @@ <h5 class="title is-5 configtitle" style="margin-top: 60px;"><i
$('#jobs_archive').DataTable().button(1).enable( selectedRows > 0 );
$('#jobs_archive').DataTable().button(2).enable( selectedRows > 0 );
$('#jobs_archive').DataTable().button(3).enable( selectedRows > 0 );
$('#jobs_archive').DataTable().button(4).enable( selectedRows > 0 );
} );
$("#job_archive_search").on('keyup', function (event) {
if (event.keyCode === 13) {
Expand Down Expand Up @@ -945,6 +969,7 @@ <h5 class="title is-5 configtitle" style="margin-top: 60px;"><i
$('#jobs_archive').DataTable().button(1).enable(false);
$('#jobs_archive').DataTable().button(2).enable(false);
$('#jobs_archive').DataTable().button(3).enable(false);
$('#jobs_archive').DataTable().button(4).enable(false);
jobtable.draw();
},
complete: function (data) {
Expand Down Expand Up @@ -989,6 +1014,39 @@ <h5 class="title is-5 configtitle" style="margin-top: 60px;"><i
});
}

function showResults(jobId)
{
if (jobId === "") {
return;
}
$("#process_results").addClass("is-loading");

$.ajax({
type: 'GET',
url: '/api/task-process-results',
data: {'task_id': jobId},
dataType: 'json',
error: function () {
// $('#erroralert').show();
},
success: function (data) {
if (data && data.length > 0) {
var resultsText = "";
for (var i = 0; i < data.length; i++) {
resultsText += "### Module " + data[i].module + "\n\n";
resultsText += data[i].logs;
resultsText += "\n\n";
}
$("#process_results_display").text(resultsText);
} else {
$("#process_results_display").text("No processing results exist for the selected task.")
}
$("#process_results").addClass("is-active");
},
timeout: 5000
});
}

function showAuditTrail(jobId)
{
if (jobId === "") {
Expand Down Expand Up @@ -1027,6 +1085,11 @@ <h5 class="title is-5 configtitle" style="margin-top: 60px;"><i
$("#process_logs").removeClass("is-active");
}

function closeProcessResults()
{
$("#process_results").removeClass("is-active");
}

function showJobInformation(jobId,category)
{
if ((jobId === "") || (category === "")) {
Expand Down

0 comments on commit 25b8241

Please sign in to comment.