[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.py
file (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
pyoncatGetRunsFromIpts
and we know it is defined in line-70 ofaddie/databases/oncat/oncat.py
file. 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_template
and 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
oncat
object isNone
which means it is not given a value anywhere. Here in the definition forrefresh_preview_table_of_runs
, we callfrom_oncat_template
which will try to access theoncat
object and return a json file. So here before we callfrom_oncat_template
function, we need to check whetheroncat
isNone
or not. If indeed it isNone
(like in our case, we clicked onCancel
at the authentication stage so did not successfully fetch database data and thereforeoncat
will 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) return
The first and third line under the
if
statement just tells the program that ifoncat
isNone
, 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