[Task] Solve the issue with interacting with ONCAT database
I checked through the issue and found this is probably too challenging for you to solve independently since you may not know what the best solution will be. I will put down what we need to check and change as below.
-
Trace back the issue.
- From the error message as presented below, we know it is something to do with
addie/databases/oncat/oncat.pyfile (line-70),
Traceback (most recent call last): File "/SNS/users/y8z/miniconda/envs/addie_env_3/lib/python3.6/site-packages/addie/processing/mantid/master_table/import_from_database/import_from_database_handler.py", line 397, in radio_button_changed self.ipts_selection_changed() File "/SNS/users/y8z/miniconda/envs/addie_env_3/lib/python3.6/site-packages/addie/processing/mantid/master_table/import_from_database/import_from_database_handler.py", line 449, in ipts_selection_changed self.refresh_preview_table_of_runs() File "/SNS/users/y8z/miniconda/envs/addie_env_3/lib/python3.6/site-packages/addie/processing/mantid/master_table/import_from_database/import_from_database_handler.py", line 271, in refresh_preview_table_of_runs o_import.from_oncat_template() File "/SNS/users/y8z/miniconda/envs/addie_env_3/lib/python3.6/site-packages/addie/processing/mantid/master_table/import_from_database/import_table_from_oncat_handler.py", line 54, in from_oncat_template projection=projection, File "/SNS/users/y8z/miniconda/envs/addie_env_3/lib/python3.6/site-packages/addie/databases/oncat/oncat.py", line 70, in pyoncatGetRunsFromIpts run_list = oncat.Datafile.list(facility=facility, AttributeError: 'NoneType' object has no attribute 'Datafile' Aborted (core dumped)- Search for
pyoncatGetRunsFromIptsand we know it is defined in line-70 ofaddie/databases/oncat/oncat.pyfile. But we need to go deeper to see where this defined function is called. Further checking of the search result forpyoncatGetRunsFromIpts, we know it is called inaddie/processing/mantid/master_table/import_from_database/import_table_from_oncat_handler.py(line-50, in the function definition forfrom_oncat_template). We then go deeper to search forfrom_oncat_templateand will arrive at line-257 which is the function body that will callfrom_oncat_template.
Now we need to think about what the fundamental reason is for the issue - from the error message printed out, it seems the
oncatobject isNonewhich means it is not given a value anywhere. Here in the definition forrefresh_preview_table_of_runs, we callfrom_oncat_templatewhich will try to access theoncatobject and return a json file. So here before we callfrom_oncat_templatefunction, we need to check whetheroncatisNoneor not. If indeed it isNone(like in our case, we clicked onCancelat the authentication stage so did not successfully fetch database data and thereforeoncatwill definitely beNone), we then need to return without doing anything. So just add in the following lines to the very top of the function definition forrefresh_preview_table_of_runs(line-257 inaddie/processing/mantid/master_table/import_from_database/import_from_database_handler.py),if self.parent.oncat is None: print("[Warning] ONCat connection not set up properly. Make sure you have logged in successfully.") self.ui.run_radio_button.setChecked(True) returnThe first and third line under the
ifstatement just tells the program that ifoncatisNone, we just print out a warning message and return. The second line is to make sure theRun(s) #radio button is checked since otherwise when we log in again, the whole program will freeze for some unknown reason (which I guess should be something to do with the GUI not being initialized properly after re-logging-in). By checking theRun(s) #button, we should be fine. - From the error message as presented below, we know it is something to do with