SasView / sasview

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

Using the Data Operation tool adversely affects Save Project #2027

Open smk78 opened 2 years ago

smk78 commented 2 years ago

Reported by User JenniferG using 5.0.4 on W11. Verified by @smk78 using 5.0.4 & 5.0.5rc2 on W10.

An invalid and unusable .json project file is created if the Data Explorer contains data created with the Data Operation tool. The Log Explorer and log file also report something like this:

18:22:16 - ERROR: Traceback (most recent call last):
  File "site-packages\sasview-5.0.4-py3.6.egg\sas\qtgui\MainWindow\GuiManager.py", line 696, in actionSave_Project
  File "site-packages\sasview-5.0.4-py3.6.egg\sas\qtgui\Utilities\GuiUtils.py", line 1279, in saveData
  File "json\__init__.py", line 179, in dump
  File "json\encoder.py", line 430, in _iterencode
  File "json\encoder.py", line 353, in _iterencode_dict
TypeError: '<' not supported between instances of 'NoneType' and 'str'

To reproduce:

Current workaround: After generating datasets in the Data Operation tool, write them to file (right-click on the dataset > Save As), and delete them from the Data Explorer. Then re-load them from file. NB: this is only necessary if you wish to use Save Project from your session.

rozyczko commented 2 years ago

The new dataset created didn't have the id attribute defined. This attribute is used as a key in a dictionary during Save Project. Adding the id attribute seems to have solved the issue.

smk78 commented 2 years ago

Cool! Which branch did this go into? I put the issue against 5.1 because I thought it might be a can of worms, but it would be nice to fix this in 5.0.5...

rozyczko commented 2 years ago

I am not sure we really want any more new stuff in 5.0.5? This seems to be an old bug, not something new in 5.0.4 so maybe it's better to merge it after the 5.0.5 release?

The fix is in https://github.com/SasView/sasview/compare/data_operation_2027 branch

smk78 commented 2 years ago

Just tested the fix on W10/x64 as per instructions above. Works a treat! And saved projects load fine.