aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-12-02 15:50:50 -0600
committerFrederick Muriuki Muriithi2024-12-02 15:50:50 -0600
commit1b5de8142fface85eb6d2de4fdbff9a41536968a (patch)
tree68beed5c0c0f77dbeb7a1b86bad5afbf37514bbd
parentecc1fb7a1186cade850fd33c0468706efcd256c3 (diff)
downloadgn-uploader-1b5de8142fface85eb6d2de4fdbff9a41536968a.tar.gz
Add UI to view status of the job as it runs.
-rw-r--r--uploader/phenotypes/views.py27
-rw-r--r--uploader/templates/phenotypes/job-status.html69
2 files changed, 96 insertions, 0 deletions
diff --git a/uploader/phenotypes/views.py b/uploader/phenotypes/views.py
index 79aab81..f23b377 100644
--- a/uploader/phenotypes/views.py
+++ b/uploader/phenotypes/views.py
@@ -366,3 +366,30 @@ def add_phenotypes(species: dict, population: dict, dataset: dict, **kwargs):# p
# f"{app.config['UPLOAD_FOLDER']}/job_errors")
raise NotImplementedError("Please implement this...")
+
+
+@phenotypesbp.route(
+ "<int:species_id>/populations/<int:population_id>/phenotypes/datasets"
+ "/<int:dataset_id>/job/<uuid:job_id>",
+ methods=["GET"])
+@require_login
+@with_dataset(
+ species_redirect_uri="species.populations.phenotypes.index",
+ population_redirect_uri="species.populations.phenotypes.select_population",
+ redirect_uri="species.populations.phenotypes.list_datasets")
+def job_status(species: dict, population: dict, dataset: dict, job_id: uuid, **kwargs):
+ """Retrieve current status of a particular phenotype QC job."""
+ from uploader.debug import __pk__
+
+ with Redis.from_url(app.config["REDIS_URL"], decode_responses=True) as rconn:
+ try:
+ job = jobs.job(rconn, jobs.jobsnamespace(), str(job_id))
+ except jobs.JobNotFound as _jnf:
+ job = None
+ return render_template("phenotypes/job-status.html",
+ species=species,
+ population=population,
+ dataset=dataset,
+ job_id=job_id,
+ job=job,
+ activelink="add-phenotypes")
diff --git a/uploader/templates/phenotypes/job-status.html b/uploader/templates/phenotypes/job-status.html
new file mode 100644
index 0000000..d531a71
--- /dev/null
+++ b/uploader/templates/phenotypes/job-status.html
@@ -0,0 +1,69 @@
+{%extends "phenotypes/base.html"%}
+{%from "cli-output.html" import cli_output%}
+{%from "flash_messages.html" import flash_all_messages%}
+{%from "macro-table-pagination.html" import table_pagination%}
+{%from "phenotypes/macro-display-pheno-dataset-card.html" import display_pheno_dataset_card%}
+
+{%block extrameta%}
+{%if job and job.status not in ("success", "completed:success", "error", "completed:error")%}
+<meta http-equiv="refresh" content="5" />
+{%endif%}
+{%endblock%}
+
+{%block title%}Phenotypes{%endblock%}
+
+{%block pagetitle%}Phenotypes{%endblock%}
+
+{%block lvl4_breadcrumbs%}
+<li {%if activelink=="add-phenotypes"%}
+ class="breadcrumb-item active"
+ {%else%}
+ class="breadcrumb-item"
+ {%endif%}>
+ <a href="{{url_for('species.populations.phenotypes.add_phenotypes',
+ species_id=species.SpeciesId,
+ population_id=population.Id,
+ dataset_id=dataset.Id)}}">View Datasets</a>
+</li>
+{%endblock%}
+
+{%block contents%}
+
+{%if job%}
+<div class="row">
+ <p><strong>Status:</strong> {{job.status}}</p>
+ {%if job.status in ("completed:success", "success")%}
+ <p><a href="#"
+ class="not-implemented btn btn-primary"
+ title="Continue to process data">Continue</a>
+ </p>
+ {%endif%}
+</div>
+
+<div class="row">
+ {{cli_output(job, "stdout")}}
+</div>
+
+<div class="row">
+ {{cli_output(job, "stderr")}}
+</div>
+{%else%}
+<div class="row">
+ <h3 class="text-danger">No Such Job</h3>
+ <p>Could not find a job with the ID: {{job_id}}</p>
+ <p>
+ Please go back to
+ <a href="{{url_for('species.populations.phenotypes.view_dataset',
+ species_id=species.SpeciesId,
+ population_id=population.Id,
+ dataset_id=dataset.Id)}}"
+ title="'{{dataset.Name}}' dataset page">
+ the '{{dataset.Name}}' dataset page</a>
+ to upload new phenotypes or edit existing ones.</p>
+</div>
+{%endif%}
+{%endblock%}
+
+{%block sidebarcontents%}
+{{display_pheno_dataset_card(species, population, dataset)}}
+{%endblock%}