Skip to content
Draft
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
1 change: 1 addition & 0 deletions src/modules/site-v2/base/views/tools/genetic_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def list_results():
# Page info
'title': ('All' if show_all else 'My') + ' Genetic Mappings',
'tool_alt_parent_breadcrumb': {"title": "Tools", "url": url_for('tools.tools')},
'user_is_admin': user_is_admin(),

# Tool info
'tool_name': 'genetic_mapping',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def list_results():
'title': ('All' if show_all else 'My') + ' Heritability Results',
'subtitle': 'Report List',
'alt_parent_breadcrumb': {"title": "Tools", "url": url_for('tools.tools')},
'user_is_admin': user_is_admin(),

# Tool info
'tool_name': 'heritability_calculator',
Expand Down
37 changes: 35 additions & 2 deletions src/modules/site-v2/base/views/tools/pairwise_indel_finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from caendr.services.logger import logger
from flask import Response, Blueprint, render_template, request, url_for, jsonify, redirect, flash, abort

from base.forms import PairwiseIndelForm
from base.forms import PairwiseIndelForm, EmptyForm
from base.utils.auth import jwt_required, admin_required, get_current_user, user_is_admin
from base.utils.tools import list_reports, try_submit
from base.utils.view_decorators import parse_job_id, validate_form

from caendr.models.datastore.browser_track import BrowserTrackDefault
from caendr.models.datastore import Species, IndelPrimerReport, DatasetRelease
from caendr.models.error import NotFoundError, NonUniqueEntity
from caendr.models.error import NotFoundError, NonUniqueEntity, JobAlreadyScheduledError
from caendr.models.job_pipeline import IndelFinderPipeline
from caendr.services.dataset_release import get_dataset_release
from caendr.services.cloud.storage import BlobURISchema
Expand Down Expand Up @@ -145,9 +145,11 @@ def list_results():
# Page info
'title': ('All' if show_all else 'My') + ' Primer Reports',
'tool_alt_parent_breadcrumb': { "title": "Tools", "url": url_for('tools.tools'), },
'form': EmptyForm(),

# User info
'user': user,
'user_is_admin': user_is_admin(),

# Tool info
'tool_name': 'pairwise_indel_finder',
Expand All @@ -161,6 +163,7 @@ def list_results():
# Table info
'species_list': Species.all(),
'items': list_reports(IndelPrimerReport, None if show_all else user, filter_errs),
'rerunnable': True,
})


Expand Down Expand Up @@ -196,6 +199,36 @@ def submit(form_data, no_cache=False):



@pairwise_indel_finder_bp.route('/resubmit/<report_id>', methods=['POST'])
@admin_required()
@parse_job_id(IndelFinderPipeline, fetch=False)
def resubmit(job: IndelFinderPipeline):

# Try scheduling the job again
try:
job.schedule(no_cache=True)
return jsonify({
'ready': job.is_finished(),
'data_hash': job.report.data_hash,
'id': job.report.id,
})

# If this job is currently running, abort
except JobAlreadyScheduledError as ex:
return jsonify({
'message': 'This job is already running.',
}), 400

# Display any other errors to the (admin) user
except Exception as ex:
return jsonify({
'message': 'There was a problem resubmitting this job. Please try again later.',
'full_msg_link': 'See details.',
'full_msg_body': getattr(ex, 'message', str(ex)),
}), 500



@pairwise_indel_finder_bp.route("/report/<report_id>", methods=['GET'])
@pairwise_indel_finder_bp.route("/report/<report_id>/download/<file_ext>", methods=['GET'])
@jwt_required()
Expand Down
1 change: 1 addition & 0 deletions src/modules/site-v2/base/views/tools/phenotype_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ def list_results():

# User info
'user': user,
'user_is_admin': user_is_admin(),

# Tool info
'tool_name': 'phenotype_database',
Expand Down
50 changes: 47 additions & 3 deletions src/modules/site-v2/templates/tools/report-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@
{{ render_dataTable_result_list_header('Date', extra_classes='ordering') }}
{% if all_results %}
{{ render_dataTable_result_list_header('Owner', extra_classes='ordering') }}
{%- if user_is_admin and rerunnable %}
{{ render_dataTable_result_list_header('Rerun', extra_classes='ordering') }}
{%- endif %}
{% endif %}
</tr>
</thead>
Expand All @@ -96,6 +99,15 @@

{% if all_results %}
<td class="data-owner">{{ item.get_display_name() }}</td>
{%- if user_is_admin and rerunnable %}
<td class="data-rerun optionsToolbar">
{%- if item.status == JobStatus.ERROR %}
<button role="button" class="btn btn-link" onclick="resubmit(this, '{{ item.name }}')">
<i class="bi bi-arrow-right-circle-fill" aria-hidden="true"></i> Rerun
</a>
{%- endif %}
</td>
{%- endif %}
{% endif %}
</tr>
{% endif %}
Expand All @@ -110,7 +122,10 @@
{% endblock %}

{% block script %}
{% from "_scripts/submit-job.js" import ajax_setup %}
<script>
{% include '_scripts/utils.js' %} {#/* defines: flashErrorResponse */#}


const status_colors = {
"{{ JobStatus.ERROR }}" : "danger",
Expand All @@ -122,6 +137,11 @@

$(document).ready(function(){

// Set headers for AJAX requests
{%- if form %}
{{ ajax_setup(form.csrf_token._value()) }}
{%- endif %}

dTable = $('#result-table').DataTable( {
paging: true,
pageLength: 25,
Expand All @@ -136,14 +156,17 @@
{ "sWidth": ({{column.width}} * 36) + '%' },
{%- endfor %}
{
"sWidth": "10%",
"sWidth": "6%",
"createdCell": function (td, cellData, rowData, row, col) {
$(td).addClass( 'bg-' + status_colors[cellData.toUpperCase()] + ' bg-opacity-25' )
}
},
{ "sWidth": "22%" },
{ "sWidth": "20%" },
{%- if all_results %}
{ "sWidth": "22%" },
{ "sWidth": "18%" },
{%- if user_is_admin and rerunnable %}
{ "sWidth": "10%" },
{%- endif %}
{%- endif %}
],
dom: "tipr",
Expand All @@ -165,5 +188,26 @@
console.log("reload the page!")
}


{%- if rerunnable and user_is_admin %}
function resubmit(el, job_id) {
el.classList.add('disabled');

$.ajax({
url: "{{ url_for(tool_name + '.resubmit', report_id='JOB_ID') }}".replace("JOB_ID", job_id),
type: "POST",
})
.done((result) => {
el.classList.remove('disabled');
el.innerHTML = `<i class="bi bi-check-circle-fill" aria-hidden="true">`;
el.onclick = null;
})
.fail((error) => {
el.classList.remove('disabled');
flashErrorResponse(error.responseJSON, 'There was a problem resubmitting this job. Please try again later.');
})
}
{%- endif %}

</script>
{% endblock %}