SasView / sasview

Code for the SasView application.
BSD 3-Clause "New" or "Revised" License
48 stars 41 forks source link

Saving Project with the general scattering calculator throws an error #2798

Closed butlerpd closed 1 month ago

butlerpd commented 7 months ago

Describe the bug Reported by user Sabol-Pulling.

Whenever I try to save my sasview window as a json project file after using the generic scattering calculator I get the following error:

  File "sas\qtgui\MainWindow\GuiManager.py", line 711, in actionSave_Project
  File "sas\qtgui\Utilities\GuiUtils.py", line 1279, in saveData
  File "json\__init__.py", line 179, in dump
  File "json\encoder.py", line 431, in _iterencode
  File "json\encoder.py", line 353, in _iterencode_dict
TypeError: '<' not supported between instances of 'NoneType' and 'str'

To Reproduce I reproduced the error using 6.0.0 alpha1 as follows:

  1. bring up the Generic Scattering Calculator
  2. Load pdb file (I used dna)
  3. Click on "Compute Debye full average
  4. See plot show up on SasView canvas
  5. Go to File -> Save Project
  6. See error

Expected behavior The general scattering calculator is a tool and therefore does not have a "save state." However SasView should save the sate of all open perspectives, or if none, state there are none to save, but should not throw a traceback error

SasView version (please complete the following information):

Operating system (please complete the following information):

krzywon commented 1 month ago

I just tested this on v5.0.6 and am seeing the same error. This seems to be an issue with the data objects being produced by the generic scattering calculator. The exact issue isn't clear to me yet, but I will continue to look into this. Because this is not a new issue to v6.0.0, I don't know if we want to fix this for the final release.

Note - Going back to v5.0.6, the GSC in v6.0.0 is now obviously much faster for both data loading and calculations.

rozyczko commented 1 month ago

The Data object needs the .id field to be serializable. Added this to GSC generated data. Also, improved our json serialized to handle DataRole enums as it was not saving these for the GSC data.