Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • A Alex_Project
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 6
    • Issues 6
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Zhang, Yuanpeng
  • Alex_Project
  • Issues
  • #13

Closed
Open
Created Jun 17, 2021 by Zhang, Yuanpeng@y8z⭐Owner

[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.

  1. 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 of addie/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 for pyoncatGetRunsFromIpts, we know it is called in addie/processing/mantid/master_table/import_from_database/import_table_from_oncat_handler.py (line-50, in the function definition for from_oncat_template). We then go deeper to search for from_oncat_template and will arrive at line-257 which is the function body that will call from_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 is None which means it is not given a value anywhere. Here in the definition for refresh_preview_table_of_runs, we call from_oncat_template which will try to access the oncat object and return a json file. So here before we call from_oncat_template function, we need to check whether oncat is None or not. If indeed it is None (like in our case, we clicked on Cancel at the authentication stage so did not successfully fetch database data and therefore oncat will definitely be None), we then need to return without doing anything. So just add in the following lines to the very top of the function definition for refresh_preview_table_of_runs (line-257 in addie/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 if oncat is None, we just print out a warning message and return. The second line is to make sure the Run(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 the Run(s) # button, we should be fine.

Edited Jun 20, 2021 by Zhang, Yuanpeng
Assignee
Assign to
Time tracking