aboutsummaryrefslogtreecommitdiff
path: root/wqflask
diff options
context:
space:
mode:
Diffstat (limited to 'wqflask')
-rw-r--r--wqflask/wqflask/metadata_edits.py25
-rw-r--r--wqflask/wqflask/views.py11
2 files changed, 23 insertions, 13 deletions
diff --git a/wqflask/wqflask/metadata_edits.py b/wqflask/wqflask/metadata_edits.py
index 572db080..f87914d5 100644
--- a/wqflask/wqflask/metadata_edits.py
+++ b/wqflask/wqflask/metadata_edits.py
@@ -1,6 +1,7 @@
import datetime
import json
import os
+import re
from collections import namedtuple
from itertools import groupby
@@ -250,17 +251,21 @@ def update_phenotype(dataset_id: str, name: str):
file_.save(new_file_name)
publishdata_id = ""
lines = []
+ split_point = ""
with open(new_file_name, "r") as f:
lines = f.read()
- first_line = lines.split('\n', 1)[0]
- publishdata_id = first_line.split("Id:")[-1].strip()
+ for line in lines.split("\n"):
+ if "# Publish Data Id:" in line:
+ split_point = line
+ publishdata_id = re.findall(r'\b\d+\b', line)[0]
+ break
with open(new_file_name, "w") as f:
- f.write(lines.split("\n\n")[-1])
+ f.write(lines.split(f"{split_point}\n")[-1].strip())
csv_ = get_trait_csv_sample_data(conn=conn,
trait_name=str(name),
phenotype_id=str(phenotype_id))
with open(uploaded_file_name, "w") as f_:
- f_.write(csv_.split("\n\n")[-1])
+ f_.write(csv_.split(str(publishdata_id))[-1].strip())
r = run_cmd(cmd=("csvdiff "
f"'{uploaded_file_name}' '{new_file_name}' "
"--format json"))
@@ -423,9 +428,15 @@ def list_diffs():
gn_proxy_url=current_app.config.get("GN2_PROXY"))
return render_template(
"display_files.html",
- approved=files.get("approved"),
- rejected=files.get("rejected"),
- waiting=files.get("waiting"))
+ approved=sorted(files.get("approved"),
+ reverse=True,
+ key=lambda d: d.get("time_stamp")),
+ rejected=sorted(files.get("rejected"),
+ reverse=True,
+ key=lambda d: d.get("time_stamp")),
+ waiting=sorted(files.get("waiting"),
+ reverse=True,
+ key=lambda d: d.get("time_stamp")))
@metadata_edit.route("/diffs/<name>")
diff --git a/wqflask/wqflask/views.py b/wqflask/wqflask/views.py
index 2cbaffd6..55d9ebbe 100644
--- a/wqflask/wqflask/views.py
+++ b/wqflask/wqflask/views.py
@@ -131,9 +131,8 @@ def handle_generic_exceptions(e):
time_str = now.strftime('%l:%M%p UTC %b %d, %Y')
# get the stack trace and send it to the logger
exc_type, exc_value, exc_traceback = sys.exc_info()
- formatted_lines = {f"{request.url} ({time_str}) "
- f" {traceback.format_exc().splitlines()}"}
-
+ formatted_lines = (f"{request.url} ({time_str}) \n"
+ f"{traceback.format_exc()}")
_message_templates = {
werkzeug.exceptions.NotFound: ("404: Not Found: "
f"{time_str}: {request.url}"),
@@ -142,8 +141,8 @@ def handle_generic_exceptions(e):
werkzeug.exceptions.RequestTimeout: ("408: Request Timeout: "
f"{time_str}: {request.url}")}
# Default to the lengthy stack trace!
- logger.error(_message_templates.get(exc_type,
- formatted_lines))
+ app.logger.error(_message_templates.get(exc_type,
+ formatted_lines))
# Handle random animations
# Use a cookie to have one animation on refresh
animation = request.cookies.get(err_msg[:32])
@@ -152,7 +151,7 @@ def handle_generic_exceptions(e):
"./wqflask/static/gif/error") if fn.endswith(".gif")])
resp = make_response(render_template("error.html", message=err_msg,
- stack=formatted_lines,
+ stack={formatted_lines},
error_image=animation,
version=GN_VERSION))