From ffd827d8ab5a544437e13c4001157954257a5921 Mon Sep 17 00:00:00 2001 From: adkinsrs Date: Fri, 30 Aug 2024 11:27:10 -0400 Subject: [PATCH 1/2] Resolving #880 --- lib/geardb.py | 4 ++-- www/cgi/save_dataset_display.cgi | 16 +++++++++++++--- www/dataset_curator.html | 8 ++++++++ www/js/curator_common.js | 23 ++++++++++++++++++++--- www/multigene_curator.html | 8 ++++++++ 5 files changed, 51 insertions(+), 8 deletions(-) diff --git a/lib/geardb.py b/lib/geardb.py index ca452698..bc273a50 100644 --- a/lib/geardb.py +++ b/lib/geardb.py @@ -108,7 +108,7 @@ def get_analysis(analysis, dataset_id, session_id): # Check that the h5ad file exists if not os.path.exists(ana.dataset_path()): - raise FileNotFoundError("No h5 file found for the passed in analysis") + raise FileNotFoundError("No h5 file found for the passed in analysis {}".format(ana.dataset_path())) else: ds = Dataset(id=dataset_id, has_h5ad=1) @@ -116,7 +116,7 @@ def get_analysis(analysis, dataset_id, session_id): # Let's not fail if the file isn't there if not os.path.exists(h5_path): - raise FileNotFoundError("No h5 file found for this dataset") + raise FileNotFoundError("No h5 file found for this dataset {}".format(h5_path)) ana = Analysis(type='primary', dataset_id=dataset_id) return ana diff --git a/www/cgi/save_dataset_display.cgi b/www/cgi/save_dataset_display.cgi index e799819f..330cff80 100755 --- a/www/cgi/save_dataset_display.cgi +++ b/www/cgi/save_dataset_display.cgi @@ -93,6 +93,14 @@ def main(): cursor = cnx.get_cursor() user = geardb.get_user_from_session_id(session_id=session_id) + + if not user: + print('User not found for session_id {}'.format(session_id), file=sys.stderr) + sys.stdout = original_stdout + print('Content-Type: application/json\n\n') + print(json.dumps(dict(display_id=None, success=False))) + return + user_id = user.id if display_id: @@ -113,10 +121,10 @@ def main(): WHERE id = %s; """ cursor.execute(query, (label, plot_type, plotly_config, display_id)) - result = dict(success=True) + result = dict(display_id=display_id, success=True) else: print('UPDATE DIDNT HAPPEN?', file=sys.stderr) - result = dict(success=False) + result = dict(display_id=display_id, success=False) else: # Display doesn't exist yet, insert new @@ -155,7 +163,8 @@ def main(): print("Invalid filename: {}".format(filename), file=sys.stderr) sys.stdout = original_stdout print('Content-Type: application/json\n\n') - print(json.dumps(dict(success=False))) + result["success"] = False + print(json.dumps(result)) return # Add plot_type to config so it can be passed in the POST cmd as well @@ -167,6 +176,7 @@ def main(): image_success = False url = "https://localhost/api/plot/{}".format(dataset_id) + is_local = True if is_local: url = alt_url diff --git a/www/dataset_curator.html b/www/dataset_curator.html index abb47257..3f284e1b 100644 --- a/www/dataset_curator.html +++ b/www/dataset_curator.html @@ -360,6 +360,14 @@
+
+
+ +
+
+
+
+ +
+