diff options
author | Frederick Muriuki Muriithi | 2024-02-12 18:14:45 +0300 |
---|---|---|
committer | Frederick Muriuki Muriithi | 2024-02-12 18:14:45 +0300 |
commit | 3334120a07d8cc7d9ba2e1f23344df4d9c9c33bb (patch) | |
tree | 192c8bc28097347b34610bf7c1fac22d547a48a6 | |
parent | a7410cb1c55f6a06606ab7dcdacd18b11c672632 (diff) | |
download | gn-uploader-3334120a07d8cc7d9ba2e1f23344df4d9c9c33bb.tar.gz |
Provide better error messaging
Provide a better error message that can help the user figure out what
they did wrong and fix it for themselves instead of the older, cryptic
and extremely unhelpful error message.
-rw-r--r-- | scripts/insert_data.py | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/scripts/insert_data.py b/scripts/insert_data.py index 72fc897..a441dcb 100644 --- a/scripts/insert_data.py +++ b/scripts/insert_data.py @@ -253,10 +253,27 @@ def insert_se(# pylint: disable = [too-many-arguments] "VALUES(%(DataId)s, %(StrainId)s, %(DataValue)s)") annotations = annotationinfo(dbconn, platformid, datasetid) if not bool(annotations): - print( - (f"ERROR: No annotations found for platform {platformid} and " - f"dataset {datasetid}. Quiting!"), - file=sys.stderr) + with dbconn.cursor(cursorclass=DictCursor) as cursor: + dquery = cursor.execute(( + "SELECT " + "gc.GeneChipName AS platformname, pf.Name AS studyname, " + "psf.FullName AS datasetname " + "FROM GeneChip AS gc INNER JOIN ProbeFreeze AS pf " + "ON gc.Id=pf.ChipId INNER JOIN ProbeSetFreeze AS psf " + "ON pf.Id=psf.ProbeFreezeId " + "WHERE gc.Id=%s AND psf.Id=%s"), + (platformid, datasetid)) + + errorinfo = dquery.fetchone() + print(("ERROR: No annotations found for the " + f"'{errorinfo['datasetname']}' dataset (Id: {datasetid}) " + f"under the '{errorinfo['studyname']}' study linked to the " + f"'{errorinfo['platformname']}' platform (Id: {platformid})." + "\n\n" + " Please verify you selected the correct platform, " + "study and dataset for the standard-error file(s) you were " + "trying to upload."), + file=sys.stderr) return 1 se_values = ( |